Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Validation errors with multiple bidirectional containment references(Validation errors with multiple bidirectional containment references)
Validation errors with multiple bidirectional containment references [message #525342] Tue, 06 April 2010 05:56 Go to next message
Henning Groenda is currently offline Henning GroendaFriend
Messages: 11
Registered: July 2009
Junior Member
Hi,

if i have a class A which is contained via bidirectional references (-1--*->)into the classes B and C (on the type level; Of course, on instance level only one containment makes sense) validation fails for at least one of the containment relations.
How can i achieve that such validation errors do not occur if one containment relation holds? Not using containment is not considered a solution.

Thanks for your feedback!
Re: Validation errors with multiple bidirectional containment references [message #525359 is a reply to message #525342] Tue, 06 April 2010 07:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Groenda,

What exactly is the validation failure?


groenda@fzi.de wrote:
> Hi,
>
> if i have a class A which is contained via bidirectional references
> (-1--*->)into the classes B and C (on the type level; Of course, on
> instance level only one containment makes sense) validation fails for
> at least one of the containment relations. How can i achieve that such
> validation errors do not occur if one containment relation holds? Not
> using containment is not considered a solution.
>
> Thanks for your feedback!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Validation errors with multiple bidirectional containment references [message #525389 is a reply to message #525359] Tue, 06 April 2010 13:00 Go to previous messageGo to next message
Henning Groenda is currently offline Henning GroendaFriend
Messages: 11
Registered: July 2009
Junior Member
Hi Ed,

i referred to the part of the model generation which provides for example the 'Validate'-functionality in the menu (via ValidateAction()) within the (generated) editor. As far as i know it uses the Diagnostic-related classes within org.eclipse.emf.ecore.util to diagnose errors or warnings of EObjects. I guessed that it uses the EMF Validation framework, however i am not sure of that.

Background: I used an ecore and EMF generator model to create the model-, edit-, editor-, and test-plugin for the model described in my initial post. When i create a model element in the editor and run validation it provides the error message that the required feature of class A must be set (for the containment-relation which does not hold). I just used the editor as it was easier. As far as i know i didn't use any features which were not available in 'pure' EMF.

Thanks for your help,
Henning
Re: Validation errors with multiple bidirectional containment references [message #525547 is a reply to message #525389] Tue, 06 April 2010 20:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Henning,

Comments below.

groenda@fzi.de wrote:
> Hi Ed,
>
> i referred to the part of the model generation which provides for
> example the 'Validate'-functionality in the menu (via
> ValidateAction()) within the (generated) editor. As far as i know it
> uses the Diagnostic-related classes within org.eclipse.emf.ecore.util
> to diagnose errors or warnings of EObjects. I guessed that it uses the
> EMF Validation framework, however i am not sure of that.
Yes, but I still don't know exactly what you're taking issue with...
>
> Background: I used an ecore and EMF generator model to create the
> model-, edit-, editor-, and test-plugin for the model described in my
> initial post. When i create a model element in the editor and run
> validation it provides the error message that the required feature of
> class A must be set (for the containment-relation which does not hold).
So you have a feature for which the lower bound is >= 1? You've
specified that it must be set. If that's not the case, then make the
lower bound be zero.
> I just used the editor as it was easier. As far as i know i didn't use
> any features which were not available in 'pure' EMF.
>
> Thanks for your help,
> Henning


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Validation errors with multiple bidirectional containment references [message #525898 is a reply to message #525547] Thu, 08 April 2010 08:35 Go to previous messageGo to next message
Henning Groenda is currently offline Henning GroendaFriend
Messages: 11
Registered: July 2009
Junior Member
Hi Ed,

i haven't thought of a containment relation with [0..1] as bounds for the containment. Somehow i assumed it to be always one. Thanks to your help everything work fine now!

Two containment relations with the bound [1] on the source element and the same target element cannot be fulfilled, right? It would have helped me a lot if a got a according error message during EMF model generation. I assumed the model was correct and that there was an validation error because it is obvious that only one containment relation can hold for the instance of an element. A message during generation helps in finding the error faster than if i have to instantiate the element and the earlier error message could help by giving a hint at the bounds.

Thank you again for help,
Henning
Re: Validation errors with multiple bidirectional containment references [message #525931 is a reply to message #525898] Thu, 08 April 2010 10:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Henning,

Comments below.

groenda@fzi.de wrote:
> Hi Ed,
>
> i haven't thought of a containment relation with [0..1] as bounds for
> the containment. Somehow i assumed it to be always one. Thanks to your
> help everything work fine now!
>
> Two containment relations with the bound [1] on the source element
> and the same target element cannot be fulfilled, right?
Not by the same instance object.
> It would have helped me a lot if a got a according error message
> during EMF model generation.
What you've described so far doesn't appear to fit in that category though.
> I assumed the model was correct and that there was an validation error
> because it is obvious that only one containment relation can hold for
> the instance of an element. A message during generation helps in
> finding the error faster than if i have to instantiate the element and
> the earlier error message could help by giving a hint at the bounds.
Are you really talking containment references or container references.
I suspect the latter...
>
> Thank you again for help,
> Henning


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Validation errors with multiple bidirectional containment references [message #525951 is a reply to message #525931] Thu, 08 April 2010 11:43 Go to previous messageGo to next message
Henning Groenda is currently offline Henning GroendaFriend
Messages: 11
Registered: July 2009
Junior Member
Hi Ed,

Comments below.

> > Two containment relations with the bound [1] on the source element
> > and the same target element cannot be fulfilled, right?
> Not by the same instance object.
Which would lead for a model with bidirectional containment references A-1--*->B and C-1--*->B to the fact that B cannot be instantiated correctly. The problem ist definitely with the model but an according early error reporting would be nice for elements which are bidirectionally contained with 'source' bound 1 in more than one reference.
> > It would have helped me a lot if a got a according error message
> > during EMF model generation.
> What you've described so far doesn't appear to fit in that category though.
I hope i could point out my original intentions above.
> > I assumed the model was correct and that there was an validation error
> > because it is obvious that only one containment relation can hold for
> > the instance of an element. A message during generation helps in
> > finding the error faster than if i have to instantiate the element and
> > the earlier error message could help by giving a hint at the bounds.
> Are you really talking containment references or container references.
> I suspect the latter...
Most probably, but in my terms the container reference would mean the referenced EObject,e.g. for an established bidirectional containment reference for an instance EObject. A bidirectional containment reference with 'source' bound 1 would automatically imply a container reference. Hence, i assumed that if the model is not considered invalid it is okay for object instances that exactly one of the bidirectional containment references with 'source' bound 1 hold (and the other references are not considered anymore).
Re: Validation errors with multiple bidirectional containment references [message #525979 is a reply to message #525951] Thu, 08 April 2010 12:47 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Henning,

Comments below.


groenda@fzi.de wrote:
> Hi Ed,
>
> Comments below.
>
>> > Two containment relations with the bound [1] on the source element
>> > and the same target element cannot be fulfilled, right?
>> Not by the same instance object.
> Which would lead for a model with bidirectional containment
> references A-1--*->B and C-1--*->B to the fact that B cannot be
> instantiated correctly. The problem ist definitely with the model but
> an according early error reporting would be nice for elements which
> are bidirectionally contained with 'source' bound 1 in more than one
> reference.
Even if only one container reference is defined for B, any other
containment references with B as a target, even ones without an opposite
and hence not necessarily known to B, will still imply a problem should
a B instance ever be added to any other containment reference.
>> > It would have helped me a lot if a got a according error message
>> > during EMF model generation.
>> What you've described so far doesn't appear to fit in that category
>> though.
> I hope i could point out my original intentions above.
>> > I assumed the model was correct and that there was an validation error
>> > because it is obvious that only one containment relation can hold for
>> > the instance of an element. A message during generation helps in
>> > finding the error faster than if i have to instantiate the element and
>> > the earlier error message could help by giving a hint at the bounds.
>> Are you really talking containment references or container references.
>> I suspect the latter...
> Most probably, but in my terms the container reference would mean the
> referenced EObject,e.g. for an established bidirectional containment
> reference for an instance EObject. A bidirectional containment
> reference with 'source' bound 1 would automatically imply a container
> reference. Hence, i assumed that if the model is not considered
> invalid it is okay for object instances that exactly one of the
> bidirectional containment references with 'source' bound 1 hold (and
> the other references are not considered anymore).
Wrong assumption.

We could add a constraint to Ecore. Perhaps the best way to specify it
would be to say that for any containment EReference x to an EClass X,
there must but no container reference y on X with lower bound 1 except
if y is x's opposite. This captures the case I mentioned above where
any other non-bidirectional containment reference to X will necessarily
cause a problem if X is required to be contained by something else.
Feel free to open a bugzilla for that.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:How to modify the EMF model?
Next Topic:[Announce] Webinar on CDO - Apr. 29
Goto Forum:
  


Current Time: Wed Apr 24 23:48:52 GMT 2024

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

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

Back to the top