private static void sync_constraint(EA.Repository Repository, EA.Diagram diagram, EA.Element sample, EA.Element classifier, JArray ja, EA.Package pkg, DiagramCache diagramCache) { //logger.log("Syncing Constraints from JArray:" + sample.Name); Dictionary <string, RunState> rs = ObjectManager.parseRunState(sample.RunState); Dictionary <string, RunState> nrs = new Dictionary <string, RunState>(); foreach (JObject jo in ja.Children <JObject>()) { //logger.log("Syncing Constraint:"); EA.Element constraint = reifyElement(Repository, diagramCache, jo, pkg); ObjectManager.sync_element_taggedvalue(Repository, constraint, null, jo, pkg, diagramCache); JArray sources = (JArray)jo.GetValue(RoundTripAddInClass.CONSTRAINT_PROPERTY_SOURCE); foreach (JObject relatedJo in sources) { EA.Element related = reifyElement(Repository, diagramCache, relatedJo, pkg); JToken connectorProperty = null; String connectorId = null; if (relatedJo.TryGetValue(RoundTripAddInClass.CONSTRAINT_PROPERTY_CONNECTOR_GUID, out connectorProperty)) { connectorId = connectorProperty.ToString(); } sync_relationship(Repository, diagram, connectorId, related, constraint, relatedJo, pkg); } JArray targets = (JArray)jo.GetValue(RoundTripAddInClass.CONSTRAINT_PROPERTY_TARGET); foreach (JObject relatedJo in targets) { EA.Element related = reifyElement(Repository, diagramCache, relatedJo, pkg); JToken connectorProperty = null; String connectorId = null; if (relatedJo.TryGetValue(RoundTripAddInClass.CONSTRAINT_PROPERTY_CONNECTOR_GUID, out connectorProperty)) { connectorId = connectorProperty.ToString(); } sync_relationship(Repository, diagram, connectorId, constraint, related, relatedJo, pkg); } } }
private static void sync_population(EA.Repository Repository, EA.Element sample, EA.Element classifier, JArray ja, EA.Package pkg, DiagramCache diagramCache) { logger.log("Syncing JArray:" + sample.Name); Dictionary <string, RunState> rs = ObjectManager.parseRunState(sample.RunState); Dictionary <string, RunState> nrs = new Dictionary <string, RunState>(); foreach (JObject jo in ja.Children <JObject>()) { logger.log("Syncing Child:"); JToken guidToken = null; if (jo.TryGetValue(RoundTripAddInClass.POPULATION_PROPERTY_GUID, out guidToken)) { String guid = guidToken.ToString(); EA.Element el = diagramCache.elementGuidHash[guid]; if (el == null) { el = Repository.GetElementByGuid(guid); } if (el != null) { //logger.log("Found element for guid" + guid); ObjectManager.sync_element_taggedvalue(Repository, el, classifier, jo, pkg, diagramCache); } else { logger.log("No element for guid" + guid); } } else { logger.log("No guid, adding element" + jo.ToString()); EA.Element el = pkg.Elements.AddNew("", "Object"); logger.log("No guid, adding element" + jo.ToString()); ObjectManager.sync_element_taggedvalue(Repository, el, classifier, jo, pkg, diagramCache); } } }