public getElementByGUID ( string GUIDstring ) : TSF.UmlToolingFramework.UML.Classes.Kernel.Element | ||
GUIDstring | string | |
return | TSF.UmlToolingFramework.UML.Classes.Kernel.Element |
/// <summary> /// creates a subset of the source model with only the properties and associations used in this schema /// </summary> /// <param name="destinationPackage">the package to create the subset in</param> /// <param name="copyDatatype"></param> public void createSubsetModel(UML.Classes.Kernel.Package destinationPackage) { //loop the elements to create the subSetElements foreach (EASchemaElement schemaElement in this.elements) { //only create subset elements for classes, not for datatypes if (schemaElement.sourceElement is UML.Classes.Kernel.Class || schemaElement.sourceElement is UML.Classes.Kernel.Enumeration) { schemaElement.createSubsetElement(destinationPackage); //Logger.log("after EASchema::creating single subset element"); } else if (schemaElement.sourceElement is UML.Classes.Kernel.DataType && this.settings.copyDataTypes) { //if the datatypes are limited then only the ones in the list should be copied if (!this.settings.limitDataTypes || this.settings.dataTypesToCopy.Contains(schemaElement.sourceElement.name)) { schemaElement.createSubsetElement(destinationPackage); } } } //Logger.log("after EASchema::creating subsetelements"); // then loop them again to create the associations foreach (EASchemaElement schemaElement in this.elements) { //only create subset elements for classes and enumerations and datatypes if (schemaElement.sourceElement is UML.Classes.Kernel.Class || schemaElement.sourceElement is UML.Classes.Kernel.Enumeration || schemaElement.sourceElement is UML.Classes.Kernel.DataType) { schemaElement.createSubsetAssociations(); //Logger.log("after EASchema::creating single subset association"); // and to resolve the attributes types to subset types if required schemaElement.createSubsetAttributes(); //Logger.log("after EASchema::createSubsetAttributes "); schemaElement.createSubsetLiterals(); //and add a dependency from the schemaElement to the type of the attributes schemaElement.addAttributeTypeDependencies(); //Logger.log("after EASchema::addAttributeTypeDependencies"); } } //then loop them the last time to remove those subset elements that don't have any attributes or associations foreach (EASchemaElement schemaElement in this.elements) { if (schemaElement.subsetElement != null) { //reload the element because otherwise the API does not return any attributes or associations var reloadedElement = model.getElementByGUID(schemaElement.subsetElement.uniqueID) as Classifier; if (reloadedElement != null && reloadedElement.attributes.Count == 0 && reloadedElement.getRelationships <UML.Classes.Kernel.Association>().Count == 0 && reloadedElement.getDependentTypedElements <UML.Classes.Kernel.TypedElement>().Count == 0) { schemaElement.subsetElement.delete(); } } } }
public override void EA_OnNotifyContextItemModified(Repository Repository, string GUID, ObjectType ot) { this.model = new UTF_EA.Model(Repository); base.EA_OnNotifyContextItemModified(Repository, GUID, ot); UML.UMLItem umlItem = model.getElementByGUID(GUID); if (umlItem != null) { if (IsTrackedUmlItem(umlItem)) { SynchronizeUmlItem(umlItem); } } Repository.RefreshOpenDiagrams(true); }
public override bool EA_OnPostNewElement(Repository Repository, EventProperties Info) { this.model = new UTF_EA.Model(Repository); bool changedElement = base.EA_OnPostNewElement(Repository, Info); EA_Utils.EventPropertiesHelper evProp = new EA_Utils.EventPropertiesHelper(Repository, Info); EA.Element element; if (evProp.GetElement(out element)) { UML.UMLItem umlItem = model.getElementByGUID(element.ElementGUID); if (umlItem != null) { if (IsTrackedUmlItem(umlItem)) { SynchronizeUmlItem(umlItem); changedElement = true; } } } Repository.RefreshOpenDiagrams(true); return(changedElement); }
/// <summary> /// creates a subset of the source model with only the properties and associations used in this schema /// </summary> /// <param name="destinationPackage">the package to create the subset in</param> /// <param name="copyDatatype"></param> public void createSubsetModel(UML.Classes.Kernel.Package destinationPackage, HashSet <SBF.SchemaElement> elements) { //loop the elements to create the subSetElements foreach (EASchemaElement schemaElement in elements) { //tell the user what we are doing EAOutputLogger.log(this.model, this.settings.outputName, "Creating subset element for : '" + schemaElement.name + "'" , 0, LogTypeEnum.log); //do not copy elements that are shared if (!schemaElement.isShared) { //only create subset elements for classes, not for datatypes if (schemaElement.sourceElement is UML.Classes.Kernel.Class || schemaElement.sourceElement is UML.Classes.Kernel.Enumeration) { schemaElement.createSubsetElement(destinationPackage); //Logger.log("after EASchema::creating single subset element"); } else if (schemaElement.sourceElement is UML.Classes.Kernel.DataType && this.settings.copyDataTypes) { //if the datatypes are limited then only the ones in the list should be copied if (!this.settings.limitDataTypes || this.settings.dataTypesToCopy.Contains(schemaElement.sourceElement.name)) { schemaElement.createSubsetElement(destinationPackage); } } } } //Logger.log("after EASchema::creating subsetelements"); // then loop them again to create the associations foreach (EASchemaElement schemaElement in elements) { if (!schemaElement.isShared) { //only create subset elements for classes and enumerations and datatypes if (schemaElement.sourceElement is UML.Classes.Kernel.Class || schemaElement.sourceElement is UML.Classes.Kernel.Enumeration || schemaElement.sourceElement is UML.Classes.Kernel.DataType) { //tell the user what we are doing EAOutputLogger.log(this.model, this.settings.outputName, "Creating subset associations for: '" + schemaElement.name + "'" , 0, LogTypeEnum.log); schemaElement.createSubsetAssociations(); //Logger.log("after EASchema::creating single subset association"); //tell the user what we are doing EAOutputLogger.log(this.model, this.settings.outputName, "Creating subset attributes for: '" + schemaElement.name + "'" , 0, LogTypeEnum.log); // and to resolve the attributes types to subset types if required schemaElement.createSubsetAttributes(); //tell the user what we are doing EAOutputLogger.log(this.model, this.settings.outputName, "Creating subset literals for: '" + schemaElement.name + "'" , 0, LogTypeEnum.log); //Logger.log("after EASchema::createSubsetAttributes "); schemaElement.createSubsetLiterals(); //clean up attribute type dependencies we don't need anymore schemaElement.cleanupAttributeDependencies(); if (!this.settings.dontCreateAttributeDependencies) { //tell the user what we are doing EAOutputLogger.log(this.model, this.settings.outputName, "Creating attribute depencendies for: '" + schemaElement.name + "'" , 0, LogTypeEnum.log); //and add a dependency from the schemaElement to the type of the attributes schemaElement.addAttributeTypeDependencies(); } //order the attributes if (!this.settings.keepOriginalAttributeOrder && !this.settings.setAttributeOrderZero && !(this.settings.orderAssociationsAlphabetically && this.settings.orderAssociationsAmongstAttributes)) { schemaElement.orderAttributes(); } //order the associations if (this.settings.orderAssociationsAlphabetically) { //tell the user what we are doing EAOutputLogger.log(this.model, this.settings.outputName, "Ordering associations for: '" + schemaElement.name + "'" , 0, LogTypeEnum.log); //and add a dependency from the schemaElement to the type of the attributes schemaElement.orderAssociationsAlphabetically(); } //Logger.log("after EASchema::addAttributeTypeDependencies"); //tell the user what we are doing EAOutputLogger.log(this.model, this.settings.outputName, "Creating generalizations for: '" + schemaElement.name + "'" , 0, LogTypeEnum.log); //add generalizations if both elements are in the subset schemaElement.addGeneralizations(); } } } //then loop them againe to remove those subset elements that don't have any attributes or associations // or generalizations, or are used as type if (this.settings.deleteUnusedSchemaElements) { foreach (EASchemaElement schemaElement in elements) { if (schemaElement.subsetElement != null) { //remove those subset elements that don't have any attributes or associations //reload the element because otherwise the API does not return any attributes or associations var reloadedElement = model.getElementByGUID(schemaElement.subsetElement.uniqueID) as Classifier; if (reloadedElement != null && !reloadedElement.attributes.Any() && !reloadedElement.getRelationships <UML.Classes.Kernel.Association>().Any() && !reloadedElement.getRelationships <UML.Classes.Kernel.Generalization>().Any() && !reloadedElement.getDependentTypedElements <UML.Classes.Kernel.TypedElement>().Any() && (reloadedElement is TSF_EA.ElementWrapper && !((TSF_EA.ElementWrapper)reloadedElement).primitiveParentNames.Any())) { //tell the user what we are doing EAOutputLogger.log(this.model, this.settings.outputName, "Deleting subset element for: '" + schemaElement.name + "'" , 0, LogTypeEnum.log); schemaElement.subsetElement.delete(); } } } } //then synchronize the tagged values where needed synchronizeTaggedValues(); //save the new schema contents to the destination package this.saveSchemaContent(destinationPackage); }
public override bool EA_OnPostNewElement(Repository Repository, EventProperties Info) { this.model = new UTF_EA.Model(Repository); bool changedElement = base.EA_OnPostNewElement(Repository, Info); EA_Utils.EventPropertiesHelper evProp = new EA_Utils.EventPropertiesHelper(Repository,Info); EA.Element element; if(evProp.GetElement(out element)) { UML.UMLItem umlItem = model.getElementByGUID(element.ElementGUID); if(umlItem != null) { if(IsTrackedUmlItem(umlItem)) { SynchronizeUmlItem(umlItem); changedElement = true; } } } Repository.RefreshOpenDiagrams(true); return changedElement; }
public override void EA_OnNotifyContextItemModified(Repository Repository, string GUID, ObjectType ot) { this.model = new UTF_EA.Model(Repository); base.EA_OnNotifyContextItemModified(Repository, GUID, ot); UML.UMLItem umlItem = model.getElementByGUID(GUID); if(umlItem != null) { if(IsTrackedUmlItem(umlItem)) { SynchronizeUmlItem(umlItem); } } Repository.RefreshOpenDiagrams(true); }