Home » Modeling » OCL » Using OCL with EMF Profiles(Evaluate OCL constraints on a Stereotyped Ecore Model with EMF Profiles)
|
Re: Using OCL with EMF Profiles [message #1702249 is a reply to message #1702208] |
Tue, 21 July 2015 04:25 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
What is an EMF Profile? Certainly not part of Ecore. I presume it is
something that you or a new project have added/are adding.
Profiles and Stereotypes are very underspecified for OCL and so the
implementation relies on implementation magic.
The Classic OCL approach of using Ecore/UML specialization with long
template argument lists is almost certainly going to need revision to
offer UML-like facilities not available with Ecore.
The new Pivot OCL approach has a shared pivot that supports profiles and
stereotypes, so you just need to extend the Ecore2AS loader to recognize
whatever Ecore extensions are in use to represent profiles.
So long as EMF profiles are not part of Ecore, the extension will have
to be an optional extension to Ecore, so that OCL continues to work with
Ecore alone.
In principle a variant of the extension point that makes UML optional
should enable some *.ecore++ support:
<extension point="org.eclipse.ocl.pivot.as_resource_factory">
<factory
class="org.eclipse.ocl.pivot.uml.internal.resource.UMLASResourceFactory"
extension="uml" contentType="org.eclipse.ocl.oclas.uml"
externalPriority="200"
resourceClass="org.eclipse.uml2.uml.resource.UMLResource"/>
</extension>
In practice, there will almost certaonly need to be some care with
meta-namespaces.
Ecore is coherent. http://www.eclipse.org/emf/2002/Ecore for Ecore and
http://www.eclipse.org/emf/2002/Ecore for its metamodel.
OMG UML is coherent. http://www.omg.org/spec/... for UML and
http://www.omg.org/spec/... for its metamodel.
Pivot OCL is coherent. http://www.eclipse.org/ocl/2015/Pivot for OCL and
http://www.eclipse.org/ocl/2015/Pivot for its metamodel.
However since stereotypes constraints are written against the metamodel
Eclipse UML2 requires special handling to accommodate:
http://www.eclipse.org/uml2/5.0.0/UML for UML but
{http://www.eclipse.org/emf/2002/Ecore,
http://www.eclipse.org/uml2/5.0.0/UML, http://www.omg.org/spec/...}
You may need similar special handling to accommodate a dual metamodel,
but this should at least be easier than a triple metamodel.
Regards
Ed Willink
On 20/07/2015 19:37, Daria Giacinto wrote:
> Hello,
>
> I am trying to evaluate programmatically OCL constraints on models
> defined by an own Ecore meta model that is extended by EMF profiles . I
> implemented it regarding the Eclipse OCL documentation in Eclipse Mars
> Modeling Tools. It works in the restriced context of the stereotype
> application and the extended class when I set :
>
> OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint>
> helper = ocl.createOCLHelper();
> helper.setInstanceContext(stereotypeApplication); or
> helper.setContext(stereotypeApplication.getExtension().getTarget());
>
> However, I cannot navigate from the StereotypeApplication to the
> extended Class.
> E.g.: Defining a constraint: invariant =
> helper.createInvariant('self.appliedTo.entityName'); or
> invariant = helper.createInvariant('self.extension.target.entityName');
> (appliedTo is the reference to the EObject and extension.target is the
> reference to the extended class)
> Query constraintEvaluation = ocl.createQuery(invariant);
>
> Check constraint:
> constraintEvaluation.check(stereotypeApplication);
>
> returns an Unrecognized variable: entityName
>
> I was looking at customizing the environment and the pivot programmers
> guide but I am unsure how I can achieve that the stereotypes are
> included in the OCL constraint validation. Do I have to register the
> profiles? Or do I have to extend specific OCL classes? I would
> appreciate some hints in which direction I should go as I am not
> experienced in OCL programming.
>
> Thank you,
>
> Daria
>
>
|
|
|
Re: Using OCL with EMF Profiles [message #1702916 is a reply to message #1702249] |
Mon, 27 July 2015 11:16 |
Daria Giacinto Messages: 7 Registered: July 2015 |
Junior Member |
|
|
Thanks for your answer.
EMF profiles provide a meta model to extend an own ecore-based meta model. So, you can define profiles with stereotypes that extend a particular class of our meta-model. Afterwards, you can annotate a model element with such stereotype, i.e., a stereotype application is created that has a reference to this model element. When I set the context of the OCL helper to the stereotype application, I can only access properties of the applied model element by the use of an explicit type cast (oclAsType(appliedModelElement) . However, I also want to check whether a model element has a particular StereotypeApplication but currently they are not recognized, e.g., when I use oclIsTypeOf(StereotypeApplication).
Quote:The new Pivot OCL approach has a shared pivot that supports profiles and
stereotypes, so you just need to extend the Ecore2AS loader to recognize
whatever Ecore extensions are in use to represent profiles.
What do I have to extend specifically from the Ecore2AS class in order that the stereotypes can be recognized? Are there examples available?
Or do I have to provide a metamodel binding, i.e., implement interfaces like Environment, EnvironmentFactory, EvaluationEnvironment as explained in the OCL Eclipse documentation (Classic Ecore Programmers Guide - Creating Metamodels Binding)?
My other idea is to customize the EcoreEnvironment and add a helper operation in Java to check whether a stereotype is applied. Would you recommend this approach?
Best regards
Daria
|
|
|
Re: Using OCL with EMF Profiles [message #1702921 is a reply to message #1702916] |
Mon, 27 July 2015 11:48 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
You seem to be a user hoping that something might work. You need the
OCL/EMF Profiles developers to do their job properly.
It would appear that EMF Profiles has given no consideration to OCL and
so you are in trouble.
Conversely EMF Profiles is not an Eclipse project and so Eclipse OCL has
no support.
You need to get the EMF Profiles developers to consider how they can
contribute to the larger Eclipse eco-system.
Regards
Ed Willink
On 27/07/2015 12:16, Daria Giacinto wrote:
> Thanks for your answer.
>
> EMF profiles provide a meta model to extend an own ecore-based meta
> model. So, you can define profiles with stereotypes that extend a
> particular class of our meta-model. Afterwards, you can annotate a
> model element with such stereotype, i.e., a stereotype application is
> created that has a reference to this model element. When I set the
> context of the OCL helper to the stereotype application, I can only
> access properties of the applied model element by the use of an
> explicit type cast (oclAsType(appliedModelElement) . However, I also
> want to check whether a model element has a particular
> StereotypeApplication but currently they are not recognized, e.g.,
> when I use oclIsTypeOf(StereotypeApplication).
> Quote:
>> The new Pivot OCL approach has a shared pivot that supports profiles
>> and stereotypes, so you just need to extend the Ecore2AS loader to
>> recognize whatever Ecore extensions are in use to represent profiles.
>
>
> What do I have to extend specifically from the Ecore2AS class in order
> that the stereotypes can be recognized? Are there examples available?
> Or do I have to provide a metamodel binding, i.e., implement
> interfaces like Environment, EnvironmentFactory, EvaluationEnvironment
> as explained in the OCL Eclipse documentation (Classic Ecore
> Programmers Guide - Creating Metamodels Binding)?
>
> My other idea is to customize the EcoreEnvironment and add a helper
> operation in Java to check whether a stereotype is applied. Would you
> recommend this approach?
>
> Best regards
> Daria
|
|
|
Re: Using OCL with EMF Profiles [message #1703046 is a reply to message #1702921] |
Tue, 28 July 2015 09:54 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
After googling EMF Profiles, it appears that
EMF Profiles has moved from EclipseLabs (deprecated) to GitHub (good)
EMF Profiles has had no commits for 2 years (worrying)
EMF Profiles installs and appears to run on Mars (good)
EMF Profiles provides no examples/tests demonstrating the EAnnotations (bad)
The tests demonstrating Profiles show an extension Ecore model strangely
embedded within a diagram.
Since there is a new model, it cannot be supported within Eclipse OCL.
But EMF Profiles already has a dependency on Eclipse OCL, so there
should be no problem in providing the required add-on functionality
within EMF Profiles.
Without any examples, I cannot be sure, but it is probably sufficient to
define a higher priority variant of
<extension point="org.eclipse.ocl.pivot.as_resource_factory">
<factory
class="org.eclipse.ocl.pivot.internal.ecore.EcoreASResourceFactory"
extension="ecore" contentType="org.eclipse.ocl.oclas.ecore"
externalPriority="100"/>
</extension>
that inspects the *.,ecore to see whether the EMF Profile overload of
org.eclipse.ocl.pivot.internal.ecore.EcoreASResourceFactory is needed to
redirect the Ecore2AS conversion to the EMF Profile overload of
org.eclipse.ocl.pivot.internal.ecore.es2as.Ecore2AS and friends.
The overloads need to ensure that EMF Profole's Stereotype etc are
converted to org.eclipse.ocl.pivot.Stereotype etc.
Regards
Ed Willink
On 27/07/2015 12:48, Ed Willink wrote:
> Hi
>
> You seem to be a user hoping that something might work. You need the
> OCL/EMF Profiles developers to do their job properly.
>
> It would appear that EMF Profiles has given no consideration to OCL
> and so you are in trouble.
>
> Conversely EMF Profiles is not an Eclipse project and so Eclipse OCL
> has no support.
>
> You need to get the EMF Profiles developers to consider how they can
> contribute to the larger Eclipse eco-system.
>
> Regards
>
> Ed Willink
>
>
> On 27/07/2015 12:16, Daria Giacinto wrote:
>> Thanks for your answer.
>>
>> EMF profiles provide a meta model to extend an own ecore-based meta
>> model. So, you can define profiles with stereotypes that extend a
>> particular class of our meta-model. Afterwards, you can annotate a
>> model element with such stereotype, i.e., a stereotype application is
>> created that has a reference to this model element. When I set the
>> context of the OCL helper to the stereotype application, I can only
>> access properties of the applied model element by the use of an
>> explicit type cast (oclAsType(appliedModelElement) . However, I also
>> want to check whether a model element has a particular
>> StereotypeApplication but currently they are not recognized, e.g.,
>> when I use oclIsTypeOf(StereotypeApplication).
>> Quote:
>>> The new Pivot OCL approach has a shared pivot that supports profiles
>>> and stereotypes, so you just need to extend the Ecore2AS loader to
>>> recognize whatever Ecore extensions are in use to represent profiles.
>>
>>
>> What do I have to extend specifically from the Ecore2AS class in
>> order that the stereotypes can be recognized? Are there examples
>> available?
>> Or do I have to provide a metamodel binding, i.e., implement
>> interfaces like Environment, EnvironmentFactory,
>> EvaluationEnvironment as explained in the OCL Eclipse documentation
>> (Classic Ecore Programmers Guide - Creating Metamodels Binding)?
>>
>> My other idea is to customize the EcoreEnvironment and add a helper
>> operation in Java to check whether a stereotype is applied. Would you
>> recommend this approach?
>>
>> Best regards
>> Daria
>
|
|
| | | | | | | | |
Goto Forum:
Current Time: Tue Sep 24 05:17:40 GMT 2024
Powered by FUDForum. Page generated in 0.04707 seconds
|