Home » Modeling » Papyrus » Extending Associations in UML Profile
Extending Associations in UML Profile [message #1754089] |
Tue, 14 February 2017 13:10 |
|
Hi there,
I wonder if you could provide some guidelines on how to extend Association when creating UML profiles.
Right now I create two Stereotypes A and B (both extends Class), and I want to add an association between them called "ref" from A to B. I was told the correct way to do that is to create a new Stereotype named "ref" and have it extend Association. However, I am eager to know how I can make ref connect to A and B. Please help.
Cheers,
Will
Research Associate
Department of Computer Science
University of York
|
|
| |
Re: Extending Associations in UML Profile [message #1754094 is a reply to message #1754091] |
Tue, 14 February 2017 13:39 |
|
Hi Christian,
Thanks!
How do we apply this visually when we create an UML model applying the aforementioned profile?
Assume there are Stereotypes A and B that extend Class and I create an Association from A to B named ref.
When I create an UML model (class diagram), I create Class1 and Class2, applied Stereotypes A and B to them, now if I want to express in the diagram that the relationship between Class1 and Class2 is "ref" as I created in the profile, what should I do?
Cheers,
Will
Research Associate
Department of Computer Science
University of York
|
|
|
Re: Extending Associations in UML Profile [message #1754096 is a reply to message #1754094] |
Tue, 14 February 2017 13:52 |
|
Hi, Will,
The Properties View will show, in the Profile tab, a "ref" property for Class1 in which you can select Class2 as the referenced element. This will then set the association between the A stereotype application of Class1 and the B application of Class2.
For visualization in the diagram, you can enable any of the various stereotype presentation options in the Appearance tab of the properties of Class1 to show how Class1 is tagged with a "ref = Class2" value. AFAIK, Papyrus does not offer a connector visualization of stereotype associations in the diagram.
But, as you're dealing with stereotypes of classes, perhaps we should take a step back and ask what really is the meaning of this "ref" association between the stereotypes? Is it only meant to link stereotypes of classes that have an UML association between them? In that case, then it may well be more appropriate to make it a stereotype of the association, itself, in which case in the UML model you would draw the association and apply the stereotype in its Profile tab in the Properties View. But if the "ref" association between the stereotypes isn't something to do with UML associations, then you wouldn't want this.
So, what does "ref" actually mean?
Cheers,
Christian
|
|
|
Re: Extending Associations in UML Profile [message #1754099 is a reply to message #1754096] |
Tue, 14 February 2017 14:10 |
|
Hi Christian,
I am trying to implement the SACM (Safety Assurance Case Metamodel) using UML profile. So I am essentially creating a metamodel. The "ref" is just an example, in fact, in the SACM there are many references among entities. So would you consider creating Stereotypes that extend Association to be more appropriate?
Cheers,
Will
Research Associate
Department of Computer Science
University of York
|
|
| |
Re: Extending Associations in UML Profile [message #1754105 is a reply to message #1754104] |
Tue, 14 February 2017 14:43 |
|
Sorry, the forum software lopped off all of my reply.
I meant to say that, if the SACM concepts that in your profile are mapped to UML classifiers, then it is entirely possible that this reference between them should be mapped to the UML concept of association, if the semantics are similar (does the SACM reference describe a link between instances of the referencing concept and the linked concept?). If the SACM concepts map to UML things that aren't classifiers, then of course in the UML you cannot use associations because associations are relationships between classifiers.
In your original context-free problem description, you mapped the A and B concepts to UML Class. So, it is reasonable that the "ref" might map to UML Association. But maybe it should map to Dependency, Usage, Generalization, or any other kind of Relationship? Or just be modelled as an association between stereotypes in the profile as in my first reply? It depends on what "ref" actually means, on a case-by-case basis.
HTH,
Christian
|
|
| |
Re: Extending Associations in UML Profile [message #1754110 is a reply to message #1754106] |
Tue, 14 February 2017 14:52 |
|
Hi, Will,
In that case, the semantics of these reference in the SACM would seem to match the semantics of UML Association, so yes, you would probably want to use associations in your UML models.
Whether the profile needs a stereotype extending the Association metaclass is another question. If you need it to define constraints on the things that are associated, then probably the stereotype is useful (this is what several stereotypes in the UML-RT profile do, for example, that otherwise might not be needed). If all of these "refs" just map to UML Association, you may not need stereotypes for the associations. Their "SACM-ness" may be implied by the stereotypes of the associated classifiers. I cannot say whether or how many stereotypes you need for these associations in your UML models.
cW
|
|
|
Re: Extending Associations in UML Profile [message #1754218 is a reply to message #1754110] |
Wed, 15 February 2017 13:50 |
|
Hi Christian,
Could you please let me know how I connect a Stereotype that extends Association to Stereotypes that extend Class?
Let's assume I have two Stereotypes A and B that extend Class and a Stereotype "ref" that extends Association. How do I connect these in the UML profile?
Cheers,
Will
Research Associate
Department of Computer Science
University of York
|
|
|
Re: Extending Associations in UML Profile [message #1754224 is a reply to message #1754218] |
Wed, 15 February 2017 14:13 |
|
Hi, Will,
In the "ref" stereotype, you can add an OCL constraint (totally untested in any way):
context ref
-- the association must have a class stereotyped as <<A>> at an end
-- and a class stereotyped as <<B>> at an end
inv associates_A_and_B:
let classes = self.base_Association.endType->select(oclIsKindOf(Class)).oclAsType(Class) in
classes->exists(extension_A->notEmpty()) and classes->exists(extension_B->notEmpty())
HTH,
Christian
|
|
|
Re: Extending Associations in UML Profile [message #1754232 is a reply to message #1754224] |
Wed, 15 February 2017 15:13 |
|
Hi Christian,
I created a minimal example (attached to this thread), in this example, there are Flowchart and Node both extend Class, and there is "nodes" that extend Association, I tried using ocl expression:
let classes = self.base_Association.endType->select(t|t.oclIsKindOf(UML::Class)).oclAsType(UML::Class) in
classes->exists(f|f.oclIsKindOf(Flowchart)) and classes->exists(n|n.oclIsKindOf(Node))
However i got an exception when I try to validate a model that applies this profile:
org.eclipse.ocl.ecore.delegate.OCLDelegateException: 2:1:2:3 "let" unexpected token(s)
at org.eclipse.ocl.ecore.delegate.InvocationBehavior.getOperationBody(InvocationBehavior.java:118)
at org.eclipse.ocl.ecore.delegate.OCLValidationDelegate.validate(OCLValidationDelegate.java:90)
at org.eclipse.ocl.ecore.delegate.OCLValidationDelegateFactory.validate(OCLValidationDelegateFactory.java:81)
at org.eclipse.ocl.common.internal.delegate.OCLValidationDelegateMapping.validate(OCLValidationDelegateMapping.java:73)
at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObjectValidator.java:194)
at org.eclipse.emf.ecore.util.EObjectValidator$DynamicEClassValidator.validateDelegatedInvariants(EObjectValidator.java:1377)
at org.eclipse.emf.ecore.util.EObjectValidator$DynamicEClassValidator.validate(EObjectValidator.java:1416)
at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObjectValidator.java:333)
at org.eclipse.emf.ecore.util.Diagnostician.doValidate(Diagnostician.java:171)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:158)
at org.eclipse.uml2.uml.editor.presentation.UMLActionBarContributor$UMLValidateAction$1.validate(UMLActionBarContributor.java:884)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
at org.eclipse.uml2.uml.editor.presentation.UMLActionBarContributor$UMLValidateAction$1.doValidateStereotypeApplications(UMLActionBarContributor.java:852)
at org.eclipse.uml2.uml.editor.presentation.UMLActionBarContributor$UMLValidateAction$1.doValidateContents(UMLActionBarContributor.java:868)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:161)
at org.eclipse.uml2.uml.editor.presentation.UMLActionBarContributor$UMLValidateAction$1.validate(UMLActionBarContributor.java:884)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
at org.eclipse.emf.ecore.util.Diagnostician.doValidateContents(Diagnostician.java:185)
at org.eclipse.uml2.uml.editor.presentation.UMLActionBarContributor$UMLValidateAction$1.doValidateContents(UMLActionBarContributor.java:873)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:161)
at org.eclipse.uml2.uml.editor.presentation.UMLActionBarContributor$UMLValidateAction$1.validate(UMLActionBarContributor.java:884)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:108)
at org.eclipse.uml2.uml.editor.presentation.UMLActionBarContributor$UMLValidateAction.validate(UMLActionBarContributor.java:892)
at org.eclipse.emf.edit.ui.action.ValidateAction$1.run(ValidateAction.java:176)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
Caused by: org.eclipse.ocl.SyntaxException: 2:1:2:3 "let" unexpected token(s)
at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:350)
at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:322)
at org.eclipse.ocl.internal.helper.HelperUtil.checkForErrors(HelperUtil.java:512)
at org.eclipse.ocl.internal.helper.HelperUtil.parseBodyCondition(HelperUtil.java:279)
at org.eclipse.ocl.internal.helper.OCLHelperImpl.createBodyCondition(OCLHelperImpl.java:255)
at org.eclipse.ocl.ecore.OCLHelperImpl.createBodyCondition(OCLHelperImpl.java:54)
at org.eclipse.ocl.ecore.OCLHelperImpl.createBodyCondition(OCLHelperImpl.java:1)
at org.eclipse.ocl.ecore.delegate.InvocationBehavior.getOperationBody(InvocationBehavior.java:116)
... 25 more
Help pliz
Research Associate
Department of Computer Science
University of York
|
|
|
Re: Extending Associations in UML Profile [message #1754492 is a reply to message #1754232] |
Sat, 18 February 2017 18:06 |
|
Hi, William,
That's odd -- I am fairly certain that let expressions are supported in Eclipse OCL. Perhaps my memory of the OCL syntax is fuzzy: is the type of the let variable optional? Maybe it needs to be "let classes : Set(Class) = ... in ...". Probably best to ask about this problem on the OCL forum, anyways (not this Papyrus forum). The Ecore delegates support is an OCL thing, not a Papyrus thing.
But I can say that once you get past the let expression problem, the oclIsKindOf(Flowchart) and oclIsKindOf(Node) expressions will not work. Despite the visual similarity of the connections in the diagram, metaclass extensions are not generalization relationships but are in fact associations. You need to navigate the extension ends as I showed in my earlier reply. A class that has the Flowchart stereotype applied is not a kind of Flowchart; it is still only a Class.
Cheers,
Christian
|
|
| | | |
Re: Extending Associations in UML Profile [message #1754576 is a reply to message #1754569] |
Mon, 20 February 2017 13:25 |
|
Hi Ed,
My mistake, I have attached an example. In this example, project flowchart contains the UML profile, I created a Stereotype named nodes that extends Association. On nodes, I apply OCL:
let classes : Sequence(UML::Class) = self.base_Association.endType->select(t:UML::Class|t.oclIsKindOf(UML::Class)) in true
Then, in project flowchart.test, I created two classes Class1 and Node2 that applies their respective Stereotypes, I then created an Association and apply Stereotype nodes to it.
When you open the model.uml and validate it. I got another error saying that UML::Class is not a known type. Do you know why this is the case, please?
Cheers,
Will
Research Associate
Department of Computer Science
University of York
[Updated on: Mon, 20 February 2017 13:30] Report message to a moderator
|
|
| | |
Re: Extending Associations in UML Profile [message #1754868 is a reply to message #1754595] |
Thu, 23 February 2017 10:56 |
|
Hi Ed,
Thank you very much for your responses. I have managed to get the OCL working by using the following expression:
let classes = self.base_Association.endType->selectByKind(UML::Class) in classes->exists(c|c.extension_Flowchart->notEmpty()) and classes->exists(c|c.extension_Node -> notEmpty())
Cheers,
Will
Research Associate
Department of Computer Science
University of York
|
|
|
Goto Forum:
Current Time: Wed Jan 15 10:10:22 GMT 2025
Powered by FUDForum. Page generated in 0.03605 seconds
|