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 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); } } } }