Beispiel #1
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 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)
            {
                string sqlGetCorrespondingAssociation = string.Empty;
                var    sourceElement = getElementByMDid(mdAssociation.source.endClassID);
                var    targetElement = getElementByMDid(mdAssociation.target.endClassID);

                if (sourceElement != null && targetElement != null)
                {
                    //moved code -> twee checks doen dan
                    //source -> target
                    correspondingAssociation = GetCorrespondingAssociation(sourceElement, targetElement, mdAssociation.source.name, mdAssociation.target.name);
                    //if we find the association we set the md_guid tagged value
                    if (correspondingAssociation != null)
                    {
                        correspondingAssociation.addTaggedValue("md_guid", mdAssociation.md_guid);
                    }

                    //target -> source
                    correspondingAssociation = GetCorrespondingAssociation(targetElement, sourceElement, mdAssociation.target.name, mdAssociation.source.name);
                    //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());
     }
 }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }