Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF model live OCL constraints
EMF model live OCL constraints [message #554407] Sun, 22 August 2010 20:46 Go to next message
Carl Pfeiffer is currently offline Carl PfeifferFriend
Messages: 3
Registered: February 2010
Junior Member
Hi Smile

I would like to add an OCL constraint to the already existing constraints dynamically. The constraint is entered as an XML constraint. I have tried parsing the OCL constraint, but no luck...

However, I have not found an appropriate solution for doing. Thus, I would be glad if anyone has a clue. Let me know! Smile

Cheers,

Carl
Re: EMF model live OCL constraints [message #554411 is a reply to message #554407] Sun, 22 August 2010 21:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Carl

Meta-models are not generally mutable. Certainly a model conforming to
an Ecore meta-model currently has to be reloaded if the meta-model
changes. The OCL delegate registries comply with this philosphy since
they use caches which are lazily computed on first access. Once
populated they won't recompute to capture your additional constraint.

I'm not quite sure what you mean by an XML constraint. I'm answering for
normal use of the OCL API.

The OCL caches are private so you can't reset them even using derived
implementations. You might manage to uninstall the delegates and install
new uninitialsed onces, but this code will be clunky and fragile
and likely to change once meta-model mutation is supported.

If this is a major problem, raise an MDT/OCL bugzilla motivating the change.

Regards

Ed Willink


On 22/08/2010 21:46, Carl Pfeiffer wrote:
> Hi :)
>
> I would like to add an OCL constraint to the already existing
> constraints dynamically. The constraint is entered as an XML constraint.
> I have tried parsing the OCL constraint, but no luck...
>
> However, I have not found an appropriate solution for doing. Thus, I
> would be glad if anyone has a clue. Let me know! :)
>
> Cheers,
>
> Carl
Re: EMF model live OCL constraints [message #554413 is a reply to message #554411] Sun, 22 August 2010 21:52 Go to previous messageGo to next message
Carl Pfeiffer is currently offline Carl PfeifferFriend
Messages: 3
Registered: February 2010
Junior Member
Hi Ed,

thanks for your reply Smile

By an XML constraint I was referring to the EMF validation constraint providers, where I can add a constraint as follows:

<extension point="org.eclipse.emf.validation.constraintProviders">
        <category name="Cospel constraints" id="emf-validation-example/adapter">
           Constraints on the Cospel model
        </category>
        <constraintProvider cache="true">
            <package namespaceUri="http:///cospel"/>
            <constraints categories="emf-validation-example/adapter">
                <constraint statusCode="12" severity="ERROR" lang="OCL" mode="Batch" name="SpecName must be foo" id="specnamefoo">
                    <description>Specification name must be foo</description>
                    <message>The Specification is not named foo</message>
                    <target class="Specification"/>
                    <!-- the OCL expression -->
                    <![CDATA[
                        name='foo'
                    ]]>
               </constraint>
            </constraints>
        </constraintProvider>
    </extension>


I was hoping that it would be possible to define these at runtime, since it would be great to be able to specify new constraints in the program rather than during the development of it.

I guess the constraints would in that case use the cache and encounter the difficulties you mentioned?

Cheers,

Carl
Re: EMF model live OCL constraints [message #554426 is a reply to message #554413] Mon, 23 August 2010 05:43 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I think that you will find that a Complete OCL document is a more
satisfactory way of defining constraints on a meta-model.

a) Complete OCL is an OMG standard
b) Complete OCL is readable
c) There is Complete OCL tooling
- an evolving Xtext-based editor in the MDT/OCL Examples
- a fuller but mature editor in M2M/QVTd.

Regards

Ed Willink


On 22/08/2010 22:52, Carl Pfeiffer wrote:
> Hi Ed,
>
> thanks for your reply :)
>
> By an XML constraint I was referring to the EMF validation constraint
> providers, where I can add a constraint as follows:
>
> <extension point="org.eclipse.emf.validation.constraintProviders">
> <category name="Cospel constraints" id="emf-validation-example/adapter">
> Constraints on the Cospel model
> </category>
> <constraintProvider cache="true">
> <package namespaceUri="http:///cospel"/>
> <constraints categories="emf-validation-example/adapter">
> <constraint statusCode="12" severity="ERROR" lang="OCL" mode="Batch"
> name="SpecName must be foo" id="specnamefoo">
> <description>Specification name must be foo</description>
> <message>The Specification is not named foo</message>
> <target class="Specification"/>
> <!-- the OCL expression -->
> <![CDATA[
> name='foo'
> ]]>
> </constraint>
> </constraints>
> </constraintProvider>
> </extension>
>
> I was hoping that it would be possible to define these at runtime, since
> it would be great to be able to specify new constraints in the program
> rather than during the development of it.
>
> I guess the constraints would in that case use the cache and encounter
> the difficulties you mentioned?
>
> Cheers,
>
> Carl
Previous Topic:XMLResource serialization of cross-resource references vs. schema conformity
Next Topic:Validation produces Duplicate EModelElement without reason
Goto Forum:
  


Current Time: Thu Apr 25 06:05:17 GMT 2024

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

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

Back to the top