Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Extending Associations in UML Profile
Extending Associations in UML Profile [message #1754089] Tue, 14 February 2017 13:10 Go to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 111
Registered: September 2012
Location: York, UK
Senior Member
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 #1754091 is a reply to message #1754089] Tue, 14 February 2017 13:27 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1199
Registered: July 2009
Location: Canada
Senior Member

No, you were told wrong. A stereotype of the Association metaclass is applied to associations in the UML model to which the profile is applied.

Just draw an association between your stereotypes.

HTH,

Christian
Re: Extending Associations in UML Profile [message #1754094 is a reply to message #1754091] Tue, 14 February 2017 13:39 Go to previous messageGo to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 111
Registered: September 2012
Location: York, UK
Senior Member
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 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1199
Registered: July 2009
Location: Canada
Senior Member

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 Go to previous messageGo to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 111
Registered: September 2012
Location: York, UK
Senior Member
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 #1754104 is a reply to message #1754099] Tue, 14 February 2017 14:36 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1199
Registered: July 2009
Location: Canada
Senior Member

Hi, Will,

I don't know anything about the SACM, which shouldn't be surprising
Re: Extending Associations in UML Profile [message #1754105 is a reply to message #1754104] Tue, 14 February 2017 14:43 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1199
Registered: July 2009
Location: Canada
Senior Member

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 #1754106 is a reply to message #1754104] Tue, 14 February 2017 14:44 Go to previous messageGo to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 111
Registered: September 2012
Location: York, UK
Senior Member
Hi Christian,

No worries Very Happy

Basically I am creating a metamodel using UML profiling. So the "ref" in the metamodel should be containment/non-containment references. Would you recommend using Stereotypes that extend Association to model these references?

Cheers,
Will


Research Associate
Department of Computer Science
University of York
Re: Extending Associations in UML Profile [message #1754110 is a reply to message #1754106] Tue, 14 February 2017 14:52 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1199
Registered: July 2009
Location: Canada
Senior Member

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 Go to previous messageGo to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 111
Registered: September 2012
Location: York, UK
Senior Member
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 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1199
Registered: July 2009
Location: Canada
Senior Member

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 Go to previous messageGo to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 111
Registered: September 2012
Location: York, UK
Senior Member
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 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1199
Registered: July 2009
Location: Canada
Senior Member

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 #1754503 is a reply to message #1754492] Sun, 19 February 2017 07:55 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6566
Registered: July 2009
Senior Member
Hi

let expressions are certainly supported in both the Classic Eclipse OCL and the new Pivot-based OCL. Only the new Pivot-based allows the type of the let variable to be inferred from its initializer.

Papyrus uses the Pivot-based OCL thoughout its UI operations and uses only the primary OCL embedded in the UML rather than the secondary OCL embedded in the EPackages with which UML2Ecore synthesizes stereotyped. The "org.eclipse.ocl.ecore.delegate.OCLDelegateException" shows that somehow you are using the Classic Eclipse OCL. The two should co-exist so can you please post a repro.

Regards

Ed Willink
Re: Extending Associations in UML Profile [message #1754568 is a reply to message #1754503] Mon, 20 February 2017 11:23 Go to previous messageGo to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 111
Registered: September 2012
Location: York, UK
Senior Member
Hi Ed,

I have attached a example project above, could you locate it?

Cheers,
Will


Research Associate
Department of Computer Science
University of York
Re: Extending Associations in UML Profile [message #1754569 is a reply to message #1754568] Mon, 20 February 2017 11:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6566
Registered: July 2009
Senior Member
Hi

Found the attachment but:

"However i got an exception when I try to validate a model that applies this profile:"

suggests a repro involves a model as well as a profile.

Regards

Ed Willink
Re: Extending Associations in UML Profile [message #1754576 is a reply to message #1754569] Mon, 20 February 2017 13:25 Go to previous messageGo to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 111
Registered: September 2012
Location: York, UK
Senior Member
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 #1754581 is a reply to message #1754576] Mon, 20 February 2017 14:30 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6566
Registered: July 2009
Senior Member
Hi

Thanks.

Use of the new/old Eclipse OCL is controlled by the "Window->Preferences->OCL Executor targetted by the default OCL delegate" option. For compatibility this is still the old OCL. Papyrus could/should override this preference when validating within Papyrus.

Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=512428 raised.

When validating within the UML model editor, you must set it right yourself.

When I use the Pivot OCL for validation I get:

org.eclipse.ocl.pivot.internal.delegate.OCLDelegateException: The 'LetVariable::CompatibleTypeForInitializer' constraint is violated for 'classes : Sequence(UML::Class) = self.base_Association.endType->select(t : UML::Class[1] | t.oclIsKindOf(UML::Class))'
The 'IteratorExp::IteratorTypeIsSourceElementType' constraint is violated for 'self.base_Association.endType->select(t : UML::Class[1] | t.oclIsKindOf(UML::Class))'
...

which is entirely correct. You have provided a redundant iterator type that is incompatible with the source type of UML::TYpe.

Some of your constraints could be simplified by exploiting->selectByKind(UML::Class)

Your undefined Class issues are due to omission of UML::

If you edit the problem constraints, you will see a yellow squiggle for the warning. Unfortunately the UI has no end of line decorations where the hover text would show the associated text easily, so you need to however over a bland bit of the squiggle that has no contextual hovertext.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=512431 raised.

If you validate the profile diagram you will find many OCL errors, whose details are missing.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=512430 raised.

Some confuse me, if they confuse you too, raise a Bugzilla.

Solution/workaround.

a) cure the OCL warnings/errors that appear in the editors.
b) set the OCL delegation preference to .../Pivot

Regards

Ed Willink
Re: Extending Associations in UML Profile [message #1754595 is a reply to message #1754581] Mon, 20 February 2017 16:25 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6566
Registered: July 2009
Senior Member
Ed Willink wrote on Mon, 20 February 2017 09:30
Some confuse me, if they confuse you too, raise a Bugzilla.


Spurious diagnosis that invocationDelegates are required: https://bugs.eclipse.org/bugs/show_bug.cgi?id=512448

Diagnosis of stale stereotypes: https://bugs.eclipse.org/bugs/show_bug.cgi?id=512449

Regards

Ed Willink
Re: Extending Associations in UML Profile [message #1754868 is a reply to message #1754595] Thu, 23 February 2017 10:56 Go to previous message
Ran Wei is currently offline Ran WeiFriend
Messages: 111
Registered: September 2012
Location: York, UK
Senior Member
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
Previous Topic:Linking Class Diagrams to Activity Diagrams
Next Topic:Applying OCL on UML profiles
Goto Forum:
  


Current Time: Sun Jan 19 04:38:16 GMT 2020

Powered by FUDForum. Page generated in 0.03773 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top