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);
 }
예제 #2
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);
        }
예제 #3
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);
        }