[Sblim-commit] ecute/Plugin/com/ibm/ecute/plugins/output/funcionality RSAModelCreator.java,1.12,1.13
From: Benjamin B. <bg...@us...> - 2005-06-06 14:17:55
|
Update of /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/plugins/output/funcionality In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1136/Plugin/com/ibm/ecute/plugins/output/funcionality Modified Files: RSAModelCreator.java Log Message: 2.1 beta 1c full support of the OCL qualifier for a class as a class constraint Index: RSAModelCreator.java =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/plugins/output/funcionality/RSAModelCreator.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- RSAModelCreator.java 31 May 2005 13:12:46 -0000 1.12 +++ RSAModelCreator.java 6 Jun 2005 14:17:43 -0000 1.13 @@ -586,78 +586,6 @@ if(name.equalsIgnoreCase("Composition")&& !value.equalsIgnoreCase("false")){ lastClassComposition = true; } - - // create OCL class constraint - if(name.equalsIgnoreCase("OCL")&& !value.equalsIgnoreCase("null")){ - Package package_ = lastCategory; - Constraint constraint = (Constraint)package_.createOwnedMember(UML2Package.eINSTANCE.getConstraint()); - constraint.setName("OCL " + lastClass.getName()); - - // create specification - constraint.createSpecification(UML2Package.eINSTANCE.getOpaqueExpression()); - // set OCL body - setOCLBody(constraint, value); -// String tempBody, body = ""; -// // prepare constraint body content -// if(value.startsWith("{")){ -// int length = value.length(); -// tempBody = value.substring(2, length - 2); -// } else { -// tempBody = value; -// } -// int index = tempBody.indexOf(","); -// boolean multiple = false; -// if (index != -1) -// multiple = true; -// while (index != -1){ -// int length = tempBody.length(); -// body = body.concat(tempBody.substring(0, index - 1)); -// body = body.concat("\n"); -// tempBody = tempBody.substring(index + 2); -// index = tempBody.indexOf(","); -// } -// if (multiple){ -// body = body.concat(tempBody.substring(index + 1)); -// } -// if (!multiple) -// body = tempBody; -// -// //set constraint body and language -// ((OpaqueExpression)constraint.getSpecification()).setBody(body); -// ((OpaqueExpression)constraint.getSpecification()).setLanguage("OCL"); - - // get the connection line between the constraint and the class - constraint.getConstrainedElements().add(lastClass); - - // add constraint to diagram - ArrayList list = new ArrayList(); - list.add(constraint); - List diagrams = diagramHelper.getDiagrams(package_, UMLDiagramKind.CLASS_LITERAL); - Iterator it = diagrams.iterator(); - Diagram thisDiagram = null; - while(it.hasNext()){ - Diagram diagram = (Diagram)it.next(); - if(diagram.getName().equalsIgnoreCase("Main")) - thisDiagram = diagram; - } - if (thisDiagram != null){ - diagramHelper.createViews(thisDiagram, list); - } - } - } - - if(type == TMETHOD){ - - // create pre/post conditions of a method - // not implemented yet - if(name.equalsIgnoreCase("OCL")&& !value.equalsIgnoreCase("null")){ - System.out.println("class: " + lastClass.getName()); - System.out.println("name: " + name + " value: "+ value); - - // lastMethod.getPreconditions().add(); - // lastMethod.getPostconditions().add(); - } - } // because of the different role order in RSA theElement is @@ -832,7 +760,48 @@ int stereotypePropertyIndex = ((List) theElement.getValue(cimStereotype, "QualifierName")).size(); theElement.setValue(cimStereotype, "QualifierName["+stereotypePropertyIndex+"]", name); theElement.setValue(cimStereotype, "QualifierValue["+stereotypePropertyIndex+"]", value); - + + } else if(name.equalsIgnoreCase("OCL")&& !value.equalsIgnoreCase("null")){ + if(theElement instanceof Class){ + // create OCL class constraint + Package package_ = lastCategory; + Constraint constraint = (Constraint)package_.createOwnedMember(UML2Package.eINSTANCE.getConstraint()); + constraint.setName("OCL " + lastClass.getName()); + + // create specification + constraint.createSpecification(UML2Package.eINSTANCE.getOpaqueExpression()); + // set OCL body + setOCLBody(constraint, value); + + // get the connection line between the constraint and the class + constraint.getConstrainedElements().add(lastClass); + + // add constraint to diagram + ArrayList list = new ArrayList(); + list.add(constraint); + List diagrams = diagramHelper.getDiagrams(package_, UMLDiagramKind.CLASS_LITERAL); + Iterator it = diagrams.iterator(); + Diagram thisDiagram = null; + while(it.hasNext()){ + Diagram diagram = (Diagram)it.next(); + if(diagram.getName().equalsIgnoreCase("Main")) + thisDiagram = diagram; + } + if (thisDiagram != null){ + diagramHelper.createViews(thisDiagram, list); + } + } else if(theElement instanceof Operation){ + // create pre/post conditions of a method + // TODO not implemented yet + if(name.equalsIgnoreCase("OCL")&& !value.equalsIgnoreCase("null")){ + System.out.println("class: " + lastClass.getName()); + System.out.println("name: " + name + " value: "+ value); + + // lastMethod.getPreconditions().add(); + // lastMethod.getPostconditions().add(); + } + } + }else{ if (value.length() == 0) |