private SubElement GetSubElement(ModelElement parent, ViewpointProjectionEntity config) { var key = config.Entity.GetReference().ToString(); SubElement element = parent.Children.FirstOrDefault(c => c.ReferenceSource == key); if (element == null) { element = new SubElement(this.Partition) { ReferenceSource = key, Name = config.Entity.Label ?? config.Entity.Name, Type = config.Entity.TypeEntity, }; parent.Children.Add(element); } return(element); }
private bool EvaluateReference(ValidationContext context, ModelRepository referential, SubElement element) { bool changed = false; var definition = element.GetDefinition(referential); if (definition == null) { context.LogError($"failed to resolve definition '{element.Type}'", CodeErrorEnum.BadConfiguration.ToString(), element); } else if (string.IsNullOrEmpty(element.ReferenceSource)) { context.LogError($"missing reference in the configuration viewpoint '{this.Name}'", CodeErrorEnum.BadConfiguration.ToString(), element); } else { var item = element.GetEntity(referential); if (item == null) { if (!string.IsNullOrEmpty(element.Type)) { element.Type = string.Empty; changed = true; } context.LogError($"Reference '{element.ReferenceSource}' can't be resolved in the configuration viewpoint '{this.Name}'", CodeErrorEnum.BadConfiguration.ToString(), element); } else { if (item is ReferentialEntity e) { if (e.TypeEntity != element.Type) { element.Type = e.TypeEntity; changed = true; } if (e.Name != element.Name) { element.Name = e.Name; changed = true; } } } } return(changed); }