Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Validating an EMF model programatically
Validating an EMF model programatically [message #535591] Mon, 24 May 2010 18:42 Go to next message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
I was going over the EMF Validation Framework example and I was able to set everything up and add a few extra constraints. Then I run the plugin as an eclipse application, I create the model and then in the editor menu I can select validate to check the constraints and everything works fine.

But I was wondering if it is possible to validate a model programmatically, without using the editor.

// For example, create a few objects:

Book myBook = EXTLibraryFactory.eINSTANCE.createBook();
myBook.setTitle("EMF Validation");
Writer writer = EXTLibraryFactory.eINSTANCE.createWriter();
writer.setName("Hector");

//And then do the validation

I've been searching the web with no luck. Can something like this be done? I would appreciate any hints.

Thanks.
Re: Validating an EMF model programatically [message #535602 is a reply to message #535591] Mon, 24 May 2010 19:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Diagnostician.INSTANCE can be used to check the core constraints.


Hector Chavez wrote:
> I was going over the EMF Validation Framework example and I was able
> to set everything up and add a few extra constraints. Then I run the
> plugin as an eclipse application, I create the model and then in the
> editor menu I can select validate to check the constraints and
> everything works fine.
> But I was wondering if it is possible to validate a model
> programmatically, without using the editor.
>
> // For example, create a few objects:
>
> Book myBook = EXTLibraryFactory.eINSTANCE.createBook();
> myBook.setTitle("EMF Validation");
> Writer writer = EXTLibraryFactory.eINSTANCE.createWriter();
> writer.setName("Hector");
>
> //And then do the validation
>
> I've been searching the web with no luck. Can something like this be
> done? I would appreciate any hints.
>
> Thanks.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Validating an EMF model programatically [message #535624 is a reply to message #535602] Mon, 24 May 2010 23:26 Go to previous messageGo to next message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
I tried using Diagnostician.INSTACE before but it seems that it only checks the default core constraints, which is not useful in my case. I added a couple of custom constraints and those are ignored by the Diagnostician.

Hector
Re: Validating an EMF model programatically [message #535625 is a reply to message #535624] Mon, 24 May 2010 23:30 Go to previous messageGo to next message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
Hector Chavez wrote on Mon, 24 May 2010 19:26
I tried using Diagnostician.INSTACE before but it seems that it only checks the default core constraints, which is not useful in my case. I added a couple of custom constraints and those are ignored by the Diagnostician.

Hector


To be more specific, I added two ocl constraints on plugin.xml following the format given in the OCL validation tutorial on the eclipse documentation web site. Those constraints are correctly checked when I use the editor->validate, but are ignored by the Diagnostician.

Hector
Re: Validating an EMF model programatically [message #535732 is a reply to message #535625] Tue, 25 May 2010 12:52 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Hector,

I gather from this thread that you have used the example plug-in's
Validate context menu action to successfully test your constraints. It
serves as an example of how to perform validation using the API: just
look at the implementation of that action. :-)

Hopefully the Programmer's Guide documentation included in the SDK will
be helpful, also.

Finally, this subject is not quite in the scope of the MDT UML2
newsgroup. Any follow-up question that you may have about EMF
Validation should be directed to the EMF newsgroup; indeed, you will
probably find that many of your questions (including this one) have been
asked and answered, there.

HTH,

Christian


On 24/05/10 07:30 PM, Hector Chavez wrote:
> Hector Chavez wrote on Mon, 24 May 2010 19:26
>> I tried using Diagnostician.INSTACE before but it seems that it only
>> checks the default core constraints, which is not useful in my case. I
>> added a couple of custom constraints and those are ignored by the
>> Diagnostician.
>>
>> Hector
>
>
> To be more specific, I added two ocl constraints on plugin.xml following
> the format given in the OCL validation tutorial on the eclipse
> documentation web site. Those constraints are correctly checked when I
> use the editor->validate, but are ignored by the Diagnostician.
>
> Hector
>
Re: Validating an EMF model programatically [message #535736 is a reply to message #535732] Tue, 25 May 2010 13:03 Go to previous messageGo to next message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
Thank you, I didn't think about that, I'll check the EMF newsgroup.

Hector

Christian W. Damus wrote on Tue, 25 May 2010 08:52
Hi, Hector,

I gather from this thread that you have used the example plug-in's
Validate context menu action to successfully test your constraints. It
serves as an example of how to perform validation using the API: just
look at the implementation of that action. Smile

Hopefully the Programmer's Guide documentation included in the SDK will
be helpful, also.

Finally, this subject is not quite in the scope of the MDT UML2
newsgroup. Any follow-up question that you may have about EMF
Validation should be directed to the EMF newsgroup; indeed, you will
probably find that many of your questions (including this one) have been
asked and answered, there.

HTH,

Christian


On 24/05/10 07:30 PM, Hector Chavez wrote:
> Hector Chavez wrote on Mon, 24 May 2010 19:26
>> I tried using Diagnostician.INSTACE before but it seems that it only
>> checks the default core constraints, which is not useful in my case. I
>> added a couple of custom constraints and those are ignored by the
>> Diagnostician.
>>
>> Hector
>
>
> To be more specific, I added two ocl constraints on plugin.xml following
> the format given in the OCL validation tutorial on the eclipse
> documentation web site. Those constraints are correctly checked when I
> use the editor->validate, but are ignored by the Diagnostician.
>
> Hector
>

Re: Validating an EMF model programatically [message #628461 is a reply to message #535591] Mon, 24 May 2010 19:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Diagnostician.INSTANCE can be used to check the core constraints.


Hector Chavez wrote:
> I was going over the EMF Validation Framework example and I was able
> to set everything up and add a few extra constraints. Then I run the
> plugin as an eclipse application, I create the model and then in the
> editor menu I can select validate to check the constraints and
> everything works fine.
> But I was wondering if it is possible to validate a model
> programmatically, without using the editor.
>
> // For example, create a few objects:
>
> Book myBook = EXTLibraryFactory.eINSTANCE.createBook();
> myBook.setTitle("EMF Validation");
> Writer writer = EXTLibraryFactory.eINSTANCE.createWriter();
> writer.setName("Hector");
>
> //And then do the validation
>
> I've been searching the web with no luck. Can something like this be
> done? I would appreciate any hints.
>
> Thanks.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Validating an EMF model programatically [message #628462 is a reply to message #535602] Mon, 24 May 2010 23:26 Go to previous messageGo to next message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
I tried using Diagnostician.INSTACE before but it seems that it only checks the default core constraints, which is not useful in my case. I added a couple of custom constraints and those are ignored by the Diagnostician.

Hector
Re: Validating an EMF model programatically [message #628464 is a reply to message #535625] Tue, 25 May 2010 12:52 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Hector,

I gather from this thread that you have used the example plug-in's
Validate context menu action to successfully test your constraints. It
serves as an example of how to perform validation using the API: just
look at the implementation of that action. :-)

Hopefully the Programmer's Guide documentation included in the SDK will
be helpful, also.

Finally, this subject is not quite in the scope of the MDT UML2
newsgroup. Any follow-up question that you may have about EMF
Validation should be directed to the EMF newsgroup; indeed, you will
probably find that many of your questions (including this one) have been
asked and answered, there.

HTH,

Christian


On 24/05/10 07:30 PM, Hector Chavez wrote:
> Hector Chavez wrote on Mon, 24 May 2010 19:26
>> I tried using Diagnostician.INSTACE before but it seems that it only
>> checks the default core constraints, which is not useful in my case. I
>> added a couple of custom constraints and those are ignored by the
>> Diagnostician.
>>
>> Hector
>
>
> To be more specific, I added two ocl constraints on plugin.xml following
> the format given in the OCL validation tutorial on the eclipse
> documentation web site. Those constraints are correctly checked when I
> use the editor->validate, but are ignored by the Diagnostician.
>
> Hector
>
Re: Validating an EMF model programatically [message #628465 is a reply to message #535732] Tue, 25 May 2010 13:03 Go to previous message
Hector Chavez is currently offline Hector ChavezFriend
Messages: 34
Registered: February 2010
Member
Thank you, I didn't think about that, I'll check the EMF newsgroup.

Hector

Christian W. Damus wrote on Tue, 25 May 2010 08:52
> Hi, Hector,
>
> I gather from this thread that you have used the example plug-in's
> Validate context menu action to successfully test your constraints. It
> serves as an example of how to perform validation using the API: just
> look at the implementation of that action. :)
>
> Hopefully the Programmer's Guide documentation included in the SDK will
> be helpful, also.
>
> Finally, this subject is not quite in the scope of the MDT UML2
> newsgroup. Any follow-up question that you may have about EMF
> Validation should be directed to the EMF newsgroup; indeed, you will
> probably find that many of your questions (including this one) have been
> asked and answered, there.
>
> HTH,
>
> Christian
>
>
> On 24/05/10 07:30 PM, Hector Chavez wrote:
> > Hector Chavez wrote on Mon, 24 May 2010 19:26
> >> I tried using Diagnostician.INSTACE before but it seems that it only
> >> checks the default core constraints, which is not useful in my case. I
> >> added a couple of custom constraints and those are ignored by the
> >> Diagnostician.
> >>
> >> Hector
> >
> >
> > To be more specific, I added two ocl constraints on plugin.xml following
> > the format given in the OCL validation tutorial on the eclipse
> > documentation web site. Those constraints are correctly checked when I
> > use the editor->validate, but are ignored by the Diagnostician.
> >
> > Hector
> >
Previous Topic:Re: Validating an EMF model programatically
Next Topic:loading serialized UML2 models standalone
Goto Forum:
  


Current Time: Fri Apr 19 16:04:04 GMT 2024

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

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

Back to the top