Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » choosing "Property::CompatibleDefaultExpression" for programmatically defined pivot types
choosing "Property::CompatibleDefaultExpression" for programmatically defined pivot types [message #1748493] Wed, 23 November 2016 15:27 Go to next message
Julien DeAntoni is currently offline Julien DeAntoniFriend
Messages: 43
Registered: July 2009
Member
Hi,

I'm extending the CompleteOCL grammar with some concepts amongst which a new "Event" type.
I implmented the visitors so that the parsing is almost ok. The problem I have comes from the Continuation of the post order of this Event Type. I have to install the pivot and I wanted to map it to a new OCLAny type (to be compliant with any type of body specification in a PropertyDefinition).
If I use the OCLAny type, it is OK:
AnyType anyType = context.getEnvironmentFactory().getStandardLibrary().getOclAnyType();
csElement.setPivot(anyType);


However, if I try to create a new OCLAny type if filas (even if I tried to copy the properties of the anyType):
AnyType anyType = context.getEnvironmentFactory().getStandardLibrary().getOclAnyType();
AnyType eventType = new PivotFactoryImpl().createAnyType();
eventType.setName("Event");
eventType.setOwningPackage(anyType.getOwningPackage());
eventType.setOwnedSignature(anyType.getOwnedSignature());
eventType.setUnspecializedElement(anyType.getUnspecializedElement());
eventType.setIsAbstract(anyType.isIsAbstract());
eventType.setIsActive(anyType.isIsActive());
eventType.getSuperClasses().addAll(anyType.getSuperClasses());
eventType.getOwnedBehaviors().addAll(anyType.getOwnedBehaviors());
eventType.getOwnedOperations().addAll(anyType.getOwnedOperations());
eventType.getExtenders().addAll(anyType.getExtenders());
csElement.setPivot(eventType);

I this last case I have a warning in the editor, for instance when trying to define a def of Event type:
The 'Property::CompatibleDefaultExpression' constraint is violated for xxxx 


any idea on how to define the default compatibility ?

Re: choosing "Property::CompatibleDefaultExpression" for programmatically defined pivot ty [message #1748502 is a reply to message #1748493] Wed, 23 November 2016 16:38 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5520
Registered: July 2009
Senior Member
Hi Julien

Re-using one type e.g AnyType as a new semantic type seems to be very pragmatic; it may save you time today, but it will make life very difficult in the future. Even today you ask me why your code doesn't work. I cannot help without a fully executable repro.

The general Pivot OCL philosophy is that each semantically distinct type has a distinct metamodel class. (On GIT/master this has driven me to introducing derived LetVariable/IteratorVariable/ParameterVariable/ResultVariable to avoid the WFRs of Variable having to discover their context before using a case switch.)

I recommend that you emulate one of the QVTd extensions for which many lack of extensibility bugs have been fixed in OCL. QVTimperative is most independent.

[I find the Complete OCL syntax very unsatisfactory - insufficient keywords, no {}'s or ;'s to help error recovery..]

Regards

Ed Willink
Previous Topic:Performing queries in KDM with OCL
Next Topic:pre and post conditions in OCL metamodel
Goto Forum:
  


Current Time: Tue Dec 12 10:40:04 GMT 2017

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

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