private static void ExportMvdRule(AttributeRule mvdRule, DocModelRule docRule) { if (!String.IsNullOrEmpty(docRule.Identification)) { mvdRule.RuleID = docRule.Identification; } mvdRule.Description = docRule.Description; mvdRule.AttributeName = docRule.Name; //mvdRule.Cardinality = ExportCardinalityType(docRule); foreach (DocModelRule docRuleEntity in docRule.Rules) { if (docRuleEntity is DocModelRuleEntity) { if(mvdRule.EntityRules == null) { mvdRule.EntityRules = new List<EntityRule>(); } EntityRule mvdRuleEntity = new EntityRule(); mvdRule.EntityRules.Add(mvdRuleEntity); mvdRuleEntity.RuleID = docRuleEntity.Identification; mvdRuleEntity.Description = docRuleEntity.Description; mvdRuleEntity.EntityName = docRuleEntity.Name; //mvdRuleEntity.Cardinality = ExportCardinalityType(docRuleEntity); foreach (DocModelRule docRuleAttribute in docRuleEntity.Rules) { if (docRuleAttribute is DocModelRuleAttribute) { if(mvdRuleEntity.AttributeRules == null) { mvdRuleEntity.AttributeRules = new List<AttributeRule>(); } AttributeRule mvdRuleAttribute = new AttributeRule(); mvdRuleEntity.AttributeRules.Add(mvdRuleAttribute); ExportMvdRule(mvdRuleAttribute, docRuleAttribute); } else if (docRuleAttribute is DocModelRuleConstraint && !String.IsNullOrEmpty(docRuleAttribute.Description)) { if(mvdRuleEntity.Constraints == null) { mvdRuleEntity.Constraints = new List<Constraint>(); } Constraint mvdConstraint = new Constraint(); mvdRuleEntity.Constraints.Add(mvdConstraint); mvdConstraint.Expression = docRuleAttribute.Description; } } DocModelRuleEntity dme = (DocModelRuleEntity)docRuleEntity; if(dme.References.Count > 0) { mvdRuleEntity.References = new List<TemplateRef>(); foreach (DocTemplateDefinition dtd in dme.References) { TemplateRef tr = new TemplateRef(); tr.Ref = dtd.Uuid; mvdRuleEntity.References.Add(tr); } } } else if (docRuleEntity is DocModelRuleConstraint) { if(mvdRule.Constraints == null) { mvdRule.Constraints = new List<Constraint>(); } Constraint mvdConstraint = new Constraint(); mvdRule.Constraints.Add(mvdConstraint); mvdConstraint.Expression = docRuleEntity.Description; } } }
internal static void ExportMvdTemplate(ConceptTemplate mvdTemplate, DocTemplateDefinition docTemplateDef, Dictionary<DocObject, bool> included, bool documentation) { ExportMvdObject(mvdTemplate, docTemplateDef, documentation); mvdTemplate.ApplicableEntity = docTemplateDef.Type; if (docTemplateDef.Rules != null && docTemplateDef.Rules.Count > 0) { mvdTemplate.Rules = new List<AttributeRule>(); foreach (DocModelRule docRule in docTemplateDef.Rules) { AttributeRule mvdAttr = new AttributeRule(); mvdTemplate.Rules.Add(mvdAttr); ExportMvdRule(mvdAttr, docRule); } } // recurse through sub-templates if (docTemplateDef.Templates != null && docTemplateDef.Templates.Count > 0) { foreach (DocTemplateDefinition docSub in docTemplateDef.Templates) { if (included == null || included.ContainsKey(docSub)) { if (mvdTemplate.SubTemplates == null) { mvdTemplate.SubTemplates = new List<ConceptTemplate>(); } ConceptTemplate mvdSub = new ConceptTemplate(); mvdTemplate.SubTemplates.Add(mvdSub); ExportMvdTemplate(mvdSub, docSub, included, documentation); } } } }
internal static DocModelRule ImportMvdRule(AttributeRule mvdRule, Dictionary<EntityRule, DocModelRuleEntity> fixups) { DocModelRuleAttribute docRule = new DocModelRuleAttribute(); docRule.Name = mvdRule.AttributeName; docRule.Description = mvdRule.Description; docRule.Identification = mvdRule.RuleID; //ImportMvdCardinality(docRule, mvdRule.Cardinality); if (mvdRule.EntityRules != null) { foreach (EntityRule mvdEntityRule in mvdRule.EntityRules) { DocModelRuleEntity docRuleEntity = new DocModelRuleEntity(); docRuleEntity.Name = mvdEntityRule.EntityName; docRuleEntity.Description = mvdEntityRule.Description; docRuleEntity.Identification = mvdEntityRule.RuleID; //ImportMvdCardinality(docRule, mvdRule.Cardinality); docRule.Rules.Add(docRuleEntity); if (mvdEntityRule.AttributeRules != null) { foreach (AttributeRule mvdAttributeRule in mvdEntityRule.AttributeRules) { DocModelRule docRuleAttribute = ImportMvdRule(mvdAttributeRule, fixups); docRuleEntity.Rules.Add(docRuleAttribute); } } if (mvdEntityRule.Constraints != null) { foreach (Constraint mvdConstraint in mvdEntityRule.Constraints) { DocModelRuleConstraint docRuleConstraint = new DocModelRuleConstraint(); docRuleConstraint.Description = mvdConstraint.Expression; docRuleEntity.Rules.Add(docRuleConstraint); } } if(mvdEntityRule.References != null) { // add it later, as referenced templates may not necessarily be loaded yet fixups.Add(mvdEntityRule, docRuleEntity); } } } if (mvdRule.Constraints != null) { foreach (Constraint mvdConstraint in mvdRule.Constraints) { DocModelRuleConstraint docRuleConstraint = new DocModelRuleConstraint(); docRuleConstraint.Description = mvdConstraint.Expression; docRule.Rules.Add(docRuleConstraint); } } return docRule; }