public IEnumerable <uSyncDependency> GetDependencies(ITemplate item, DependencyFlags flags) { var dependencies = new List <uSyncDependency>(); // only get teh dependencies for templates if the flag is set. if (!flags.HasFlag(DependencyFlags.IncludeViews)) { return(dependencies); } dependencies.Add(new uSyncDependency() { Name = item.Name, Order = DependencyOrders.Templates, Udi = item.GetUdi(), Flags = flags, Level = CalculateLevel(item) }); // always get the parents of a template?? // if (flags.HasFlag(DependencyFlags.IncludeAncestors)) // { dependencies.AddRange(GetParents(item, DependencyOrders.Templates - 1, flags)); // } if (flags.HasFlag(DependencyFlags.IncludeChildren)) { // children check. dependencies.AddRange(GetChildren(item, DependencyOrders.Templates + 1, flags)); } return(dependencies); }
/// <summary> /// so do we want this ? go through all the picked values in the content, /// and include them in the things to export ? /// </summary> /// <param name="item"></param> /// <returns></returns> protected IEnumerable <uSyncDependency> GetPropertyDependencies(IContentBase item, DependencyFlags flags) { var dependencies = new List <uSyncDependency>(); var propertyFlags = flags & ~DependencyFlags.IncludeChildren; foreach (var property in item.Properties) { var editorAlias = property.PropertyType.PropertyEditorAlias; var mapper = mappers.GetSyncMapper(editorAlias); if (mapper != null) { foreach (var value in property.Values) { if (value.EditedValue == null) { continue; } var linkedDependencies = mapper.GetDependencies(value.EditedValue, editorAlias, propertyFlags); // include linked means all content we link to if (flags.HasFlag(DependencyFlags.IncludeLinked)) { dependencies.AddRange(linkedDependencies.Where(x => x.Udi.EntityType == UdiEntityType.Document)); } // include any settings things we would be dependent on for this property. if (flags.HasFlag(DependencyFlags.IncludeDependencies)) { dependencies.AddRange(linkedDependencies.Where(x => settingsTypes.InvariantContains(x.Udi.EntityType))); } // media means we include media items (the files are checked) if (flags.HasFlag(DependencyFlags.IncludeMedia)) { var media = linkedDependencies.Where(x => x.Udi.EntityType == UdiEntityType.Media || x.Udi.EntityType == UdiEntityType.MediaFile).ToList(); media.ForEach(x => { x.Flags |= DependencyFlags.IncludeAncestors; }); dependencies.AddRange(media); } } } } return(dependencies); }
public IEnumerable <uSyncDependency> GetDependencies(IMediaType item, DependencyFlags flags) { var dependencies = new List <uSyncDependency>(); var dependentFlags = flags & ~DependencyFlags.IncludeChildren; dependencies.Add(new uSyncDependency() { Name = item.Name, Udi = item.GetUdi(), Order = DependencyOrders.MediaTypes, Flags = flags, Level = item.Level }); if (flags.HasFlag(DependencyFlags.IncludeDependencies)) { dependencies.AddRange(CalcDataTypeDependencies(item, dependentFlags)); dependencies.AddRange(CalcCompositions(item, DependencyOrders.MediaTypes - 1, dependentFlags)); } dependencies.AddRange(CalcChildren(item.Id, flags)); return(dependencies); }
protected IEnumerable <uSyncDependency> CalcChildren(int itemId, DependencyFlags flags) { var childItems = new List <uSyncDependency>(); if (flags.HasFlag(DependencyFlags.IncludeChildren)) { var children = entityService.GetDescendants(itemId, this.ObjectType); if (children != null && children.Any()) { foreach (var child in children.OrderBy(x => x.Level)) { if (child != null) { childItems.Add(new uSyncDependency() { Name = child.Name, Udi = Udi.Create(UdiEntityType.FromUmbracoObjectType(this.ObjectType), child.Key), Flags = flags & ~DependencyFlags.IncludeAncestors, Level = child.Level, Order = DependencyOrders.ContentTypes + child.Level }); } } } } return(childItems); }
public IEnumerable <uSyncDependency> GetDependencies(IContent item, DependencyFlags flags) { uSyncDependency.FireUpdate(item.Name); var dependencies = new List <uSyncDependency>(); dependencies.Add(new uSyncDependency() { Name = item.Name, Udi = item.GetUdi(), Order = DependencyOrders.Content, Flags = flags, Level = item.Level }); if (flags.HasFlag(DependencyFlags.IncludeDependencies)) { var contentType = CalcDocTypeDependency(item, flags); if (contentType != null) { dependencies.Add(contentType); } } // if we are getting linked items or media, include in the look up. if (flags.HasFlagAny(DependencyFlags.IncludeLinked | DependencyFlags.IncludeMedia | DependencyFlags.IncludeDependencies)) { uSyncDependency.FireUpdate($"{item.Name} Property Dependencies"); dependencies.AddRange(GetPropertyDependencies(item, flags)); } if (flags.HasFlag(DependencyFlags.IncludeAncestors)) { uSyncDependency.FireUpdate($"{item.Name} Ancestors"); dependencies.AddRange(GetParentDependencies(item.Id, DependencyOrders.Content - 1, flags)); } if (flags.HasFlag(DependencyFlags.IncludeChildren)) { uSyncDependency.FireUpdate($"{item.Name} Children"); dependencies.AddRange(GetChildDepencies(item.Id, DependencyOrders.Content + 1, flags, 1, uSyncContent.DependencyCountMax)); } return(dependencies); }
public IEnumerable <uSyncDependency> GetDependencies(IMedia item, DependencyFlags flags) { uSyncDependency.FireUpdate(item.Name); var dependencies = new List <uSyncDependency>(); dependencies.Add(new uSyncDependency() { Name = item.Name, Udi = item.GetUdi(), Order = DependencyOrders.Media, Flags = flags, Level = item.Level }); if (flags.HasFlag(DependencyFlags.IncludeDependencies)) { var contentType = CalcDocTypeDependency(item, flags); if (contentType != null) { dependencies.Add(contentType); } } if (flags.HasFlag(DependencyFlags.IncludeAncestors)) { // dependencies.AddRange(GetParentDependencies(item.Id, DependencyOrders.Media - 1, flags)); dependencies.AddRange(GetParentDependencies(item.Path, DependencyOrders.Media - 1, flags)); } if (flags.HasFlag(DependencyFlags.IncludeChildren)) { dependencies.AddRange(GetChildDepencies(item.Id, DependencyOrders.Media + 1, flags, 1, uSyncContent.DependencyCountMax)); } return(dependencies); }
public override IEnumerable <uSyncDependency> GetDependencies(object value, string editorAlias, DependencyFlags flags) { var jsonValue = GetJsonValue(value); if (value == null || jsonValue == null) { return(Enumerable.Empty <uSyncDependency>()); } var docValue = jsonValue.Value <JObject>("value"); var docTypeAlias = jsonValue.Value <string>(this.docTypeAliasValue); if (docValue == null || docTypeAlias == null) { return(Enumerable.Empty <uSyncDependency>()); } var docType = GetDocType(docTypeAlias); if (docType == null) { return(Enumerable.Empty <uSyncDependency>()); } List <uSyncDependency> dependencies = new List <uSyncDependency>(); if (flags.HasFlag(DependencyFlags.IncludeDependencies)) { // get the docType as a dependency. // you only need to get the primary doctype, a subsequent check // will get the full dependency tree for this doctype if it // is needed. var docDependency = CreateDocTypeDependency(docTypeAlias, flags); if (docDependency != null) { dependencies.Add(docDependency); } } // let the base class go through the PropertyTypes // and call the mappers for each value, this gets us // any internal dependencies (like media, etc) // from within the content. dependencies.AddRange(GetPropertyDependencies(docValue, docType, flags)); return(dependencies); }
public override IEnumerable <uSyncDependency> GetDependencies(object value, string editorAlias, DependencyFlags flags) { var stringValue = GetValueAs <string>(value); if (string.IsNullOrWhiteSpace(stringValue) || !stringValue.DetectIsJson()) { return(Enumerable.Empty <uSyncDependency>()); } var elements = JsonConvert.DeserializeObject <JArray>(stringValue); if (elements == null || !elements.Any()) { return(Enumerable.Empty <uSyncDependency>()); } var dependencies = new List <uSyncDependency>(); foreach (var item in elements.Cast <JObject>()) { var itemValue = item.Value <JObject>("value"); if (itemValue == null) { continue; } var doctype = GetDocTypeByKey(item, "elementType"); if (doctype == null) { continue; } if (flags.HasFlag(DependencyFlags.IncludeDependencies)) { var doctypeDependency = CreateDocTypeDependency(doctype.Alias, flags); if (doctypeDependency != null) { dependencies.Add(doctypeDependency); } } dependencies.AddRange(GetPropertyDependencies(itemValue, doctype, flags)); } return(dependencies); }
public override IEnumerable <uSyncDependency> GetDependencies(object value, string editorAlias, DependencyFlags flags) { var stringValue = GetValueAs <string>(value); if (string.IsNullOrWhiteSpace(stringValue) || !stringValue.DetectIsJson()) { return(Enumerable.Empty <uSyncDependency>()); } var nestedJson = JsonConvert.DeserializeObject <JArray>(stringValue); if (nestedJson == null || !nestedJson.Any()) { return(Enumerable.Empty <uSyncDependency>()); } var dependencies = new List <uSyncDependency>(); foreach (var item in nestedJson.Cast <JObject>()) { var docTypeAlias = item[this.docTypeAliasValue].ToString(); var docType = GetDocType(docTypeAlias); if (docType == null) { continue; } if (flags.HasFlag(DependencyFlags.IncludeDependencies)) { var docTypeDep = CreateDocTypeDependency(docTypeAlias, flags); if (docTypeDep != null) { dependencies.Add(docTypeDep); } } dependencies.AddRange(GetPropertyDependencies(item, docType, flags)); } return(dependencies); }
private IEnumerable <uSyncDependency> CalcTemplateDependencies(IContentType item, DependencyFlags flags) { var templates = new List <uSyncDependency>(); if (flags.HasFlag(DependencyFlags.IncludeViews)) { foreach (var template in item.AllowedTemplates) { templates.Add(new uSyncDependency() { Name = item.Name, Udi = template.GetUdi(), Order = DependencyOrders.Templates, Flags = flags, Level = template.Path.ToDelimitedList().Count() }); } } return(templates); }