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 ConceptElement GetConceptElement(Concept parent, ViewpointProjectionEntity config) { var key = config.Entity.GetReference().ToString(); ConceptElement element = parent.Children.FirstOrDefault(c => c.ReferenceSource == key); if (element == null) { element = new ConceptElement(this.Partition) { ReferenceSource = key, Name = config.Entity.Label ?? config.Entity.Name, Type = config.Entity.TypeEntity, }; parent.Children.Add(element); } return(element); }
private void CreateItem(ViewpointProjectionEntities k2) { using (Transaction t = this.Store.TransactionManager.BeginTransaction("automated model")) { foreach (var item in k2.Entities) { if (item.Kind == Galileo.Files.Viewpoints.ViewpointItem.Concept) { Concept concept = GetConcept(item); foreach (var parent in item.Children) { ConceptElement s = GetConceptElement(concept, parent); foreach (var subParent in parent.Children) { GetConceptSubElement(s, subParent); } } } else { ModelElement parent = GetModelElement(item); foreach (var subParent in item.Children) { GetSubElement(parent, subParent); } } } // t.Commit(); //} //using (Transaction t = this.Store.TransactionManager.BeginTransaction("automated model")) //{ GenerateRelationships(k2); t.Commit(); } }
private bool EvaluateReference(ValidationContext context, ModelRepository referential, ConceptElement 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); }