コード例 #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 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());
     }
 }
        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);
        }
 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);
 }