private static ConceptTemplate FindTemplate(ConceptTemplate conceptTemplate, string uuid) { Console.WriteLine(conceptTemplate); var conceptUUID = conceptTemplate.getUUID(); if (conceptUUID == uuid) { } else { foreach (var item in conceptTemplate.getTemplate()) { Console.WriteLine(item); foreach (var entry in item.getConceptTemplates()) { ConceptTemplate conceptTemplate1 = entry.Value; FindTemplate(conceptTemplate1, uuid); } } } return(conceptTemplate); }
private static Templates DisplayTemplates(XmlNode node, ConceptTemplate conceptTemplate, Templates templates, bool subTemplates, bool rules, AttributeRule attributeRule, EntityRule entityRule) { //Print the node type, node name and node value of the node if (node.Name == "ConceptTemplate") { conceptTemplate = new ConceptTemplate(); if (node.Attributes != null) { XmlAttributeCollection attrs = node.Attributes; foreach (XmlAttribute attr in attrs) { switch (attr.Name) { case "uuid": conceptTemplate.setUUID(attr.Value); break; case "name": conceptTemplate.name = attr.Value; break; case "code": conceptTemplate.code = attr.Value; break; case "status": break; case "applicableSchema": conceptTemplate.applicableSchema = attr.Value; break; case "applicableEntity": conceptTemplate.applicableEntity = attr.Value; break; } } } templates.addConceptTemplate(conceptTemplate.getUUID(), conceptTemplate); } else if (node.Name == "Definition") { foreach (XmlNode childNode in node.ChildNodes) { Definition definition = new Definition(); definition.setBody(childNode.InnerText); conceptTemplate.addDefinition(definition); } } else if (node.Name == "SubTemplates") { templates = new Templates(); conceptTemplate.addTemplates(templates); } else if (node.Name == "Rules") { rules = true; } else if (node.Name == "AttributeRule") { attributeRule = new AttributeRule(); if (node.Attributes != null) { XmlAttributeCollection attrs = node.Attributes; foreach (XmlAttribute attr in attrs) { if (attr.Name == "AttributeName") { attributeRule.attributeName = attr.Value; } else if (attr.Name == "Cardinality") { attributeRule.cardinality = attr.Value; } } } if (rules == true) { conceptTemplate.addAttributeRule(attributeRule); } else { entityRule.addAttributeRule(attributeRule); } } else if (node.Name == "EntityRule") { rules = false; entityRule = new EntityRule(); string attributeName = attributeRule.attributeName; if (!String.IsNullOrEmpty(attributeName)) { if (node.Attributes != null) { XmlAttributeCollection attrs = node.Attributes; foreach (XmlAttribute attr in attrs) { if (attr.Name == "EntityName") { entityRule.entityName = attr.Value; } else if (attr.Name == "Cardinality") { entityRule.cardinality = attr.Value; } } } attributeRule.addEntityRule(entityRule); } } else { Console.WriteLine("Type = [" + node.NodeType + "] Name = " + node.Name); } //Print attributes of the node if (node.Attributes != null) { XmlAttributeCollection attrs = node.Attributes; foreach (XmlAttribute attr in attrs) { Console.WriteLine("Attribute Name = " + attr.Name + "; Attribute Value = " + attr.Value); } } //Print individual children of the node, gets only direct children of the node XmlNodeList children = node.ChildNodes; foreach (XmlNode child in children) { DisplayTemplates(child, conceptTemplate, templates, subTemplates, rules, attributeRule, entityRule); } return(templates); }