public void addLinkedElement(ElementWrapper element) { if (element is NoteComment || element is UML.Classes.Kernel.Constraint) { //set idref to the id of this relation to create the notelink string pdata4 = element.wrappedElement.MiscData[3].ToString(); string idRefString = getNextIdRefString(pdata4); pdata4 = KeyValuePairsHelper.setValueForKey(idRefString, this.id.ToString(), pdata4); string sqlUpdateNoteLink = "update t_object set PDATA4 = '" + pdata4 + "' where ea_guid =" + element.uniqueID; this.model.executeSQL(sqlUpdateNoteLink); } else { //create an element of type ProxyConnector with //t_object.ClassifierGUID = sourceConnectorGUID //t_object.Classifier = sourcConnector.ConnectorID var proxyConnector = this.model.factory.createNewElement <ProxyConnector>(this.owningPackage, string.Empty); proxyConnector.connector = this; proxyConnector.save(); //then create a connector between the ProxyConnector Element and the target element var elementLink = this.model.factory.createNewElement <Dependency>(proxyConnector, string.Empty); elementLink.target = element; elementLink.save(); } }
private void setLinkedFeature(UML.Classes.Kernel.Element linkedFeature, bool isSource) { //check if attribute Element actualEnd = linkedFeature as Attribute; //or maybe operation if (actualEnd == null) { actualEnd = linkedFeature as Operation; } if (actualEnd != null) { //set the client id to the id of the owner if (isSource) { _source = linkedFeature; this.wrappedConnector.ClientID = ((ElementWrapper)actualEnd.owner).id; } else { _target = linkedFeature; this.wrappedConnector.SupplierID = ((ElementWrapper)actualEnd.owner).id; } //set the linked feature string key = isSource ? "LFSP" : "LFEP"; string suffix = isSource ? "R":"L"; string styleEx = KeyValuePairsHelper.setValueForKey(key, linkedFeature.uniqueID + suffix, this.wrappedConnector.StyleEx); this.wrappedConnector.StyleEx = styleEx; } }
public static List <Mapping> createNewMappings(TSF.UmlToolingFramework.Wrappers.EA.Attribute attribute, string basepath, ElementWrapper targetRootElement) { List <Mapping> returnedMappings = new List <Mapping>(); //connectors from owned attributes foreach (ConnectorWrapper mappedConnector in attribute.relationships.OfType <ConnectorWrapper>()) { if (!mappedConnector.taggedValues.Any(x => x.name == mappingSourcePathName && x.tagValue.ToString() != basepath)) { //get the target base path ConnectorMapping connectorMapping; var targetTV = mappedConnector.taggedValues.FirstOrDefault(x => x.name == mappingTargetPathName); string targetBasePath = string.Empty; if (targetTV != null) { targetBasePath = targetTV.tagValue.ToString(); } if (!string.IsNullOrEmpty(targetBasePath)) { //connectorMapping = new ConnectorMapping(mappedConnector,basepath,targetBasePath); } else { //connectorMapping = new ConnectorMapping(mappedConnector,basepath,targetRootElement); } //returnedMappings.Add(connectorMapping); } } //tagged value references from owned attributes foreach (TaggedValue mappedTaggedValue in attribute.taggedValues.Where(x => x.tagValue is Element)) { string mappingSourcePath = KeyValuePairsHelper.getValueForKey(mappingSourcePathName, mappedTaggedValue.comment); string targetBasePath = KeyValuePairsHelper.getValueForKey(mappingTargetPathName, mappedTaggedValue.comment); //if not filled in or corresponds to the attributeBasePath or the attributeBasePath + the name of the attribute if (string.IsNullOrEmpty(mappingSourcePath) || mappingSourcePath == basepath || mappingSourcePath == basepath + "." + attribute.name) { TaggedValueMapping tagMapping; if (!string.IsNullOrEmpty(targetBasePath)) { //tagMapping = new TaggedValueMapping(mappedTaggedValue,basepath,targetBasePath); } else { //tagMapping = new TaggedValueMapping(mappedTaggedValue,basepath,targetRootElement); } //returnedMappings.Add(tagMapping); } } //add the mappings for the type of the attribute var attributeType = attribute.type as ElementWrapper; if (attributeType != null) { returnedMappings.AddRange(createOwnedMappings(attributeType, basepath + "." + attribute.name, false)); } return(returnedMappings); }
private static List <string> getMappingPath(TaggedValue mappingTag, bool target) { var mappingPath = new List <String>(); var pathString = target ? KeyValuePairsHelper.getValueForKey(mappingTargetPathName, mappingTag.comment) : KeyValuePairsHelper.getValueForKey(mappingTargetPathName, mappingTag.comment); if (!string.IsNullOrEmpty(pathString)) { mappingPath = pathString.Split(',').ToList(); } return(mappingPath); }
private string getNextIdRefString(string pdata) { int i = 0; string idRefValue = null; do { i++; idRefValue = KeyValuePairsHelper.getValueForKey("idref" + i, pdata); }while (!string.IsNullOrEmpty(idRefValue)); return("idref" + i); }
public override void save() { if (this._mappingLogic != null) { this.mappingLogic = this._mappingLogic; //make sure to set the mapping logic value correctly } //set mapping path if (this.source.structure == MP.ModelStructure.Message || this.source.isVirtual) { this.wrappedTaggedValue.comment = KeyValuePairsHelper.setValueForKey(MappingFactory.mappingSourcePathName, ((MappingNode)this.source).getMappingPathString(), this.wrappedTaggedValue.comment); } if (this.target.structure == MP.ModelStructure.Message || this.target.isVirtual) { this.wrappedTaggedValue.comment = KeyValuePairsHelper.setValueForKey(MappingFactory.mappingTargetPathName, ((MappingNode)this.target).getMappingPathString(), this.wrappedTaggedValue.comment); } this.wrappedTaggedValue.save(); }
public void setStyle(LinkStyle linkStyle) { string lineStyleString = this.wrappedDiagramLink.Style; string mode = getMode(linkStyle); string tree = getTree(linkStyle); //set the Mode lineStyleString = KeyValuePairsHelper.setValueForKey("Mode", mode, lineStyleString); //set the TREE if (string.IsNullOrEmpty(tree)) { lineStyleString = KeyValuePairsHelper.RemoveKey("TREE", lineStyleString); } else { lineStyleString = KeyValuePairsHelper.setValueForKey("TREE", tree, lineStyleString); } this.wrappedDiagramLink.Style = lineStyleString; }
private UML.Extended.UMLItem getLinkedFeature(bool isSource) { UML.Extended.UMLItem linkedFeature = null; //determine start or end keyword string key = isSource ? "LFSP" : "LFEP"; string featureGUID = KeyValuePairsHelper.getValueForKey(key, this.wrappedConnector.StyleEx); if (!string.IsNullOrEmpty(featureGUID)) { if (featureGUID.EndsWith("}R") || featureGUID.EndsWith("}L")) { //remove the last "R" or "L" featureGUID = featureGUID.Substring(0, featureGUID.Length - 1); } //get the linked feature linkedFeature = this.model.getItemFromGUID(featureGUID); } return(linkedFeature); }
public TaggedValueMapping(Element source, Element target, string sourcePath, string targetPath, MappingSettings settings) : base(source, target, sourcePath, targetPath) { string tagName = settings.linkedAttributeTagName; if (target is ConnectorWrapper) { tagName = settings.linkedAssociationTagName; } string tagComments = string.Empty; if (!string.IsNullOrEmpty(sourcePath)) { tagComments = KeyValuePairsHelper.setValueForKey("mappingSourcePath", this.stripPathFromElementName(source, sourcePath), tagComments); } if (!string.IsNullOrEmpty(targetPath)) { tagComments = KeyValuePairsHelper.setValueForKey("mappingTargetPath", this.stripPathFromElementName(target, targetPath), tagComments); } this.wrappedTaggedValue = source.addTaggedValue(tagName, target.uniqueID, tagComments, true); }
public override void correct() { int diagramCounter = 0; EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Starting corrections for diagrams'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); //Loop each diagram foreach (var mdDiagramKeyValue in magicDrawReader.allDiagrams) { //find the corresponding diagram in EA var ownerID = magicDrawReader.getDiagramOnwerID(mdDiagramKeyValue.Key); var mdDiagram = mdDiagramKeyValue.Value; string getCorrespondingdiagramSQL = @"select d.Diagram_ID from ((t_diagram d inner join t_object o on o.Object_ID = d.ParentID) inner join t_objectproperties tv on (tv.Object_ID = o.Object_ID and tv.Property = 'md_guid')) where tv.Value = '" + ownerID + "'" + " and d.Name = '" + mdDiagram.name.Replace("'", "''") + "'" + " and d.Package_ID in (" + packageTreeIDString + ")" + @" union select d.Diagram_ID from (((t_diagram d inner join t_package p on d.Package_ID = p.Package_ID) inner join t_object o on o.ea_guid = p.ea_guid) inner join t_objectproperties tv on (tv.Object_ID = o.Object_ID and tv.Property = 'md_guid')) where d.ParentID = 0 and tv.Value = '" + ownerID + "'" + " and d.Name = '" + mdDiagram.name.Replace("'", "''") + "'" + " and d.Package_ID in (" + packageTreeIDString + ")"; var eaDiagrams = this.model.getDiagramsByQuery(getCorrespondingdiagramSQL); //loop the found diagrams foreach (var eaDiagram in eaDiagrams) { diagramCounter++; if (eaDiagram != null && eaDiagram.owner is TSF_EA.ElementWrapper) { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Processing diagram number {1}: '{2}.{3}'" , DateTime.Now.ToLongTimeString() , diagramCounter , eaDiagram.owner.name , eaDiagram.name) , ((TSF_EA.ElementWrapper)eaDiagram.owner).id , LogTypeEnum.log); } else if (eaDiagram != null) { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Processing diagram number {1}: '{2}'" , DateTime.Now.ToLongTimeString() , diagramCounter , eaDiagram.name) , 0 , LogTypeEnum.log); } else { break; } //loop all diagramObjects in the mdDiagram that are not activity partitions foreach (var mdDiagramObject in mdDiagram.diagramObjects.Where(x => !x.umlType.StartsWith("Swimlane"))) { addElementToDiagram(mdDiagramObject, eaDiagram); } //save diagram in between? //eaDiagram.save(); //then do all Activity Partitions foreach (var mdDiagramObject in mdDiagram.diagramObjects.Where(x => x.umlType.StartsWith("Swimlane"))) { addElementToDiagram(mdDiagramObject, eaDiagram); } //then do all the messages int i = 1; //default previous y = -100 int previousY = -100; foreach (var mdMessageLink in mdDiagram.diagramObjects.Where(x => x.umlType == "SeqMessage").OrderBy(y => y.y)) { //get the corresponding message string sqlGetMessage = @"select * from (t_connector c inner join t_connectortag tv on (c.Connector_ID = tv.ElementID and tv.Property = 'md_guid')) where tv.VALUE = '" + mdMessageLink.mdID + "'"; var messages = this.model.getRelationsByQuery(sqlGetMessage); foreach (TSF_EA.Message message in messages) { message.sequence = i; int y = mdMessageLink.y * -1; message.y = y; message.WrappedConnector.DiagramID = eaDiagram.DiagramID; message.save(); //update pdata5 SY field. This needs to be filled with the 35 + the difference between the current Y and the previous Y int SYValue = 35 - (previousY - y); //set the previousY previousY = y; //get pdata5 string pdata5 = "SX=0;SY=0;EX=0;EY=0;$LLB=;LLT=;LMT=CX=250:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=1:DIR=0:ROT=0;LMB=;LRT=;LRB=;IRHS=;ILHS=;"; //set SY value pdata5 = KeyValuePairsHelper.setValueForKey("SY", SYValue.ToString(), pdata5); //update pdata5 string sqlUpdatePdata5 = "update t_connector set PDATA5 = '" + pdata5 + "' where ea_guid = '" + message.uniqueID + "'"; this.model.executeSQL(sqlUpdatePdata5); } i++; } //save the diagram eaDiagram.save(); //set the line styles correctLines(eaDiagram); } //if no diagram found in EA then report it as error if (!eaDiagrams.Any()) { EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Could not find EA diagram for diagram with ID '{1}'" , DateTime.Now.ToLongTimeString() , mdDiagramKeyValue.Key) , 0 , LogTypeEnum.error); } } // after all diagram are done we fix the activity partition using a query fixActivityPartitions(); EAOutputLogger.log(this.model, this.outputName , string.Format("{0} Finished corrections for diagrams'" , DateTime.Now.ToLongTimeString()) , 0 , LogTypeEnum.log); }