/// <summary>
        /// returns the matching SchemaAssociation for the given Association.
        /// the match is made based on the tagged value sourceAssociation on the subset assocation, which references the source association fo the SchemaAssociation
        /// </summary>
        /// <param name="association">the association to match</param>
        /// <returns>the matching SchemaAssociation</returns>
        public EASchemaAssociation getMatchingSchemaAssociation(UTF_EA.Association association)
        {
            EASchemaAssociation result = null;
            var sourceAssociationTag   = association.getTaggedValue(this.owner.settings.sourceAssociationTagName);

            if (sourceAssociationTag != null)
            {
                string tagReference = sourceAssociationTag.eaStringValue;

                foreach (EASchemaAssociation schemaAssociation in this.schemaAssociations)
                {
                    //we have the same attribute if the given attribute has a tagged value
                    //called sourceAssociation that refences the source association of the schema Association
                    if (((UTF_EA.Association)schemaAssociation.sourceAssociation).guid == tagReference)
                    {
                        //if the schema association has choiceElements then the target of the association should match one of the choice elements
                        if ((schemaAssociation.choiceElements != null &&
                             (schemaAssociation.choiceElements.Count == 0 ||
                              schemaAssociation.choiceElements.Exists(x => association.target.Equals(x.subsetElement)))) ||
                            schemaAssociation.choiceElements == null)
                        {
                            result = schemaAssociation;
                            break;
                        }
                    }
                }
            }
            return(result);
        }
 private TSF_EA.Association createNewCorrespondingAssociation(TSF_EA.ElementWrapper sourceElement, TSF_EA.ElementWrapper targetElement, MDAssociation mdAssociation)
 {
     //create the actual association
     TSF_EA.Association newAssociation = this.model.factory.createNewElement <TSF_EA.Association>(sourceElement, string.Empty);
     //set target class
     newAssociation.target = targetElement;
     //set source name
     newAssociation.sourceEnd.name        = mdAssociation.source.name;
     newAssociation.sourceEnd.aggregation = parseAggregationKind(mdAssociation.source.aggregationKind);
     //set target name
     newAssociation.targetEnd.name        = mdAssociation.target.name;
     newAssociation.targetEnd.aggregation = parseAggregationKind(mdAssociation.target.aggregationKind);
     //set the target end navigable by default
     newAssociation.targetEnd.isNavigable = true;
     if (mdAssociation.stereotype == "participates")
     {
         newAssociation.targetEnd.isNavigable = false;
     }
     //set the stereotype
     newAssociation.addStereotype(this.model.factory.createStereotype(newAssociation, mdAssociation.stereotype));
     //save the new association
     newAssociation.save();
     //return
     return(newAssociation);
 }
示例#3
0
        private TSF_EA.Association findCorrespondingAssociation(MDAssociation mdAssociation)
        {
            //first try to find it using the MD guid
            string sqlGetExistingRelations = @"select c.Connector_ID from (t_connector c
											inner join t_connectortag tv on( c.Connector_ID = tv.ElementID
														and tv.Property = 'md_guid'))
											where tv.VALUE = '"                                             + mdAssociation.md_guid + "'";

            TSF_EA.Association correspondingAssociation = this.model.getRelationsByQuery(sqlGetExistingRelations).FirstOrDefault() as TSF_EA.Association;
            //if not found then we look for associations that
            // - are between the same two elements
            // - have the same rolenames
            if (correspondingAssociation == null)
            {
                var sourceElement = getElementByMDid(mdAssociation.source.endClassID);
                var targetElement = getElementByMDid(mdAssociation.target.endClassID);
                if (sourceElement != null && targetElement != null)
                {
                    //first set the first part:
                    string sqlGetCorrespondingAssociation =
                        @"select c.Connector_ID from t_connector c
						where c.Connector_Type in ('Association', 'Aggregation')
						and c.Start_Object_ID = "                         + sourceElement.id + Environment.NewLine +
                        "and c.End_Object_ID = " + targetElement.id;
                    if (!string.IsNullOrEmpty(mdAssociation.target.name))
                    {
                        //target role is filled in
                        sqlGetCorrespondingAssociation += @" 
						and c.DestRole = '"                         + mdAssociation.target.name + "'";
                    }
                    if (!string.IsNullOrEmpty(mdAssociation.source.name))
                    {
                        //source role is filled in
                        sqlGetCorrespondingAssociation += @" 
						and c.SourceRole = '"                         + mdAssociation.source.name + "'";
                    }
                    //add the part checking for the md_guid
                    sqlGetCorrespondingAssociation += @" 
					and not exists 
					(select tv.PropertyID from t_connectortag tv
					where tv.ElementID = c.Connector_ID
					and tv.Property = 'md_guid'
					and tv.VALUE is not null)"                    ;
                    correspondingAssociation        = this.model.getRelationsByQuery(sqlGetCorrespondingAssociation).FirstOrDefault() as TSF_EA.Association;
                    //if we find the association we set the md_guid tagged value
                    if (correspondingAssociation != null)
                    {
                        correspondingAssociation.addTaggedValue("md_guid", mdAssociation.md_guid);
                    }
                }
            }
            return(correspondingAssociation);
        }
 private void setSequenceKey(MDAssociation mdAssociation, TSF_EA.Association eaAssociation)
 {
     //only if the association is an ASMA or ASBIE association
     if (eaAssociation.hasStereotype("ASMA") ||
         eaAssociation.hasStereotype("ASBIE"))
     {
         //find the associationRole with the largest sequenceKey
         int sequenceKey = mdAssociation.source.sequenceKey > mdAssociation.target.sequenceKey ?
                           mdAssociation.source.sequenceKey : mdAssociation.target.sequenceKey;
         //set the tagged value on the association
         eaAssociation.addTaggedValue("sequencingKey", sequenceKey.ToString());
     }
 }
示例#5
0
        /// <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);
                }
            }
        }
        private TSF_EA.Association findCorrespondingAssociation(MDAssociation mdAssociation)
        {
            //first try to find it using the MD guid
            string sqlGetExistingRelations = @"select c.Connector_ID from (t_connector c
											inner join t_connectortag tv on( c.Connector_ID = tv.ElementID
														and tv.Property = 'md_guid'))
											where tv.VALUE = '"                                             + mdAssociation.md_guid + "'";

            TSF_EA.Association correspondingAssociation = this.model.getRelationsByQuery(sqlGetExistingRelations).FirstOrDefault() as TSF_EA.Association;
            //if not found then we look for associations that
            // - are between the same two elements
            // - have the same rolenames
            if (correspondingAssociation != null)
            {
                return(correspondingAssociation);
            }

            //not found with mdguid, search other associations
            string sqlGetCorrespondingAssociation = string.Empty;
            var    sourceElement = getElementByMDid(mdAssociation.source.endClassID);
            var    targetElement = getElementByMDid(mdAssociation.target.endClassID);

            if (sourceElement != null && targetElement != null)
            {
                //source -> target
                correspondingAssociation = GetCorrespondingAssociation(sourceElement, targetElement, mdAssociation.source.name, mdAssociation.target.name);
                //target -> source
                if (correspondingAssociation == null)
                {
                    correspondingAssociation = GetCorrespondingAssociation(targetElement, sourceElement, mdAssociation.target.name, mdAssociation.source.name);
                }
                //if still not found we create it new
                if (correspondingAssociation == null)
                {
                    correspondingAssociation = createNewCorrespondingAssociation(sourceElement, targetElement, mdAssociation);
                }
                //if we find the association we set the md_guid tagged value
                if (correspondingAssociation != null)
                {
                    correspondingAssociation.addTaggedValue("md_guid", mdAssociation.md_guid);
                }
            }

            return(correspondingAssociation);
        }
示例#7
0
        public override void correct()
        {
            EAOutputLogger.log(this.model, this.outputName
                               , string.Format("{0} Starting corrections for ASMA associations"
                                               , DateTime.Now.ToLongTimeString())
                               , 0
                               , LogTypeEnum.log);
            foreach (MDAssociation mdAssociation in magicDrawReader.allASMAAssociations)
            {
                //find the source class
                var sourceClass = this.getClassByMDid(mdAssociation.source.endClassID);
                //find the target class
                var targetClass = this.getClassByMDid(mdAssociation.target.endClassID);
                if (sourceClass != null && targetClass != null)
                {
                    EAOutputLogger.log(this.model, this.outputName
                                       , string.Format("{0} Creating ASMA association between '{1}' and '{2}'"
                                                       , DateTime.Now.ToLongTimeString()
                                                       , sourceClass.name
                                                       , targetClass.name)
                                       , sourceClass.id
                                       , LogTypeEnum.log);
                    //check if the association already exists
                    //check if the relation doesn't exist yet
                    string             sqlGetExistingRelations = @"select c.Connector_ID from (t_connector c
												inner join t_connectortag tv on( c.Connector_ID = tv.ElementID
															and tv.Property = 'md_guid'))
												where tv.VALUE = '"                                                 + mdAssociation.md_guid + "'";
                    TSF_EA.Association newAsmaAssociation      = this.model.getRelationsByQuery(sqlGetExistingRelations).FirstOrDefault() as TSF_EA.Association;
                    if (newAsmaAssociation == null)
                    {
                        //create the actual association
                        newAsmaAssociation = this.model.factory.createNewElement <TSF_EA.Association>(sourceClass, string.Empty);
                        //set source end properties
                        setEndProperties(newAsmaAssociation.sourceEnd, mdAssociation.source);
                        //set target end properties
                        setEndProperties(newAsmaAssociation.targetEnd, mdAssociation.target);
                        //set the target end navigable by default
                        newAsmaAssociation.targetEnd.isNavigable = true;
                        //set target class
                        newAsmaAssociation.target = targetClass;
                    }
                    if (newAsmaAssociation != null)
                    {
                        //set the stereotype
                        newAsmaAssociation.addStereotype(this.model.factory.createStereotype(newAsmaAssociation, mdAssociation.stereotype));
                        //save the new association
                        newAsmaAssociation.save();
                        //set the md_guid tagged value
                        newAsmaAssociation.addTaggedValue("md_guid", mdAssociation.md_guid);
                    }
                }
                else
                {
                    EAOutputLogger.log(this.model, this.outputName
                                       , string.Format("{0} Could not create ASMA association classes with ID's '{1}' and '{2}'"
                                                       , DateTime.Now.ToLongTimeString()
                                                       , mdAssociation.source.endClassID
                                                       , mdAssociation.target.endClassID)
                                       , 0
                                       , LogTypeEnum.error);
                }
            }
            EAOutputLogger.log(this.model, this.outputName
                               , string.Format("{0} Finished corrections for ASMA associations'"
                                               , DateTime.Now.ToLongTimeString())
                               , 0
                               , LogTypeEnum.log);
        }
示例#8
0
 public AssociationMappingNode(TSF_EA.Association sourceAssociation, ClassifierMappingNode parent, MappingSettings settings, MP.ModelStructure structure, UML.Classes.Kernel.NamedElement virtualOwner) : base(sourceAssociation, parent, settings, structure, virtualOwner)
 {
 }
示例#9
0
 public AssociationMappingNode(TSF_EA.Association sourceAssociation, ClassifierMappingNode parent, MappingSettings settings, MP.ModelStructure structure) : this(sourceAssociation, parent, settings, structure, null)
 {
 }
示例#10
0
 public AssociationMappingNode(TSF_EA.Association sourceAssociation, MappingSettings settings, MP.ModelStructure structure) : this(sourceAssociation, null, settings, structure)
 {
 }
示例#11
0
 public AssociationMappingNode(TSF_EA.Association sourceAssociation, ElementMappingNode parent, MappingSettings settings, MP.ModelStructure structure, bool isTarget)
     : this(sourceAssociation, parent, settings, structure, null, isTarget)
 {
 }
示例#12
0
        void correctAssociations()
        {
            EAOutputLogger.log(this.model, this.outputName
                               , string.Format("{0} Starting corrections for the associations"
                                               , DateTime.Now.ToLongTimeString())
                               , 0
                               , LogTypeEnum.log);

            //First get all the associations
            foreach (var mdAssociation in magicDrawReader.allAssociations)
            {
                //Check if the association already exists
                if (!exists(mdAssociation.Key, mdAssociation.Value.source.endClassID, mdAssociation.Value.target.endClassID, "Association", mdAssociation.Value.stereotype))
                {
                    //It it does not exist -> create
                    var sourceElement = this.getElementByMDid(mdAssociation.Value.source.endClassID);
                    var targetElement = this.getElementByMDid(mdAssociation.Value.target.endClassID);

                    if (sourceElement != null && targetElement != null)
                    {
                        //create the actual association
                        TSF_EA.Association newAssociation = this.model.factory.createNewElement <TSF_EA.Association>(sourceElement, string.Empty);
                        //set source end properties
                        setEndProperties(newAssociation.sourceEnd, mdAssociation.Value.source);
                        //set target end properties
                        setEndProperties(newAssociation.targetEnd, mdAssociation.Value.target);
                        //set the target end navigable by default
                        newAssociation.targetEnd.isNavigable = true;
                        if (mdAssociation.Value.stereotype == "participates")
                        {
                            newAssociation.targetEnd.isNavigable = false;
                        }


                        //set target class
                        newAssociation.target = targetElement;
                        //set the stereotype
                        newAssociation.addStereotype(this.model.factory.createStereotype(newAssociation, mdAssociation.Value.stereotype));
                        //save the new association
                        newAssociation.save();
                        //set the md_guid tagged value
                        newAssociation.addTaggedValue("md_guid", mdAssociation.Key);

                        //tell the user
                        EAOutputLogger.log(this.model, this.outputName
                                           , string.Format("{0} Created «" + mdAssociation.Value.stereotype + "» association between '{1}' and '{2}'"
                                                           , DateTime.Now.ToLongTimeString()
                                                           , newAssociation.source.name
                                                           , newAssociation.target.name)
                                           , ((TSF_EA.ElementWrapper)newAssociation.source).id
                                           , LogTypeEnum.log);
                    }
                }
            }

            EAOutputLogger.log(this.model, this.outputName
                               , string.Format("{0} Finished corrections for the associations"
                                               , DateTime.Now.ToLongTimeString())
                               , 0
                               , LogTypeEnum.log);
        }
示例#13
0
        public override void correct()
        {
            EAOutputLogger.log(this.model, this.outputName
                               , string.Format("{0} Starting corrections for cross MDzip relations"
                                               , DateTime.Now.ToLongTimeString())
                               , 0
                               , LogTypeEnum.log);

            //loop all simple element to element cross mdzip relations
            foreach (var crossRelation in magicDrawReader.allCrossMDzipRelations)
            {
                //check if the relation doesn't exist yet
                string sqlGetExistingRelations = @"select c.Connector_ID from (t_connector c
												inner join t_connectortag tv on( c.Connector_ID = tv.ElementID
															and tv.Property = 'md_guid'))
												where tv.VALUE = '"                                                 + crossRelation.Key + "'";
                var    newRelation             = this.model.getRelationsByQuery(sqlGetExistingRelations).FirstOrDefault();



                if (newRelation == null)
                {
                    MDElementRelation relation = crossRelation.Value;
                    //find source
                    var source = this.getElementByMDid(relation.sourceMDGUID);
                    //find target
                    var target = this.getElementByMDid(relation.targetMDGUID);
                    //create relation
                    if (source != null &&
                        target != null)
                    {
                        //create the actual relation
                        newRelation = this.model.factory.createNewElement(source, relation.name, relation.relationType) as TSF_EA.ConnectorWrapper;
                        if (newRelation != null)
                        {
                            newRelation.target = target;
                            newRelation.save();
                            //save md_guid tag
                            newRelation.addTaggedValue("md_guid", crossRelation.Key);
                            //tell the user what is happening
                            EAOutputLogger.log(this.model, this.outputName
                                               , string.Format("{0} Created relation of type {1} between '{2}' and '{3}'"
                                                               , DateTime.Now.ToLongTimeString()
                                                               , relation.relationType
                                                               , source.name
                                                               , target.name)
                                               , source.id
                                               , LogTypeEnum.log);
                        }
                        else
                        {
                            //report the fact that we could not create the relation
                            EAOutputLogger.log(this.model, this.outputName
                                               , string.Format("{0} Could not create relation of type {1} between '{2}' and '{3}'"
                                                               , DateTime.Now.ToLongTimeString()
                                                               , relation.relationType
                                                               , source.name
                                                               , target.name)
                                               , source.id
                                               , LogTypeEnum.error);
                        }
                    }
                }
                //save md_guid tag
                if (newRelation != null)
                {
                    newRelation.addTaggedValue("md_guid", crossRelation.Key);
                }
            }


            //loop all cross MDzip Associations
            foreach (var mdCrossAssocation in magicDrawReader.allCrossMDzipAssociations)
            {
                //check if the relation doesn't exist yet
                string sqlGetExistingRelations = @"select c.Connector_ID from (t_connector c
												inner join t_connectortag tv on( c.Connector_ID = tv.ElementID
															and tv.Property = 'md_guid'))
												where tv.VALUE = '"                                                 + mdCrossAssocation.Key + "'";

                TSF_EA.Association newCrossAssociation = this.model.getRelationsByQuery(sqlGetExistingRelations).FirstOrDefault() as TSF_EA.Association;
                if (newCrossAssociation == null)
                {
                    var mdAssociation = mdCrossAssocation.Value;
                    //get the source element
                    var source = this.getElementByMDid(mdAssociation.source.endClassID);
                    //get the target element
                    var target = this.getElementByMDid(mdAssociation.target.endClassID);
                    if (source != null &&
                        target != null)
                    {
                        //create the actual association
                        newCrossAssociation = this.model.factory.createNewElement <TSF_EA.Association>(source, string.Empty);
                        //set source end properties
                        setEndProperties(newCrossAssociation.sourceEnd, mdAssociation.source);
                        //set target end properties
                        setEndProperties(newCrossAssociation.targetEnd, mdAssociation.target);
                        //set target class
                        newCrossAssociation.target = target;
                        //set navigability
                        newCrossAssociation.targetEnd.isNavigable = true;
                        //save the association
                        newCrossAssociation.save();
                        //tell the user what is happening
                        EAOutputLogger.log(this.model, this.outputName
                                           , string.Format("{0} Created association between '{1}' and '{2}'"
                                                           , DateTime.Now.ToLongTimeString()
                                                           , source.name
                                                           , target.name)
                                           , source.id
                                           , LogTypeEnum.log);
                    }
                    else
                    {
                        //report the fact that we could not create the relation
                        EAOutputLogger.log(this.model, this.outputName
                                           , string.Format("{0} Could not create association between '{1}' and '{2}'"
                                                           , DateTime.Now.ToLongTimeString()
                                                           , source.name
                                                           , target.name)
                                           , source.id
                                           , LogTypeEnum.error);
                    }
                }
                //set the md_guid tagged value, also on existing associations
                if (newCrossAssociation != null)
                {
                    newCrossAssociation.addTaggedValue("md_guid", mdCrossAssocation.Key);
                }
            }
            EAOutputLogger.log(this.model, this.outputName
                               , string.Format("{0} Finished corrections for cross MDzip relations"
                                               , DateTime.Now.ToLongTimeString())
                               , 0
                               , LogTypeEnum.log);
        }
 public EAForeignKeyTransformer(ForeignKey foreignKey, UTF_EA.Association association, NameTranslator nameTranslator) : this(nameTranslator)
 {
     _foreignKey         = foreignKey;
     _logicalAssociation = association;
 }
 public DB2ForeignKeyTransformer(ForeignKey foreignKey, UTF_EA.Association association, NameTranslator nameTranslator) : base(foreignKey, association, nameTranslator)
 {
 }
 public EAForeignKeyTransformer(ForeignKey foreignKey, UTF_EA.Association association,NameTranslator nameTranslator)
     : this(nameTranslator)
 {
     _foreignKey = foreignKey;
     _logicalAssociation = association;
 }