Hi there,
I'm having a problem with a UML profile, rbacUML, that I created using Rational Software Architect. The attached picture shows two stereotypes, «User» and «Role», that can be attached to a class. There is also a 0..* association between «User» and «Role».
Now, I can easily create classes stereotyped with «User» or «Role». Here is a code sample that create one of each:
Package root = (Package)element;
org.eclipse.uml2.uml.Class jSmith = root.createOwnedClass("John Smith", false);
org.eclipse.uml2.uml.Class student = root.createOwnedClass("Student", false);
Stereotype uSter = root.getAppliedProfile("rbacUML").getOwnedStereotype("User");
jSmith.applyStereotype(uSter);
Stereotype rSter = root.getAppliedProfile("rbacUML").getOwnedStereotype("RBACRole");
student.applyStereotype(rSter);
The problem is: how do I create an association between «User» on the class John Smith and «Role» on the class Student? I tried using setValue(...):
jSmith.setValue(jSmith.getAppliedStereotype("rbacUML::User"), "rBACRole", student.getAppliedStereotype("rbacUML::Role"));
... but I get the following exception:
java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@38b938b9 (name: RBACRole, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
at org.eclipse.uml2.uml.internal.operations.ElementOperations.setValue(Unknown Source)
at org.eclipse.uml2.uml.internal.impl.ElementImpl.setValue(Unknown Source)
at LDAPImporter$1.doExecute(Unknown Source)
at org.eclipse.emf.transaction.RecordingCommand.execute(Unknown Source)
at org.eclipse.emf.workspace.EMFCommandOperation.doExecute(Unknown Source)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(Unknown Source)
at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(Unknown Source)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(Unknown Source)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(Unknown Source)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(Unknown Source)
at LDAPImporter.plugletmain(Unknown Source)
I guess the problem comes from the 0..* multiplicity? Can anyone help me create such an association?
Thank you very much!