public override void correct() { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting corrections for all the relations" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); //Abstractions //Associations this.correctAssociations(); //ControlFlows //this.correctControlFlows(); //Dependencies - Usage - Realisation this.correctElementRelations(); //Generalizations this.correctGeneralizations(); //Finished EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished corrections for the all the relations" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }
public override void correct() { /* Check how the Depencency matrix information can be transferred to EA. * Since this seems to be linking attributes with other attributes or associations we * will probably need to use tagged values to create the links and specific SQL Searches * to get the information out of EA as well. * (to be check with Thibault if the information is present or not)*/ EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting corrections for relationship matrixes'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); foreach (var mdDependency in magicDrawReader.allAttDependencies) { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Get dependency '{1}' --> '{2}'" , DateTime.Now.ToLongTimeString() , mdDependency.sourceName , mdDependency.targetName) , 0 , LogTypeEnum.log); //get the corresponding attributes in EA //source element var sourceElement = (TSF_EA.Class)getElementByMDid(mdDependency.sourceParentGuid); //target element var targetElement = (TSF_EA.Class)getElementByMDid(mdDependency.targetParentGuid); var sourceAttribute = (TSF_EA.Attribute)sourceElement.attributes.FirstOrDefault(x => x.name == mdDependency.sourceName); mdDependency.sourceGuid = sourceAttribute != null? sourceAttribute.guid: string.Empty; var targetAttribute = (TSF_EA.Attribute)targetElement.attributes.FirstOrDefault(x => x.name == mdDependency.targetName); mdDependency.targetGuid = targetAttribute != null? targetAttribute.guid: string.Empty; if (sourceAttribute != null && targetAttribute != null) { sourceAttribute.addTaggedValue("sourceAttribute", mdDependency.targetGuid); EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Set sourceAttribute '{1}' for '{2}'" , DateTime.Now.ToLongTimeString() , mdDependency.targetName , mdDependency.sourceName) , 0 , LogTypeEnum.log); } } EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished Corrections for Dependency Matrix'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }
public void matchSubsetLiterals() { if (this.subsetElement != null) { var subsetElementWrapper = subsetElement as UTF_EA.ElementWrapper; if (subsetElementWrapper != null) { foreach (UTF_EA.EnumerationLiteral literal in subsetElementWrapper.ownedLiterals) { //tell the user what we are doing EAOutputLogger.log(this.model, this.owner.settings.outputName, "Matching subset literal: '" + literal.name + "' to a schema property" , subsetElementWrapper.id, LogTypeEnum.log); EASchemaLiteral matchingLiteral = this.getMatchingSchemaLiteral(literal); if (matchingLiteral != null) { //found a match matchingLiteral.subSetLiteral = literal; } else { //only delete if stereotype not in list of ignored stereotypes if (literal.stereotypes.Count(x => this.owner.settings.ignoredStereotypes.Contains(x.name)) <= 0) { //no match, delete the literal literal.delete(); } } } } } }
public MappingSet getMappingSet(TSF_EA.Element sourceElement) { var sourceRoot = sourceElement as TSF_EA.ElementWrapper; //if an attribute was selected then we select the parent element as root if (sourceRoot == null) { sourceRoot = sourceElement?.owner as TSF_EA.ElementWrapper; } var mappingSet = getEmptyMappingSet(sourceRoot); //actually load the mappingset if (mappingSet != null) { //log progress this.clearOutput(); //log progress var startTime = DateTime.Now; EAOutputLogger.log($"Start loading mapping for {sourceRoot.name}", sourceRoot.id); //Load the mappings mappingSet.loadMappings(sourceRoot); //mappingSet.loadAllMappings(); //log progress var endTime = DateTime.Now; var processingTime = (endTime - startTime).TotalSeconds; EAOutputLogger.log($"Finished loading mapping for {sourceRoot.name} in {processingTime.ToString("N0")} seconds", sourceRoot.id); } //return return(mappingSet); }
void fixParticipation() { /*this method adds the stereotype <<participates>> to all the connectors between a 'Harmonized_Role' * actor and a 'BusinessRealizationUseCase, bRealizationUC' use case */ string sqlGetAssociations = @"select con.Connector_ID, con.[Stereotype] from ((t_connector con inner join t_object ac on (con.[Start_Object_ID] = ac.[Object_ID] and ac.[Stereotype]= 'Harmonized_Role' )) inner join t_object uc on (con.[End_Object_ID] = uc.[Object_ID] and uc.[Stereotype] in ('BusinessRealizationUseCase','bRealizationUC')))" ; var associations = this.model.getRelationsByQuery(sqlGetAssociations); foreach (var association in associations) { association.addStereotype(this.model.factory.createStereotype(association, "participates")); association.save(); //tell the user EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Corrected «participates» association'" , DateTime.Now.ToLongTimeString() ) , 0 , LogTypeEnum.log); } }
/// <summary> /// matches the association of the subset element with the schema associations. /// If an association cannot be matched, it is deleted. /// </summary> public void matchSubsetAssociations() { if (this.subsetElement != null) { foreach (UTF_EA.Association association in this.subsetElement.getRelationships <Association>()) { //tell the user what we are doing EAOutputLogger.log(this.model, this.owner.settings.outputName, "Matching relations of subset element: '" + subsetElement.name + "' to a schema element" , ((UTF_EA.ElementWrapper)subsetElement).id, LogTypeEnum.log); //we are only interested in the outgoing associations if (this.subsetElement.Equals(association.source)) { EASchemaAssociation matchingAssociation = this.getMatchingSchemaAssociation(association); if (matchingAssociation != null) { if (matchingAssociation.subsetAssociations == null) { matchingAssociation.subsetAssociations = new List <Association>(); } matchingAssociation.subsetAssociations.Add(association); } else { //only delete if the target does not have a stereotype in the list of ignored stereotypes or if this association does not have an ignored stereotype if (association.target.stereotypes.Count(x => this.owner.settings.ignoredStereotypes.Contains(x.name)) <= 0 && association.stereotypes.Count(x => this.owner.settings.ignoredStereotypes.Contains(x.name)) <= 0) { //no match, delete the association association.delete(); } } } } } }
public override void correct() { //Log start EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting fixing the CallBehavior action'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); string packageString = mdPackage.packageTreeIDString; this.model.executeSQL(@"delete from t_xref where [XrefID] in (select x.[XrefID] from (t_xref x inner join t_object o on o.[ea_guid] = x.[Client]) where x.name = 'CustomProperties' and o.[Classifier] = 0 and x.[Description] like '@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=CallBehavior@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;' and o.[Package_ID] in (" + packageString + "))"); //Log Finished EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished fixing the CallBehavior action'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }
public void addLineToEAOutput(string outputline, string parameter) { if (this.settings.logToSystemOutput) { EAOutputLogger.log(this.model, this.outputName, string.Format("{0} {1} {2}", DateTime.Now.ToLongTimeString(), outputline, parameter), 0, LogTypeEnum.log); } }
void matchSubsetElements(Package destinationPackage, HashSet <Classifier> subsetElements) { //loop subset elements ordered by name foreach (Classifier subsetElement in subsetElements.OrderBy(x => name)) { //tell the user what we are doing EAOutputLogger.log(this.model, this.settings.outputName, "Matching subset element: '" + subsetElement.name + "' to a schema element" , ((TSF_EA.ElementWrapper)subsetElement).id, LogTypeEnum.log); //get the corrsponding schema element EASchemaElement schemaElement = this.getSchemaElementForSubsetElement(subsetElement); //found a corresponding schema element if (schemaElement != null && shouldElementExistAsDatatype(subsetElement)) { schemaElement.matchSubsetElement(subsetElement); } else { //if it doesn't correspond with a schema element we delete it? //only if the subset element is located in the same folder as the message element //and it doesn't have one of stereotypes to be ignored if (destinationPackage.getNestedPackageTree(true).Any(x => x.Equals(subsetElement.owningPackage)) && !this.settings.ignoredStereotypes.Intersect(((TSF_EA.Element)subsetElement).stereotypeNames).Any()) { subsetElement.delete(); } } } }
/// <summary> /// Generate a new JSON Schema from the selected File /// </summary> private void generateJSONSchema() { //inform user EAOutputLogger.clearLog(this.model, outputName); var selectedPackage = this.model.selectedElement as TSF_EA.Package; if (selectedPackage != null) { //generate for package generateJSONSchemas(selectedPackage); } else { var selectedElement = this.model.selectedElement as TSF_EA.ElementWrapper; if (selectedElement != null) { this.generateJSONSchema(selectedElement); } } //inform user EAOutputLogger.log(this.model, outputName , $"{DateTime.Now.ToLongTimeString()} Finished generating Schema(s)" , 0 , LogTypeEnum.log); }
/// <summary> /// transform the selected package to the JSON profile /// </summary> private void transform() { //let the user select a class to be the root class MessageBox.Show("Please select the root element"); var rootObject = this.model.getUserSelectedElement(new List <string> { "Class" }) as UML.Classes.Kernel.Class; var selectedPackage = this.model.selectedElement as UML.Classes.Kernel.Package; if (selectedPackage != null) { //inform user EAOutputLogger.clearLog(this.model, outputName); EAOutputLogger.log(this.model, outputName , $"{DateTime.Now.ToLongTimeString()} Starting transform of package '{selectedPackage.name}'" , ((TSF_EA.ElementWrapper)selectedPackage).id , LogTypeEnum.log); //perform the actual transformation EAJSONSchema.transformPackage(selectedPackage, rootObject); //inform user EAOutputLogger.log(this.model, outputName , $"{DateTime.Now.ToLongTimeString()} Finished transform of package '{selectedPackage.name}'" , ((TSF_EA.ElementWrapper)selectedPackage).id , LogTypeEnum.log); } }
/// <summary> /// Creates a new message subset from the given schema in the given targetPackage /// </summary> /// <param name="schema">the Schema to generate a message subset from</param> /// <param name="targetPackage">the Package to create the new Message subset in</param> private void createNewMessageSubset(Schema schema, UML.Classes.Kernel.Package targetPackage) { //log progress EAOutputLogger.clearLog(this.EAModel, this.settings.outputName); EAOutputLogger.log(this.EAModel, this.settings.outputName , string.Format("{0} Starting creation of new subset for schema '{1}' in package '{2}'" , DateTime.Now.ToLongTimeString() , schema.name , targetPackage.name) , ((TSF_EA.ElementWrapper)targetPackage).id , LogTypeEnum.log); if (targetPackage != null) { //Logger.log("before ECDMMessageComposerAddin::schema.createSubsetModel"); //Todo create global setting bool copyDataType = this.settings.copyDataTypes; List <String> datatypesToCopy = null; if (copyDataType && this.settings.limitDataTypes) { datatypesToCopy = this.settings.dataTypesToCopy; } schema.createSubsetModel(targetPackage, schema.elements); this.createNewSubsetDiagram(schema, targetPackage); } //log progress EAOutputLogger.log(this.EAModel, this.settings.outputName , string.Format("{0} Finished creation of new subset for schema '{1}' in package '{2}'" , DateTime.Now.ToLongTimeString() , schema.name , targetPackage.name) , ((TSF_EA.ElementWrapper)targetPackage).id , LogTypeEnum.log); }
/// <summary> /// checks all attributes of the subset element and tries to match it with a SchemaProperty. /// It it can't be matches te subset attribute is deleted. /// </summary> public void matchSubsetAttributes() { if (this.subsetElement != null) { foreach (UTF_EA.Attribute attribute in this.subsetElement.attributes) { //tell the user what we are doing EAOutputLogger.log(this.model, this.owner.settings.outputName, "Matching subset attribute: '" + attribute.name + "' to a schema property" , ((UTF_EA.ElementWrapper)subsetElement).id, LogTypeEnum.log); EASchemaProperty matchingProperty = this.getMatchingSchemaProperty(attribute); if (matchingProperty != null) { //found a match matchingProperty.subSetProperty = attribute; } else { //only delete if stereotype not in list of ignored stereotypes if (attribute.stereotypes.Count(x => this.owner.settings.ignoredStereotypes.Contains(x.name)) <= 0) { //no match, delete the attribute attribute.delete(); } } } } }
void correctGeneralizations() { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting corrections for the generalizations" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); //First get all the generalizations foreach (var mdGeneralization in magicDrawReader.allDirectMDElementRelations) { string md_guid = mdGeneralization.Key; string source_id = mdGeneralization.Value.sourceMDGUID; string target_id = mdGeneralization.Value.targetMDGUID; string relationType = mdGeneralization.Value.relationType; string name = mdGeneralization.Value.name; string stereotype = string.Empty; //check if the relation already exists if (!exists(md_guid, source_id, target_id, relationType, stereotype)) { var sourceElement = this.getElementByMDid(source_id); var targetElement = this.getElementByMDid(target_id); if (sourceElement != null && targetElement != null) { //create the actual generalization var newGeneralization = this.model.factory.createNewElement(sourceElement, name, relationType) as TSF_EA.Generalization; //set target newGeneralization.target = targetElement; //set the target end navigable by default --> always true? newGeneralization.targetEnd.isNavigable = true; //save the new generalization newGeneralization.save(); //set the md_guid tagged value newGeneralization.addTaggedValue("md_guid", md_guid); //tell the user EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Created generalization between '{1}' and '{2}'" , DateTime.Now.ToLongTimeString() , sourceElement.name , targetElement.name) , sourceElement.id , LogTypeEnum.log); } } } EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished corrections for the generalizations" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }
internal void log(string msg) { if (this.model == null) { return; } EAOutputLogger.log(this.model, this.settings.outputName, msg); }
internal void logError(string msg) { if (this.model == null) { return; } EAOutputLogger.log(this.model, this.settings.outputName, msg, 0, LogTypeEnum.error); }
/// <summary> /// updates an existing message subset for a schema /// </summary> /// <param name="schema">the schema to use as basis</param> /// <param name="messageElement">the root element of the subset</param> private void updateMessageSubset(Schema schema, UML.Classes.Kernel.Package targetPackage) { //log progress var startTime = DateTime.Now; EAOutputLogger.clearLog(this.EAModel, this.settings.outputName); EAOutputLogger.log(this.EAModel, this.settings.outputName , $"{startTime.ToLongTimeString()} Starting update of existing subset for schema '{schema.name}' in package '{targetPackage.name}'" , ((TSF_EA.ElementWrapper)targetPackage).id , LogTypeEnum.log); bool copyDataType = this.settings.copyDataTypes; List <String> datatypesToCopy = null; if (copyDataType && this.settings.limitDataTypes) { datatypesToCopy = this.settings.dataTypesToCopy; } bool useMessage = false; if (!this.settings.usePackageSchemasOnly) { //check if we have a message element to folow var messageElement = targetPackage.ownedElements.OfType <UML.Classes.Kernel.Classifier>().FirstOrDefault(); if (messageElement != null) { useMessage = true; schema.updateSubsetModel(messageElement); } } if (this.settings.usePackageSchemasOnly || !useMessage) { schema.updateSubsetModel(targetPackage); } if (this.settings.generateDiagram) { var subsetDiagrams = targetPackage.ownedDiagrams; if (subsetDiagrams.Count > 0) { //if there are existing diagram then we update the existing diagrams this.updateExistingDiagrams(schema, subsetDiagrams); } else { //if not we create a new diagram this.createNewSubsetDiagram(schema, targetPackage); } } //log progress var endTime = DateTime.Now; var processingTime = (endTime - startTime).TotalSeconds; EAOutputLogger.log(this.EAModel, this.settings.outputName , $"{endTime.ToLongTimeString()} Finished update of existing subset for schema '{schema.name}' in package '{targetPackage.name}' in {processingTime.ToString("N0")} seconds" , ((TSF_EA.Package)targetPackage).id , LogTypeEnum.log); }
/// <summary> /// for some reason the activity partitions don't show propertly. /// These updates (only on SQL Server) fix those problems /// /// </summary> void fixActivityPartitions() { if (this.model.repositoryType == TSF_EA.RepositoryType.SQLSVR) { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Fix Activity Partitions'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); //update the bottoms string sqlFixActivityPartitionsBottom = @"update dor set dor.RectBottom = do.RectBottom from t_diagramObjects do inner join t_object o on do.Object_ID = o.Object_ID and o.Object_Type = 'ActivityPartition' inner join t_diagramobjects dor on do.Diagram_ID = dor.Diagram_ID and do.RectTop = dor.RectTop and do.RectRight = dor.RectRight and do.RectLeft < dor.RectLeft inner join t_object obr on obr.Object_ID = dor.Object_ID and obr.Object_Type = 'ActivityPartition' inner join t_diagram d on d.Diagram_ID = do.Diagram_ID where not exists (select * from t_diagramobjects do2 inner join t_object o2 on do2.Object_ID = o2.Object_ID and o2.Object_Type = 'ActivityPartition' where do2.Diagram_ID = d.Diagram_ID and do2.RectLeft > do.RectLeft and do2.RectLeft < dor.RectLeft and do2.Instance_ID not in (do.Instance_ID, dor.Instance_ID))" ; this.model.executeSQL(sqlFixActivityPartitionsBottom); //update the right edges string sqlFixActivityPartitionsRight = @"update do set do.RectRight = dor.RectLeft from t_diagramObjects do inner join t_object o on do.Object_ID = o.Object_ID and o.Object_Type = 'ActivityPartition' inner join t_diagramobjects dor on do.Diagram_ID = dor.Diagram_ID and do.RectTop = dor.RectTop and do.RectRight = dor.RectRight and do.RectLeft < dor.RectLeft inner join t_object obr on obr.Object_ID = dor.Object_ID and obr.Object_Type = 'ActivityPartition' inner join t_diagram d on d.Diagram_ID = do.Diagram_ID where not exists (select * from t_diagramobjects do2 inner join t_object o2 on do2.Object_ID = o2.Object_ID and o2.Object_Type = 'ActivityPartition' where do2.Diagram_ID = d.Diagram_ID and do2.RectLeft > do.RectLeft and do2.RectLeft < dor.RectLeft and do2.Instance_ID not in (do.Instance_ID, dor.Instance_ID))" ; this.model.executeSQL(sqlFixActivityPartitionsRight); } }
/// <summary> /// updates an existing message subset for a schema /// </summary> /// <param name="schema">the schema to use as basis</param> /// <param name="messageElement">the root element of the subset</param> private void updateMessageSubset(Schema schema, UML.Classes.Kernel.Package targetPackage) { //log progress EAOutputLogger.clearLog(this.EAModel, this.settings.outputName); EAOutputLogger.log(this.EAModel, this.settings.outputName , string.Format("{0} Starting update of existing subset for schema '{1}' in package '{2}'" , DateTime.Now.ToLongTimeString() , schema.name , targetPackage.name) , ((UTF_EA.ElementWrapper)targetPackage).id , LogTypeEnum.log); bool copyDataType = this.settings.copyDataTypes; List <String> datatypesToCopy = null; if (copyDataType && this.settings.limitDataTypes) { datatypesToCopy = this.settings.dataTypesToCopy; } bool useMessage = false; if (!settings.usePackageSchemasOnly) { //check if we have a message element to folow var messageElement = targetPackage.ownedElements.OfType <UML.Classes.Kernel.Classifier>().FirstOrDefault(); if (messageElement != null) { useMessage = true; schema.updateSubsetModel(messageElement); } } if (settings.usePackageSchemasOnly || !useMessage) { schema.updateSubsetModel(targetPackage); } var subsetDiagrams = targetPackage.ownedDiagrams; if (subsetDiagrams.Count > 0) { //if there are existing diagram then we update the existing diagrams updateExistingDiagrams(schema, subsetDiagrams); } else { //if not we create a new diagram createNewSubsetDiagram(schema, targetPackage); } //log progress EAOutputLogger.log(this.EAModel, this.settings.outputName , string.Format("{0} Finished update of existing subset for schema '{1}' in package '{2}'" , DateTime.Now.ToLongTimeString() , schema.name , targetPackage.name) , ((UTF_EA.Package)targetPackage).id , LogTypeEnum.log); }
public override void correct() { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting fix notes'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); // get al the diagrams foreach (var mdDiagramKeyValue in magicDrawReader.allDiagrams) { var mdDiagram = mdDiagramKeyValue.Value; var ownerID = magicDrawReader.getDiagramOnwerID(mdDiagramKeyValue.Key); var parentElement = getElementByMDid(ownerID); foreach (var mdDiagramNote in mdDiagram.diagramNotes) { if (parentElement != null) { //create a new note TSF_EA.NoteComment newNote = this.model.factory.createNewElement <TSF_EA.NoteComment>(parentElement, string.Empty); //add the comments to the note newNote.ownedComments.FirstOrDefault().body = model.convertToEANotes(mdDiagramNote.text, "HTML"); //save the note newNote.save(); //add the tagged value md_guid newNote.addTaggedValue("md_guid", mdDiagramNote.note_Id); //links var linkedElement = getElementByMDid(mdDiagramNote.linkedElement); if (linkedElement != null) { TSF_EA.ConnectorWrapper noteLink = newNote.addOwnedElement <TSF_EA.ConnectorWrapper>(string.Empty, "NoteLink"); noteLink.target = linkedElement; noteLink.save(); } EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Create new note '{1}'" , DateTime.Now.ToLongTimeString() , newNote.ownedComments.FirstOrDefault().body) , parentElement.id , LogTypeEnum.log); } } } //Log finished EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished fix notes" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }
void saveDatabaseButtonClicked(object sender, EventArgs e) { var selectedComparison = _dbCompareControl.selectedComparison; EAOutputLogger.log("Saving Database..."); _comparer.save(); this.refreshCompare(true); this.model.showTab(compareControlName); //this._dbCompareControl.selectedComparison = selectedComparison; }
public override void correct() { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting corrections for cross MDzip Attributes" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); //get all attributes that have a foreign type foreach (var crossAttribute in magicDrawReader.allAttributes.Where( x => x.isCrossMDZip && !string.IsNullOrEmpty(x.typeMDGuid))) { //get the type element from EA var typeElement = this.getElementByMDid(crossAttribute.typeMDGuid); //make sure the element is a Type var typeAsType = typeElement as UML.Classes.Kernel.Type; if (typeAsType != null) { //get the corresponding attribute in EA that doesn't have the correct type yet string sqlGetCorrespondingAttribute = @"select a.ea_guid from (( t_attribute a inner join t_object o on a.Object_ID = o.Object_ID) inner join t_objectproperties tv on (tv.Object_ID = o.Object_ID and tv.Property = 'md_guid')) where tv.Value = '" + crossAttribute.mdParentGuid + @"' and a.Name = '" + crossAttribute.name + @"' and (a.classifier is null or a.Classifier <> " + typeElement.id + ")"; var correspondingAttributes = this.model.getAttributesByQuery(sqlGetCorrespondingAttribute); //set the type of the attribute in EA foreach (var attribute in correspondingAttributes) { attribute.type = typeAsType; attribute.save(); //set the md_guid tagged value attribute.addTaggedValue("md_guid", crossAttribute.mdGuid); //tell the user EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Setting type '{1}' on attribute '{2}.{3}'" , DateTime.Now.ToLongTimeString() , typeAsType.name , attribute.owner.name , attribute.name) , ((TSF_EA.ElementWrapper)attribute.owner).id , LogTypeEnum.log); } } } EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished corrections for cross MDzip Attributes" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }
private void generateJSONSchema(TSF_EA.ElementWrapper element) { EAOutputLogger.log(this.model, outputName , $"{DateTime.Now.ToLongTimeString()} Generating Schema for element '{element.name}'" , element.id , LogTypeEnum.log); var eaJsonSchema = new EAJSONSchema(element); //print the schema to the file eaJsonSchema.print(); }
public override void correct() { //Log start EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting add classifiers to partitions'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); foreach (var mdPartition in magicDrawReader.allPartitions) { //key = partition, value = represents //partitionID: '_17_0_2_b9402f1_1366196749027_793557_54194' //representsID: '_17_0_2_3_38a017f_1374238063627_212930_92600' KeyValuePair <string, string> objectIdGuid = this.model.getObjectIdAndGuid(@"select o.[Object_ID], o.[ea_guid] from t_object o inner join [t_objectproperties] op on o.[Object_ID] = op.[Object_ID] where op.[Property] = 'md_guid' and op.[value] = '" + mdPartition.Value + "'"); this.model.executeSQL(@"update t_object set [Classifier] = '" + objectIdGuid.Key + @"', [Classifier_guid] = '" + objectIdGuid.Value + @"' where Object_ID in (select o.[Object_ID] from t_object o inner join [t_objectproperties] op on o.[Object_ID] = op.[Object_ID] where op.[Property] = 'md_guid' and op.[value] = '" + mdPartition.Key + "')"); //logging EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Add the classifier '{1}' - '{2}' for partition '{3}'" , DateTime.Now.ToLongTimeString() , objectIdGuid.Key , objectIdGuid.Value , mdPartition.Key) , 0 , LogTypeEnum.log); } EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished add classifiers to partitions'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }
public override void correct() { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting Corrections for OCL Constraints'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); //loop all classes that have MA as stereotype string getMessageAssembliesSQL = "select o.Object_ID from t_object o" + " where o.Stereotype = 'MA'" + " and o.Object_Type = 'Class'" + " and o.Package_ID in (" + mdPackage.getPackageTreeIDString() + ")"; var messageAssemblies = this.model.getElementWrappersByQuery(getMessageAssembliesSQL); foreach (var messageAssembly in messageAssemblies) { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Correcting OCL Constraints for '{1}' in package '{2}'" , DateTime.Now.ToLongTimeString() , messageAssembly.name , messageAssembly.owningPackage.name) , messageAssembly.id , LogTypeEnum.log); var mdIDTag = messageAssembly.taggedValues.FirstOrDefault(x => x.name == "md_guid"); if (mdIDTag != null) { string mdID = mdIDTag.tagValue.ToString(); //get the MDConstraints for this element var mdConstraints = magicDrawReader.getContraints(mdID); if (mdConstraints.Any()) { //first delete all existing constraints foreach (var existingContraint in messageAssembly.constraints) { existingContraint.delete(); } //add the new constraints foreach (var mdConstraint in mdConstraints) { var newConstraint = this.model.factory.createNewElement <TSF_EA.Constraint>(messageAssembly, mdConstraint.name); newConstraint.specification = new TSF_EA.OpaqueExpression(mdConstraint.body, mdConstraint.language); newConstraint.save(); } } } } EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished Corrections for OCL Constraints'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }
/// <summary> /// if the association is between two classes, and one of the end is an aggregation or composite then the other side should be navigable /// </summary> /// <param name="eaAssociation">the association to change</param> void fixNavigability(TSF_EA.Association eaAssociation) { var sourceEnd = eaAssociation.sourceEnd; var targetEnd = eaAssociation.targetEnd; bool navigabilityUpdated = false; if (sourceEnd.type is UML.Classes.Kernel.Class && targetEnd.type is UML.Classes.Kernel.Class) { if (sourceEnd.aggregation != AggregationKind.none) { if (!targetEnd.isNavigable) { targetEnd.isNavigable = true; navigabilityUpdated = true; } if (sourceEnd.isNavigable) { sourceEnd.isNavigable = false; navigabilityUpdated = true; } } if (targetEnd.aggregation != AggregationKind.none) { if (!sourceEnd.isNavigable) { sourceEnd.isNavigable = true; navigabilityUpdated = true; } if (targetEnd.isNavigable) { targetEnd.isNavigable = false; navigabilityUpdated = true; } } //save if needed if (navigabilityUpdated) { //save the association eaAssociation.save(); //let the user know EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Corrected navigability of association between '{1}' and '{2}'" , DateTime.Now.ToLongTimeString() , eaAssociation.source.name , eaAssociation.target.name) , ((TSF_EA.ElementWrapper)eaAssociation.source).id , LogTypeEnum.log); } } }
public override void correct() { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting create links between attributes and elements'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); //get al the classes with stereotype BusinessEntity var classes = this.model.getElementWrappersByQuery(@"select distinct o.[Object_ID] from t_object o left join t_xref x on (o.[ea_guid] = x.[Client]) where o.[Stereotype] like 'BusinessEntity' or o.[StereoType] like 'bEntity' or (x.[Name] = 'StereoTypes' and x.[Description] = 'BusinessEntity' or x.[Description] = 'bEntity')" ); //loop the attribues in the classes, filter the enums out foreach (var businessEntity in classes) { foreach (var attribute in businessEntity.attributes.Where(x => x.classifier is UML.Classes.Kernel.Enumeration)) { if (!attribute.relationships.Any()) { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Create <<usage>> link from '{1}.{2}' to '{3}'" , DateTime.Now.ToLongTimeString() , businessEntity.name , attribute.name , attribute.classifier) , businessEntity.id , LogTypeEnum.log); // create a 'usage' link from the enum attributes to the enum entities TSF_EA.Usage usage = this.model.factory.createNewElement <TSF_EA.Usage>(attribute.owner, string.Empty); usage.source = attribute; usage.target = (TSF_EA.Element)attribute.classifier; usage.targetEnd.isNavigable = true; usage.save(); } } } EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished create links between attributes and elements'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }
/// <summary> /// the CSVString has mapping logic in the form of /// --context1 name-- /// --other context name-- /// mapping logic /// --context2-- /// mapping logic 2 /// /// Or just plain mapping logic. In that case the mapping is valid for all contexts /// </summary> /// <param name="mappingLogic">the string containing the mapping logic</param> /// <param name="contexts">the possible contexts for the mapping set</param> /// <param name="model">the model</param> /// <returns>a list of new mapping logics based on the given string</returns> private static IEnumerable <MP.MappingLogic> createMappingLogicsFromCSVString(string mappingLogic, List <ElementWrapper> contexts, Model model) { var mappingLogics = new List <MappingLogic>(); //read the lines using (var reader = new StringReader(mappingLogic)) { string line; var currentContexts = new List <ElementWrapper>(); string logic = string.Empty; while ((line = reader.ReadLine()) != null) { if (line.StartsWith("--") && line.EndsWith("--") && line.Length > 4) { //we have a new context //add the logics for the previous contexts if (!string.IsNullOrEmpty(logic) && currentContexts.Any()) { addMappingLogics(mappingLogics, currentContexts, logic); //clear the current contexts currentContexts.Clear(); //clear the logic logic = string.Empty; } //get the name of the context var contexTextName = line.Substring(2, line.Length - 4); //get the context from the list var newContext = contexts.FirstOrDefault(x => x.name.Equals(contexTextName, StringComparison.InvariantCultureIgnoreCase)); if (newContext == null && contexTextName.Equals("Default", StringComparison.CurrentCultureIgnoreCase)) { EAOutputLogger.log($"Could not find context with name '{contexTextName}'", 0, LogTypeEnum.warning); } //add to the current contexts currentContexts.Add(newContext); } else { if (!string.IsNullOrEmpty(logic)) { logic += Environment.NewLine; } //add the logic logic += line; } } //make sure to add the logic addMappingLogics(mappingLogics, currentContexts, logic); } return(mappingLogics); }
void correctUseCases() { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting corrections for the usecases" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished corrections for the usecases" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }
public override void correct() { //tell the user we are starting EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting to correct Attribute Sequence" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); //loop all attributes foreach (var mdAttribute in magicDrawReader.allAttributes) { //get the corresponding attribute in EA that doesn't have the correct type yet string sqlGetCorrespondingAttribute = @"select a.ea_guid from (( t_attribute a inner join t_object o on a.Object_ID = o.Object_ID) inner join t_objectproperties tv on (tv.Object_ID = o.Object_ID and tv.Property = 'md_guid')) where tv.Value = '" + mdAttribute.mdParentGuid + @"' and a.Name = '" + mdAttribute.name + "'"; var correspondingAttributes = this.model.getAttributesByQuery(sqlGetCorrespondingAttribute); //set the type of the attribute in EA foreach (var attribute in correspondingAttributes) { //only for BBIE attributes if (attribute.stereotypeNames.Contains("BBIE")) { //tell the user we are starting EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Setting {1} as sequence for attribute {2}" , DateTime.Now.ToLongTimeString() , mdAttribute.sequencingKey , attribute.owner.name + "." + attribute.name) , 0 , LogTypeEnum.log); attribute.addTaggedValue("sequencingKey", mdAttribute.sequencingKey.ToString()); //set the md_guid tagged value attribute.addTaggedValue("md_guid", mdAttribute.mdGuid); } } } //tell the user we are finished EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting to correct Attribute Sequence" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }