Home » Modeling » EMF » Validation constraints on annotated Java
|
Re: Validation constraints on annotated Java [message #420871 is a reply to message #420870] |
Tue, 15 July 2008 12:50 |
Eclipse User |
|
|
|
Originally posted by: cdamus.zeligsoft.com
--=-6Q0hJF0iPQMxaNVTm/EU
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi, JF,
That is correct. All of the constraints in your package are generated
into a single validator class (like the single package, factory, switch,
adapter factory, etc.).
Just fill in the TODOs in the methods in your generated validator and
remember to mark them @generated NOT
HTH,
Christian
On Tue, 2008-07-15 at 12:43 +0000, JF wrote:
> Hi,
>
> I tried following the tutorial on the EMF Validation framework at
> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.Validation.html
>
> I created a dymmy project based on the annotated Java Library example and
> annotated my Library as follows;
>
>
> /**
> * @model
> annotation="http://www.eclipse.org/emf/2002/Ecore
> constraints='NonNegativeQuantity ValidShipDate'"
>
> */
> public interface Library extends EObject
> {
> /**
> * @model
> */
> String getName();
>
> /**
> * Sets the value of the '{@link model.Library#getName <em>Name</em>}'
> attribute.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @param value the new value of the '<em>Name</em>' attribute.
> * @see #getName()
> * @generated
> */
> void setName(String value);
>
> /**
> * @model type="Writer" containment="true"
> */
> EList getWriters();
>
> /**
> * @model type="Book" containment="true"
> */
> EList getBooks();
>
> /**
> * @model
> */
> boolean hasUSState(
> DiagnosticChain diagnostics,
> Map context);
>
> }
>
>
> This leads to a single validator for the whole model being generated ( not
> one per interface ). Also there is nothing generated for the constraints
> that I can see.
>
> Is this what is meant to occur now? i.e. If I want to do something special
> I just override methods in the single package level validator?
>
> Thanks
>
--=-6Q0hJF0iPQMxaNVTm/EU
Content-Type: text/html; charset=utf-8
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, JF,<BR>
<BR>
That is correct. All of the constraints in your package are generated into a single validator class (like the single package, factory, switch, adapter factory, etc.).<BR>
<BR>
Just fill in the TODOs in the methods in your generated validator and remember to mark them @generated NOT<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
On Tue, 2008-07-15 at 12:43 +0000, JF wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hi, </FONT>
<FONT COLOR="#000000">I tried following the tutorial on the EMF Validation framework at </FONT>
<FONT COLOR="#000000"><A HREF=" http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.Validation.html"> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.Validation.html</A></FONT>
<FONT COLOR="#000000">I created a dymmy project based on the annotated Java Library example and </FONT>
<FONT COLOR="#000000">annotated my Library as follows;</FONT>
<FONT COLOR="#000000">/**</FONT>
<FONT COLOR="#000000"> * @model </FONT>
<FONT COLOR="#000000"> annotation="<A HREF="http://www.eclipse.org/emf/2002/Ecore">http://www.eclipse.org/emf/2002/Ecore</A> </FONT>
<FONT COLOR="#000000"> constraints='NonNegativeQuantity ValidShipDate'"</FONT>
<FONT COLOR="#000000"> */</FONT>
<FONT COLOR="#000000">public interface Library extends EObject</FONT>
<FONT COLOR="#000000">{</FONT>
<FONT COLOR="#000000"> /**</FONT>
<FONT COLOR="#000000"> * @model</FONT>
<FONT COLOR="#000000"> */</FONT>
<FONT COLOR="#000000"> String getName();</FONT>
<FONT COLOR="#000000"> /**</FONT>
<FONT COLOR="#000000"> * Sets the value of the '{@link model.Library#getName <em>Name</em>}' </FONT>
<FONT COLOR="#000000">attribute.</FONT>
<FONT COLOR="#000000"> * <!-- begin-user-doc --></FONT>
<FONT COLOR="#000000"> * <!-- end-user-doc --></FONT>
<FONT COLOR="#000000"> * @param value the new value of the '<em>Name</em>' attribute.</FONT>
<FONT COLOR="#000000"> * @see #getName()</FONT>
<FONT COLOR="#000000"> * @generated</FONT>
<FONT COLOR="#000000"> */</FONT>
<FONT COLOR="#000000"> void setName(String value);</FONT>
<FONT COLOR="#000000"> /**</FONT>
<FONT COLOR="#000000"> * @model type="Writer" containment="true"</FONT>
<FONT COLOR="#000000"> */</FONT>
<FONT COLOR="#000000"> EList getWriters();</FONT>
<FONT COLOR="#000000"> /**</FONT>
<FONT COLOR="#000000"> * @model type="Book" containment="true"</FONT>
<FONT COLOR="#000000"> */</FONT>
<FONT COLOR="#000000"> EList getBooks();</FONT>
<FONT COLOR="#000000"> </FONT>
<FONT COLOR="#000000"> /**</FONT>
<FONT COLOR="#000000"> * @model</FONT>
<FONT COLOR="#000000"> */</FONT>
<FONT COLOR="#000000"> boolean hasUSState(</FONT>
<FONT COLOR="#000000"> DiagnosticChain diagnostics, </FONT>
<FONT COLOR="#000000"> Map context);</FONT>
<FONT COLOR="#000000">}</FONT>
<FONT COLOR="#000000">This leads to a single validator for the whole model being generated ( not </FONT>
<FONT COLOR="#000000">one per interface ). Also there is nothing generated for the constraints </FONT>
<FONT COLOR="#000000">that I can see.</FONT>
<FONT COLOR="#000000">Is this what is meant to occur now? i.e. If I want to do something special </FONT>
<FONT COLOR="#000000">I just override methods in the single package level validator?</FONT>
<FONT COLOR="#000000">Thanks</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-6Q0hJF0iPQMxaNVTm/EU--
|
|
| |
Re: Validation constraints on annotated Java [message #420874 is a reply to message #420872] |
Tue, 15 July 2008 13:03 |
Eclipse User |
|
|
|
Originally posted by: cdamus.zeligsoft.com
--=-o4/ozQ4W7jNapWpDdTXy
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi, JF,
These annotations aren't obsolete. As far as I know, you should be
getting a validator in your model's *.util package. Perhaps Ed would be
able to advise on why this doesn't seem to be working.
This *is* the intrinsic (generative) validation framework provided by
the EMF Core component. The EMF Validation Framework component (the
separate one) provides an altogether different solution based on
contribution of constraints externally to the model definition.
Cheers,
Christian
On Tue, 2008-07-15 at 12:55 +0000, JF wrote:
> Thanks...
>
> So the
>
> @model annotation="http://www.eclipse.org/emf/2002/Ecore
> constraints='NonNegativeQuantity ValidShipDate'"
>
>
> stuff is obsolete? - I don't get a Validator for the annotated class in
> the generated util directory, with a method per constraint name?
>
> What is the relationship of this with the validation framework?
>
--=-o4/ozQ4W7jNapWpDdTXy
Content-Type: text/html; charset=utf-8
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, JF,<BR>
<BR>
These annotations aren't obsolete. As far as I know, you should be getting a validator in your model's *.util package. Perhaps Ed would be able to advise on why this doesn't seem to be working.<BR>
<BR>
This *is* the intrinsic (generative) validation framework provided by the EMF Core component. The EMF Validation Framework component (the separate one) provides an altogether different solution based on contribution of constraints externally to the model definition.<BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
On Tue, 2008-07-15 at 12:55 +0000, JF wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Thanks...</FONT>
<FONT COLOR="#000000">So the</FONT>
<FONT COLOR="#000000">@model annotation="<A HREF="http://www.eclipse.org/emf/2002/Ecore">http://www.eclipse.org/emf/2002/Ecore</A> </FONT>
<FONT COLOR="#000000"> constraints='NonNegativeQuantity ValidShipDate'"</FONT>
<FONT COLOR="#000000">stuff is obsolete? - I don't get a Validator for the annotated class in </FONT>
<FONT COLOR="#000000">the generated util directory, with a method per constraint name?</FONT>
<FONT COLOR="#000000">What is the relationship of this with the validation framework?</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-o4/ozQ4W7jNapWpDdTXy--
|
|
|
Re: Validation constraints on annotated Java [message #420875 is a reply to message #420874] |
Tue, 15 July 2008 13:09 |
J F Messages: 256 Registered: July 2009 |
Senior Member |
|
|
Thanks Christian,
I don't seem to be getting the ***Validator class generated.
I started with the Empty EMF Project wizard, copied across the Java
interfaces from the library example, added the invariant method and
constraint annotation from the tutorial to the Library interface, as per
the code I posted, and nothing is being generated ...
BTW, I don't want to use the annotated Java, I would prefer to add
annotations directly to my EClass model which I extract from somewhere
else, I was trying to find out what "shape" the annotations would look
like in the ecore model, but ofcourse these don't seem to be generated
either. I'd be grateful of any hints, thanks...
|
|
| | | |
Goto Forum:
Current Time: Thu Apr 25 19:23:34 GMT 2024
Powered by FUDForum. Page generated in 0.03337 seconds
|