From: Benjamin B. <bg...@us...> - 2005-03-24 09:10:53
|
Update of /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/UMLBuffer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17065/Plugin/com/ibm/ecute/UMLBuffer Modified Files: UMLBuffer.java Log Message: Changes to get aggregations and compositions the right way round in RSA Index: UMLBuffer.java =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/UMLBuffer/UMLBuffer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- UMLBuffer.java 21 Dec 2004 17:08:32 -0000 1.5 +++ UMLBuffer.java 24 Mar 2005 09:10:44 -0000 1.6 @@ -34,6 +34,7 @@ import com.ibm.ecute.UMLBuffer.UMLTree.UMLRole; import com.ibm.ecute.plugins.ProgressFrame; import com.ibm.ecute.plugins.output.UMLInterface; +import com.ibm.ecute.plugins.output.funcionality.RSAModelCreator; import com.ibm.ecute.utils.License; import com.ibm.ecute.utils.Utils; public class UMLBuffer implements UMLInterface { @@ -46,6 +47,7 @@ private UMLRole lastRole1 = null; private UMLRole lastRole2 = null; private UMLQualified lastAddedElement = null; + boolean aggregateRole1 = true; boolean ready = false; private ProgressFrame log; public UMLBuffer(ProgressFrame log) { @@ -506,8 +508,26 @@ ArrayList qualifiers = qualifiedElement.getQualifiers(!completeClasses); for (int i = 0; i < qualifiers.size(); i++) { UMLQualifier theQualifier = (UMLQualifier) qualifiers.get(i); + // RSA + if (UMLProgram instanceof RSAModelCreator){ + // if the aggregation/composition is defined in the second role of a association class + // then the qualifiers have to be added to the other end of the association + // (in this case the addAssociation mehtod is also called the other way round + if (aggregateRole1 == false && qualifiedElement.getType() == TLINK1){ + UMLProgram.SetQualifier(TLINK2, theQualifier.name, theQualifier.value); + } else if (aggregateRole1 == false && qualifiedElement.getType() == TLINK2){ + UMLProgram.SetQualifier(TLINK1, theQualifier.name, theQualifier.value); + // normal case, if qualifiedElement is a class, normal association or an + // aggregation/composition with the definition in role1 + } else { + UMLProgram.SetQualifier(qualifiedElement.getType(), + theQualifier.name, theQualifier.value); + } + // ROSE + } else { UMLProgram.SetQualifier(qualifiedElement.getType(), theQualifier.name, theQualifier.value); + } } } void CreateMethods(ArrayList methods) { @@ -543,9 +563,56 @@ return OK; UMLRole role1 = theClass.getRole1(); UMLRole role2 = theClass.getRole2(); + try { - int result = UMLProgram.AddAssociation(role1.endPointName, + int result = -1; + // RSA + if (UMLProgram instanceof RSAModelCreator){ + // System.out.println("UMLProgram is an instance of RSAModelCreator"); + + // get the first qualifier of each association role to find out + // in which role the aggregate is defined + ArrayList qualifiers1 = role1.getQualifiers(true); + UMLQualifier role1Qualifier = (UMLQualifier) qualifiers1.get(0); + ArrayList qualifiers2 = role2.getQualifiers(true); + UMLQualifier role2Qualifier = (UMLQualifier) qualifiers2.get(0); + + // if aggregate is defined in role 1 (MOF file) then AddAssociation is + // called with role 2 first to get the diamond on the correct end of the + // association (the diamond is in RSA on the side of the second role + // which is passed to AddAssociation) + if (role1Qualifier.name.equalsIgnoreCase("Aggregate")){ + System.out.println("Role 1 is AGGREGATE"); + aggregateRole1 = true; + result = UMLProgram.AddAssociation(role2.endPointName, + role2.name, role1.endPointName, role1.name, RclassDiagram); + } + // if aggregate is defined in role 2 (MOF file) + // aggregateRole1 is set to false to get the qualifiers (with SetQualifiers) + // to the correct end of the aggregation/composition + else if (role2Qualifier.name.equalsIgnoreCase("Aggregate")){ + System.out.println("Role 2 is AGGREGATE"); + aggregateRole1 = false; + result = UMLProgram.AddAssociation(role1.endPointName, + role1.name, role2.endPointName, role2.name, RclassDiagram); + + // if the association is no aggregation or composition + } else { + //System.out.println("Normal association"); + //System.out.println("Role 1 end point = " + role1.endPointName + " Role 1 name = " + role1.name); + //System.out.println("Role 2 end point = " + role2.endPointName + " Role 2 name = " + role2.name); + aggregateRole1 = true; + result = UMLProgram.AddAssociation(role2.endPointName, + role2.name, role1.endPointName, role1.name, RclassDiagram); + } + // ROSE + } else { + result = UMLProgram.AddAssociation(role1.endPointName, role1.name, role2.endPointName, role2.name, RclassDiagram); + } + // create the qulifiers of the roles + // it doesn't matter if the qualifiers of role 1 are created + // first or not if (result == OK) { CreateQualifiers(role1); CreateQualifiers(role2); |