private bool ValidateConceptElement(ConceptElement conceptElement, ConceptSubElement configConceptElement, ValidationContext context, Galileo.Files.ModelRepository referential) { var changed = false; foreach (ConceptSubElement conceptSubElement in conceptElement.Children) { if (EvaluateReference(context, referential, conceptSubElement)) { changed = true; } } return(changed); }
private ConceptSubElement GetConceptSubElement(ConceptElement parent, ViewpointProjectionEntity config) { var key = config.Entity.GetReference().ToString(); ConceptSubElement element = parent.Children.FirstOrDefault(c => c.ReferenceSource == key); if (element == null) { element = new ConceptSubElement(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, ConceptSubElement 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); }