internal static void ExportMvdConceptRoot(ConceptRoot mvdConceptRoot, DocConceptRoot docRoot, bool documentation) { ExportMvdObject(mvdConceptRoot, docRoot, documentation); if (String.IsNullOrEmpty(mvdConceptRoot.Name)) { mvdConceptRoot.Name = docRoot.ApplicableEntity.Name; } mvdConceptRoot.ApplicableRootEntity = docRoot.ApplicableEntity.Name; if (docRoot.ApplicableTemplate != null) { mvdConceptRoot.Applicability = new ApplicabilityRules(); mvdConceptRoot.Applicability.Template = new TemplateRef(); mvdConceptRoot.Applicability.Template.Ref = docRoot.ApplicableTemplate.Uuid; mvdConceptRoot.Applicability.TemplateRules = new TemplateRules(); mvdConceptRoot.Applicability.TemplateRules.Operator = (TemplateOperator)Enum.Parse(typeof(TemplateOperator), docRoot.ApplicableOperator.ToString()); foreach (DocTemplateItem docItem in docRoot.ApplicableItems) { TemplateRule rule = ExportMvdItem(docItem); mvdConceptRoot.Applicability.TemplateRules.TemplateRule.Add(rule); } } foreach (DocTemplateUsage docTemplateUsage in docRoot.Concepts) { Concept mvdConceptLeaf = new Concept(); mvdConceptRoot.Concepts.Add(mvdConceptLeaf); ExportMvdConcept(mvdConceptLeaf, docTemplateUsage, documentation); } }
internal static void ExportMvdConcept(Concept mvdConceptLeaf, DocTemplateUsage docTemplateUsage, bool documentation) { if (docTemplateUsage.Definition == null) return; ExportMvdObject(mvdConceptLeaf, docTemplateUsage, documentation); mvdConceptLeaf.Template = new TemplateRef(); mvdConceptLeaf.Template.Ref = docTemplateUsage.Definition.Uuid; mvdConceptLeaf.Override = docTemplateUsage.Override; // requirements foreach (DocExchangeItem docExchangeRef in docTemplateUsage.Exchanges) { if (docExchangeRef.Exchange != null) { ConceptRequirement mvdRequirement = new ConceptRequirement(); if(mvdConceptLeaf.Requirements == null) { mvdConceptLeaf.Requirements = new List<ConceptRequirement>(); } mvdConceptLeaf.Requirements.Add(mvdRequirement); switch (docExchangeRef.Applicability) { case DocExchangeApplicabilityEnum.Export: mvdRequirement.Applicability = ApplicabilityEnum.Export; break; case DocExchangeApplicabilityEnum.Import: mvdRequirement.Applicability = ApplicabilityEnum.Import; break; } switch (docExchangeRef.Requirement) { case DocExchangeRequirementEnum.Excluded: mvdRequirement.Requirement = RequirementEnum.Excluded; break; case DocExchangeRequirementEnum.Mandatory: mvdRequirement.Requirement = RequirementEnum.Mandatory; break; case DocExchangeRequirementEnum.NotRelevant: mvdRequirement.Requirement = RequirementEnum.NotRelevant; break; case DocExchangeRequirementEnum.Optional: mvdRequirement.Requirement = RequirementEnum.Recommended; break; default: mvdRequirement.Requirement = RequirementEnum.NotRelevant; break; } mvdRequirement.ExchangeRequirement = docExchangeRef.Exchange.Uuid; } } // rules if (docTemplateUsage.Items.Count > 0) { mvdConceptLeaf.TemplateRules = new TemplateRules(); mvdConceptLeaf.TemplateRules.Operator = (TemplateOperator)Enum.Parse(typeof(TemplateOperator), docTemplateUsage.Operator.ToString()); foreach (DocTemplateItem docRule in docTemplateUsage.Items) { TemplateRule mvdTemplateRule = ExportMvdItem(docRule); mvdConceptLeaf.TemplateRules.TemplateRule.Add(mvdTemplateRule); // using proposed mvdXML schema if (false) // was removed from mvdXML final schema, so no longer possible to capture inner templates such as valid property names and values /// docRule.Concepts.Count > 0) { mvdConceptLeaf.SubConcepts = new List<Concept>(); mvdTemplateRule.References = new List<Concept>(); foreach (DocTemplateUsage docInner in docRule.Concepts) { Concept mvdInner = new Concept(); mvdTemplateRule.References.Add(mvdInner); ExportMvdConcept(mvdInner, docInner, documentation); } } } } }
private static void ImportMvdConcept(Concept mvdNode, DocTemplateUsage docUse, DocProject docProject, Dictionary<Guid, ExchangeRequirement> mapExchange) { // special case for attributes DocTemplateDefinition docTemplateDef = docProject.GetTemplate(mvdNode.Template.Ref); if (docTemplateDef != null) { ImportMvdObject(mvdNode, docUse); docUse.Definition = docTemplateDef; docUse.Override = mvdNode.Override; // exchange requirements foreach (ConceptRequirement mvdReq in mvdNode.Requirements) { ExchangeRequirement mvdExchange = null; if (mapExchange.TryGetValue(mvdReq.ExchangeRequirement, out mvdExchange)) { DocExchangeItem docReq = new DocExchangeItem(); docUse.Exchanges.Add(docReq); foreach (DocModelView docModel in docProject.ModelViews) { foreach (DocExchangeDefinition docAnno in docModel.Exchanges) { if (docAnno.Uuid.Equals(mvdReq.ExchangeRequirement)) { docReq.Exchange = docAnno; break; } } } docReq.Applicability = (DocExchangeApplicabilityEnum)mvdReq.Applicability; switch(mvdReq.Requirement) { case RequirementEnum.Mandatory: docReq.Requirement = DocExchangeRequirementEnum.Mandatory; break; case RequirementEnum.Recommended: docReq.Requirement = DocExchangeRequirementEnum.Optional; break; case RequirementEnum.NotRelevant: docReq.Requirement = DocExchangeRequirementEnum.NotRelevant; break; case RequirementEnum.NotRecommended: docReq.Requirement = DocExchangeRequirementEnum.NotRecommended; break; case RequirementEnum.Excluded: docReq.Requirement = DocExchangeRequirementEnum.Excluded; break; } } } // rules as template items if (mvdNode.TemplateRules != null) { docUse.Operator = (DocTemplateOperator)Enum.Parse(typeof(DocTemplateOperator), mvdNode.TemplateRules.Operator.ToString()); foreach (TemplateRule rule in mvdNode.TemplateRules.TemplateRule) { DocTemplateItem docItem = ImportMvdItem(rule, docProject, mapExchange); docUse.Items.Add(docItem); } if (mvdNode.TemplateRules.InnerRules != null) { mvdNode.ToString(); } } } }
// each list is optional- if specified then must be followed; if null, then no filter applies (all included) internal static void ExportMvd( mvdXML mvd, DocProject docProject, Dictionary<DocObject, bool> included) { mvd.Name = String.Empty; foreach (DocTemplateDefinition docTemplateDef in docProject.Templates) { if (included == null || included.ContainsKey(docTemplateDef)) { ConceptTemplate mvdConceptTemplate = new ConceptTemplate(); mvd.Templates.Add(mvdConceptTemplate); ExportMvdTemplate(mvdConceptTemplate, docTemplateDef, included); } } foreach (DocModelView docModelView in docProject.ModelViews) { if (included == null || included.ContainsKey(docModelView)) { ModelView mvdModelView = new ModelView(); mvd.Views.Add(mvdModelView); ExportMvdObject(mvdModelView, docModelView); mvdModelView.ApplicableSchema = "IFC4"; mvdModelView.BaseView = docModelView.BaseView; foreach (DocExchangeDefinition docExchangeDef in docModelView.Exchanges) { ExchangeRequirement mvdExchangeDef = new ExchangeRequirement(); mvdModelView.ExchangeRequirements.Add(mvdExchangeDef); ExportMvdObject(mvdExchangeDef, docExchangeDef); switch (docExchangeDef.Applicability) { case DocExchangeApplicabilityEnum.Export: mvdExchangeDef.Applicability = ApplicabilityEnum.Export; break; case DocExchangeApplicabilityEnum.Import: mvdExchangeDef.Applicability = ApplicabilityEnum.Import; break; } } // export template usages for model view foreach (DocConceptRoot docRoot in docModelView.ConceptRoots) { if (docRoot.ApplicableEntity != null) { // check if entity contains any concept roots ConceptRoot mvdConceptRoot = new ConceptRoot(); mvdModelView.Roots.Add(mvdConceptRoot); ExportMvdObject(mvdConceptRoot, docRoot); mvdConceptRoot.ApplicableRootEntity = docRoot.ApplicableEntity.Name; if (docRoot.ApplicableTemplate != null) { mvdConceptRoot.Applicability = new ApplicabilityRules(); mvdConceptRoot.Applicability.Template = new TemplateRef(); mvdConceptRoot.Applicability.Template.Ref = docRoot.ApplicableTemplate.Uuid; mvdConceptRoot.Applicability.TemplateRules = new TemplateRules(); mvdConceptRoot.Applicability.TemplateRules.Operator = (TemplateOperator)Enum.Parse(typeof(TemplateOperator), docRoot.ApplicableOperator.ToString()); foreach (DocTemplateItem docItem in docRoot.ApplicableItems) { TemplateRule rule = ExportMvdItem(docItem); mvdConceptRoot.Applicability.TemplateRules.TemplateRule.Add(rule); } } foreach (DocTemplateUsage docTemplateUsage in docRoot.Concepts) { Concept mvdConceptLeaf = new Concept(); mvdConceptRoot.Concepts.Add(mvdConceptLeaf); ExportMvdConcept(mvdConceptLeaf, docTemplateUsage); } } } } } }
private static void ExportMvdConcept(Concept mvdConceptLeaf, DocTemplateUsage docTemplateUsage) { if (docTemplateUsage.Definition == null) return; ExportMvdObject(mvdConceptLeaf, docTemplateUsage); mvdConceptLeaf.Template = new TemplateRef(); mvdConceptLeaf.Template.Ref = docTemplateUsage.Definition.Uuid; mvdConceptLeaf.Override = docTemplateUsage.Override; // requirements foreach (DocExchangeItem docExchangeRef in docTemplateUsage.Exchanges) { if (docExchangeRef.Exchange != null) { ConceptRequirement mvdRequirement = new ConceptRequirement(); mvdConceptLeaf.Requirements.Add(mvdRequirement); switch (docExchangeRef.Applicability) { case DocExchangeApplicabilityEnum.Export: mvdRequirement.Applicability = ApplicabilityEnum.Export; break; case DocExchangeApplicabilityEnum.Import: mvdRequirement.Applicability = ApplicabilityEnum.Import; break; } switch (docExchangeRef.Requirement) { case DocExchangeRequirementEnum.Excluded: mvdRequirement.Requirement = RequirementEnum.Excluded; break; case DocExchangeRequirementEnum.Mandatory: mvdRequirement.Requirement = RequirementEnum.Mandatory; break; case DocExchangeRequirementEnum.NotRelevant: mvdRequirement.Requirement = RequirementEnum.NotRelevant; break; case DocExchangeRequirementEnum.Optional: mvdRequirement.Requirement = RequirementEnum.Optional; break; default: mvdRequirement.Requirement = RequirementEnum.Optional; break; } mvdRequirement.ExchangeRequirement = docExchangeRef.Exchange.Uuid; } } // rules mvdConceptLeaf.TemplateRules = new TemplateRules(); mvdConceptLeaf.TemplateRules.Operator = (TemplateOperator)Enum.Parse(typeof(TemplateOperator), docTemplateUsage.Operator.ToString()); foreach (DocTemplateItem docRule in docTemplateUsage.Items) { TemplateRule mvdTemplateRule = ExportMvdItem(docRule); mvdConceptLeaf.TemplateRules.TemplateRule.Add(mvdTemplateRule); // using proposed mvdXML schema if (docRule.Concepts.Count > 0) { mvdConceptLeaf.SubConcepts = new List<Concept>(); mvdTemplateRule.References = new List<Concept>(); foreach (DocTemplateUsage docInner in docRule.Concepts) { Concept mvdInner = new Concept(); mvdTemplateRule.References.Add(mvdInner); ExportMvdConcept(mvdInner, docInner); } } } }
private static void ImportMvdConcept(Concept mvdNode, DocTemplateUsage docUse, DocProject docProject, Dictionary<Guid, ExchangeRequirement> mapExchange) { // special case for attributes DocTemplateDefinition docTemplateDef = docProject.GetTemplate(mvdNode.Template.Ref); if (docTemplateDef != null) { // lookup use definition docUse.Uuid = mvdNode.Uuid; docUse.Name = mvdNode.Name; docUse.Definition = docTemplateDef; docUse.Override = mvdNode.Override; // content if (mvdNode.Definitions != null) { foreach (Definition mvdDef in mvdNode.Definitions) { if (mvdDef.Body != null) { docUse.Documentation = mvdDef.Body.Content; } } } // exchange requirements foreach (ConceptRequirement mvdReq in mvdNode.Requirements) { ExchangeRequirement mvdExchange = null; if (mapExchange.TryGetValue(mvdReq.ExchangeRequirement, out mvdExchange)) { DocExchangeItem docReq = new DocExchangeItem(); docUse.Exchanges.Add(docReq); foreach (DocModelView docModel in docProject.ModelViews) { foreach (DocExchangeDefinition docAnno in docModel.Exchanges) { if (docAnno.Uuid.Equals(mvdReq.ExchangeRequirement)) { docReq.Exchange = docAnno; break; } } } docReq.Applicability = (DocExchangeApplicabilityEnum)mvdReq.Applicability; docReq.Requirement = (DocExchangeRequirementEnum)mvdReq.Requirement; } } // rules as template items if (mvdNode.TemplateRules != null) { docUse.Operator = (DocTemplateOperator)Enum.Parse(typeof(DocTemplateOperator), mvdNode.TemplateRules.Operator.ToString()); foreach (TemplateRule rule in mvdNode.TemplateRules.TemplateRule) { DocTemplateItem docItem = ImportMvdItem(rule, docProject, mapExchange); docUse.Items.Add(docItem); } if (mvdNode.TemplateRules.InnerRules != null) { mvdNode.ToString(); } } } }