Home » Modeling » EMF » Mapping EObject Objects to Diagnostic Objects
Mapping EObject Objects to Diagnostic Objects [message #423994] |
Mon, 13 October 2008 17:57 |
Felix Dorner Messages: 676 Registered: July 2009 |
Senior Member |
|
|
Hey,
I have read the (too short, but 1000 times better than nothing) chapter
on EMF Validation in the Rough Cuts Book, and have a small doubt, please
correct if I make wrong assumptions.
I call Diagnostician.eINSTANCE.validate(myContainmentRoot), to validate
my whole model which gives me a tree-like structure consisting of
Diagnostic objects.
From a certain Diagnostic object, I can then get the involved model
object(s) via the Diagnostic's getData() method.
I'd rather like to have a Map<EObject,List<Diagnostic>>, which would map
a given eObject to all the Diagnostic's it is involved (i.e. its
getData() contains the eObject).
Is something like this available through the framework, or do I need to
manually compute the Map based on the Diagnostic tree?
What's the role of the "context" map argument in the Diagnostician's
validate() methods? Unfortunately there's no information in the Javadoc.
Thanks,
Felix
|
|
|
Re: Mapping EObject Objects to Diagnostic Objects [message #424003 is a reply to message #423994] |
Tue, 14 October 2008 08:06 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
> Felix
Felix Dorner wrote:
> Hey,
>
> I have read the (too short, but 1000 times better than nothing)
> chapter on EMF Validation in the Rough Cuts Book, and have a small
> doubt, please correct if I make wrong assumptions.
>
> I call Diagnostician.eINSTANCE.validate(myContainmentRoot), to
> validate my whole model which gives me a tree-like structure
> consisting of Diagnostic objects.
>
> From a certain Diagnostic object, I can then get the involved model
> object(s) via the Diagnostic's getData() method.
>
> I'd rather like to have a Map<EObject,List<Diagnostic>>, which would
> map a given eObject to all the Diagnostic's it is involved (i.e. its
> getData() contains the eObject).
>
> Is something like this available through the framework, or do I need
> to manually compute the Map based on the Diagnostic tree?
>
>
> What's the role of the "context" map argument in the Diagnostician's
> validate() methods? Unfortunately there's no information in the Javadoc.
>
>
> Thanks,
> Felix
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Mapping EObject Objects to Diagnostic Objects [message #424004 is a reply to message #424003] |
Tue, 14 October 2008 08:10 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Felix,
Oops, wrong button. :-P
Comments below.
Ed Merks wrote:
>> Felix
>
>
> Felix Dorner wrote:
>> Hey,
>>
>> I have read the (too short, but 1000 times better than nothing)
>> chapter on EMF Validation in the Rough Cuts Book, and have a small
>> doubt, please correct if I make wrong assumptions.
Too short! If these things were longer, Dave would have taken another
year!!
>>
>> I call Diagnostician.eINSTANCE.validate(myContainmentRoot), to
>> validate my whole model which gives me a tree-like structure
>> consisting of Diagnostic objects.
>>
>> From a certain Diagnostic object, I can then get the involved model
>> object(s) via the Diagnostic's getData() method.
>>
>> I'd rather like to have a Map<EObject,List<Diagnostic>>, which would
>> map a given eObject to all the Diagnostic's it is involved (i.e. its
>> getData() contains the eObject).
Sounds like a a helper method you could write...
>>
>> Is something like this available through the framework, or do I need
>> to manually compute the Map based on the Diagnostic tree?
Manually.
>>
>>
>> What's the role of the "context" map argument in the Diagnostician's
>> validate() methods? Unfortunately there's no information in the Javadoc.
Generally it's a place where complex constraints can cache information
so that expensive computations don't need to be duplicated across
several constraint that might need the same information.
>>
>>
>> Thanks,
>> Felix
>>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: Mapping EObject Objects to Diagnostic Objects [message #424033 is a reply to message #424032] |
Tue, 14 October 2008 20:12 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Felix,
Comments below.
Felix Dorner wrote:
> Hey Ed,
>
>>>> What's the role of the "context" map argument in the
>>>> Diagnostician's validate() methods? Unfortunately there's no
>>>> information in the Javadoc.
>> Generally it's a place where complex constraints can cache
>> information so that expensive computations don't need to be
>> duplicated across several constraint that might need the same
>> information.
>
> Mhm, ok, so it's content is completely "free for all", i.e. Framework
> Code doesn't look/expect anything from it?).
Pretty much. Diagnostic doesn't even know about Ecore and the
validators. Generally though the first object in the data will identify
the source of the issue.
>
> In my application, it however doesn't end with a message "Uh, your
> model is broken, fix it!".
That would be a bit unhelpful. :-P It should describe what's wrong.
> I'd like to provide users with Diagnostic dependent suggestions on how
> to fix an issue. Can I use the "code" field to give a diagnostic a
> semantics?
Between the source and the code it should generally uniquely identify a
"type of problem".
> Or is that meant for something else?
You can see how EObjectValidator and EcoreValidator use it...
>
>
> Thanks a thousand times,
> Felix
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Goto Forum:
Current Time: Wed Sep 18 19:19:56 GMT 2024
Powered by FUDForum. Page generated in 0.03977 seconds
|