[jira] Created: (MODELLO-214) Add Java annotations generation

View: New views
10 Messages — Rating Filter:   Alert me  

[jira] Created: (MODELLO-214) Add Java annotations generation

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Add Java annotations generation
-------------------------------

                 Key: MODELLO-214
                 URL: http://jira.codehaus.org/browse/MODELLO-214
             Project: Modello
          Issue Type: New Feature
          Components: modello-core, modello-plugin-java
    Affects Versions: 1.0.1
            Reporter: Ludovic Maître
         Attachments: annotation_and_modifier_core.diff, annotation_and_modifier_java.diff

The attached patches (one for modello-core the other for modello-plugin-java) adds a new element <annotations> in the BaseElement and the CodeSegment, this element can contain <annotation> tags which contains annotations for java classes. It modify a few classes in core and plugin-java. The patch also include a subfeature : a <modifier> tag can be added to fields to define their visibility (see the end of the examples). I have spent a few hours checking my code and hope to have followed the code style :-) I apologize to not separate the annotation patch from the modifier patch but now that they are in my code it's not easy to do patch with the right line numbers if i separate the features.

Examples:
    <class>
      <name>CRUDService</name>
      <packageName>com.jsonapps.model.services</packageName>
      <annotations>
        <annotation>@Path("/crud")</annotation>
      </annotations>
...
<codeSegment>
          <annotations>
            <annotation>@GET</annotation>
            <annotation>@Path("/internal/types")</annotation>
            <annotation>@Produces({ "application/json", "application/xml" })</annotation>
          </annotations>
          <version>1.0.0</version>
          <code>  public Map<String,String> getMappingsAsString() {
...
    <class jpa.entity="true">
      <name>Param</name>
      <packageName>com.jsonapps.model</packageName>
      <annotations>
        <annotation>@XmlRootElement</annotation>
        <annotation>@Entity</annotation>
        <annotation>@Table(name="params",uniqueConstraints={@UniqueConstraint(columnNames="param_id"),@UniqueConstraint(columnNames="param_name")})</annotation>
      </annotations>
      <version>1.0.0</version>
      <fields>
        <field>
          <name>id</name>
          <type>int</type>
          <annotations>
            <annotation>@Id</annotation>
            <annotation>@SequenceGenerator(name="param_seq", sequenceName="param_pk_seq")</annotation>
            <annotation>@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="param_seq")</annotation>
            <annotation>@Column(name="param_id")</annotation>
          </annotations>
          <version>1.0.0</version>
        </field>
...
      <fields>
        <field>
          <name>em</name>
          <type>javax.persistence.EntityManager</type>
          <modifier>protected</modifier>
          <version>1.0.0</version>
        </field>

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Commented: (MODELLO-214) Add Java annotations generation

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/MODELLO-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=183997#action_183997 ]

Herve Boutemy commented on MODELLO-214:
---------------------------------------

I tried to merge annotation feature in javasource (and only this feature, not yet its integration into Modello model), and found some problems:
- it creates an unwanted dependency of javasource package to core model (CodeSegment): javasource should remain fully independant. In fact, it could (should?) have been an isolated component.
- JAnnotations class hardcodes '\n', should use writeln instead

Another point.
I don't really understand why an annotation should be avaiable for a code segment: a code segment is just raw code injected in generated file. Did I miss something?
I'll create a javasource unit test (actually missing) to help testing javasource and showing javasource features.

Then sorry, but I'm going to ask for a new patch....

> Add Java annotations generation
> -------------------------------
>
>                 Key: MODELLO-214
>                 URL: http://jira.codehaus.org/browse/MODELLO-214
>             Project: Modello
>          Issue Type: New Feature
>          Components: modello-core, modello-plugin-java
>    Affects Versions: 1.0.1
>            Reporter: Ludovic Maître
>         Attachments: annotation_and_modifier_core.diff, annotation_and_modifier_java.diff
>
>
> The attached patches (one for modello-core the other for modello-plugin-java) adds a new element <annotations> in the BaseElement and the CodeSegment, this element can contain <annotation> tags which contains annotations for java classes. It modify a few classes in core and plugin-java. The patch also include a subfeature : a <modifier> tag can be added to fields to define their visibility (see the end of the examples). I have spent a few hours checking my code and hope to have followed the code style :-) I apologize to not separate the annotation patch from the modifier patch but now that they are in my code it's not easy to do patch with the right line numbers if i separate the features.
> Examples:
>     <class>
>       <name>CRUDService</name>
>       <packageName>com.jsonapps.model.services</packageName>
>       <annotations>
>         <annotation>@Path("/crud")</annotation>
>       </annotations>
> ...
> <codeSegment>
>           <annotations>
>             <annotation>@GET</annotation>
>             <annotation>@Path("/internal/types")</annotation>
>             <annotation>@Produces({ "application/json", "application/xml" })</annotation>
>           </annotations>
>           <version>1.0.0</version>
>           <code>  public Map<String,String> getMappingsAsString() {
> ...
>     <class jpa.entity="true">
>       <name>Param</name>
>       <packageName>com.jsonapps.model</packageName>
>       <annotations>
>         <annotation>@XmlRootElement</annotation>
>         <annotation>@Entity</annotation>
>         <annotation>@Table(name="params",uniqueConstraints={@UniqueConstraint(columnNames="param_id"),@UniqueConstraint(columnNames="param_name")})</annotation>
>       </annotations>
>       <version>1.0.0</version>
>       <fields>
>         <field>
>           <name>id</name>
>           <type>int</type>
>           <annotations>
>             <annotation>@Id</annotation>
>             <annotation>@SequenceGenerator(name="param_seq", sequenceName="param_pk_seq")</annotation>
>             <annotation>@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="param_seq")</annotation>
>             <annotation>@Column(name="param_id")</annotation>
>           </annotations>
>           <version>1.0.0</version>
>         </field>
> ...
>       <fields>
>         <field>
>           <name>em</name>
>           <type>javax.persistence.EntityManager</type>
>           <modifier>protected</modifier>
>           <version>1.0.0</version>
>         </field>

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Commented: (MODELLO-214) Add Java annotations generation

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/MODELLO-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=183999#action_183999 ]

Ludovic Maître commented on MODELLO-214:
----------------------------------------


Hi Hervé,
Thanks for your time in investigating this issue, and your valuable remarks, you are right.

I have used CodeSegment in order to generate annotation on the top of them. The goal for me - it works - is to be able to generate code for the methods i define in my classes (in UML). Currently my tool argo2modello convert UML operations to modello CodeSegment, but it's only because it lacks a ModelMethod (or ModelOperation) in modello-core model, else i would have used it and not CodeSegment. I wonder why there is not methods definition in modello-core, in any case it forbid me to do round trip between UML and modello currently (it is not easy to generate UML operations from the current CodeSegment model element of Modello - i would so much appreciate a <methods><method><return><type>...</type><parameters><parameter><type>...</type><name>...</name><annotations>...</...<body></body>...  in Modello, it could be ignored by plugin which didn't use it - i could write it if everyone is ok).

My prototype is not perfect but works, for the end line issue it could be fixed, i will do it if it is the only remaining issue.

I'm ok for the new patch and will find a solution to not have the dependency on CodeSegment, i would like to create JMethods for classes (they are already extended to manage annotations) but (if i have not missed it) it miss methods in modello-core model for it to be efficient, if you and the other devs are ok i would like to do it, please let me know :-) We could keep the support for code segments, perhaps without annotations (i can expand on this), to be backward compatible.

Best regards thanks for your inputs and fast answers,


> Add Java annotations generation
> -------------------------------
>
>                 Key: MODELLO-214
>                 URL: http://jira.codehaus.org/browse/MODELLO-214
>             Project: Modello
>          Issue Type: New Feature
>          Components: modello-core, modello-plugin-java
>    Affects Versions: 1.0.1
>            Reporter: Ludovic Maître
>         Attachments: annotation_and_modifier_core.diff, annotation_and_modifier_java.diff
>
>
> The attached patches (one for modello-core the other for modello-plugin-java) adds a new element <annotations> in the BaseElement and the CodeSegment, this element can contain <annotation> tags which contains annotations for java classes. It modify a few classes in core and plugin-java. The patch also include a subfeature : a <modifier> tag can be added to fields to define their visibility (see the end of the examples). I have spent a few hours checking my code and hope to have followed the code style :-) I apologize to not separate the annotation patch from the modifier patch but now that they are in my code it's not easy to do patch with the right line numbers if i separate the features.
> Examples:
>     <class>
>       <name>CRUDService</name>
>       <packageName>com.jsonapps.model.services</packageName>
>       <annotations>
>         <annotation>@Path("/crud")</annotation>
>       </annotations>
> ...
> <codeSegment>
>           <annotations>
>             <annotation>@GET</annotation>
>             <annotation>@Path("/internal/types")</annotation>
>             <annotation>@Produces({ "application/json", "application/xml" })</annotation>
>           </annotations>
>           <version>1.0.0</version>
>           <code>  public Map<String,String> getMappingsAsString() {
> ...
>     <class jpa.entity="true">
>       <name>Param</name>
>       <packageName>com.jsonapps.model</packageName>
>       <annotations>
>         <annotation>@XmlRootElement</annotation>
>         <annotation>@Entity</annotation>
>         <annotation>@Table(name="params",uniqueConstraints={@UniqueConstraint(columnNames="param_id"),@UniqueConstraint(columnNames="param_name")})</annotation>
>       </annotations>
>       <version>1.0.0</version>
>       <fields>
>         <field>
>           <name>id</name>
>           <type>int</type>
>           <annotations>
>             <annotation>@Id</annotation>
>             <annotation>@SequenceGenerator(name="param_seq", sequenceName="param_pk_seq")</annotation>
>             <annotation>@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="param_seq")</annotation>
>             <annotation>@Column(name="param_id")</annotation>
>           </annotations>
>           <version>1.0.0</version>
>         </field>
> ...
>       <fields>
>         <field>
>           <name>em</name>
>           <type>javax.persistence.EntityManager</type>
>           <modifier>protected</modifier>
>           <version>1.0.0</version>
>         </field>

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Commented: (MODELLO-214) Add Java annotations generation

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/MODELLO-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=184587#action_184587 ]

Herve Boutemy commented on MODELLO-214:
---------------------------------------

I'm trying to extract annotations feature, and I need some explanations.
The patch provides annotation support on parameters (in JParameter.java).
I'm not an annotation expert: my knowledge is limited to some tutorials and basic examples.
Annotations are supported on parameters? Can you give me a pointer to an example?

> Add Java annotations generation
> -------------------------------
>
>                 Key: MODELLO-214
>                 URL: http://jira.codehaus.org/browse/MODELLO-214
>             Project: Modello
>          Issue Type: New Feature
>          Components: modello-core, modello-plugin-java
>    Affects Versions: 1.0.1
>            Reporter: Ludovic Maître
>         Attachments: annotation_and_modifier_core.diff, annotation_and_modifier_java.diff
>
>
> The attached patches (one for modello-core the other for modello-plugin-java) adds a new element <annotations> in the BaseElement and the CodeSegment, this element can contain <annotation> tags which contains annotations for java classes. It modify a few classes in core and plugin-java. The patch also include a subfeature : a <modifier> tag can be added to fields to define their visibility (see the end of the examples). I have spent a few hours checking my code and hope to have followed the code style :-) I apologize to not separate the annotation patch from the modifier patch but now that they are in my code it's not easy to do patch with the right line numbers if i separate the features.
> Examples:
>     <class>
>       <name>CRUDService</name>
>       <packageName>com.jsonapps.model.services</packageName>
>       <annotations>
>         <annotation>@Path("/crud")</annotation>
>       </annotations>
> ...
> <codeSegment>
>           <annotations>
>             <annotation>@GET</annotation>
>             <annotation>@Path("/internal/types")</annotation>
>             <annotation>@Produces({ "application/json", "application/xml" })</annotation>
>           </annotations>
>           <version>1.0.0</version>
>           <code>  public Map<String,String> getMappingsAsString() {
> ...
>     <class jpa.entity="true">
>       <name>Param</name>
>       <packageName>com.jsonapps.model</packageName>
>       <annotations>
>         <annotation>@XmlRootElement</annotation>
>         <annotation>@Entity</annotation>
>         <annotation>@Table(name="params",uniqueConstraints={@UniqueConstraint(columnNames="param_id"),@UniqueConstraint(columnNames="param_name")})</annotation>
>       </annotations>
>       <version>1.0.0</version>
>       <fields>
>         <field>
>           <name>id</name>
>           <type>int</type>
>           <annotations>
>             <annotation>@Id</annotation>
>             <annotation>@SequenceGenerator(name="param_seq", sequenceName="param_pk_seq")</annotation>
>             <annotation>@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="param_seq")</annotation>
>             <annotation>@Column(name="param_id")</annotation>
>           </annotations>
>           <version>1.0.0</version>
>         </field>
> ...
>       <fields>
>         <field>
>           <name>em</name>
>           <type>javax.persistence.EntityManager</type>
>           <modifier>protected</modifier>
>           <version>1.0.0</version>
>         </field>

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Commented: (MODELLO-214) Add Java annotations generation

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/MODELLO-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=184590#action_184590 ]

Herve Boutemy commented on MODELLO-214:
---------------------------------------

I just added annotations support in javasource in r1297, with corresponding unit test to check that annotations can be generated in every useful place
please review and tell me if it is ok

> Add Java annotations generation
> -------------------------------
>
>                 Key: MODELLO-214
>                 URL: http://jira.codehaus.org/browse/MODELLO-214
>             Project: Modello
>          Issue Type: New Feature
>          Components: modello-core, modello-plugin-java
>    Affects Versions: 1.0.1
>            Reporter: Ludovic Maître
>         Attachments: annotation_and_modifier_core.diff, annotation_and_modifier_java.diff
>
>
> The attached patches (one for modello-core the other for modello-plugin-java) adds a new element <annotations> in the BaseElement and the CodeSegment, this element can contain <annotation> tags which contains annotations for java classes. It modify a few classes in core and plugin-java. The patch also include a subfeature : a <modifier> tag can be added to fields to define their visibility (see the end of the examples). I have spent a few hours checking my code and hope to have followed the code style :-) I apologize to not separate the annotation patch from the modifier patch but now that they are in my code it's not easy to do patch with the right line numbers if i separate the features.
> Examples:
>     <class>
>       <name>CRUDService</name>
>       <packageName>com.jsonapps.model.services</packageName>
>       <annotations>
>         <annotation>@Path("/crud")</annotation>
>       </annotations>
> ...
> <codeSegment>
>           <annotations>
>             <annotation>@GET</annotation>
>             <annotation>@Path("/internal/types")</annotation>
>             <annotation>@Produces({ "application/json", "application/xml" })</annotation>
>           </annotations>
>           <version>1.0.0</version>
>           <code>  public Map<String,String> getMappingsAsString() {
> ...
>     <class jpa.entity="true">
>       <name>Param</name>
>       <packageName>com.jsonapps.model</packageName>
>       <annotations>
>         <annotation>@XmlRootElement</annotation>
>         <annotation>@Entity</annotation>
>         <annotation>@Table(name="params",uniqueConstraints={@UniqueConstraint(columnNames="param_id"),@UniqueConstraint(columnNames="param_name")})</annotation>
>       </annotations>
>       <version>1.0.0</version>
>       <fields>
>         <field>
>           <name>id</name>
>           <type>int</type>
>           <annotations>
>             <annotation>@Id</annotation>
>             <annotation>@SequenceGenerator(name="param_seq", sequenceName="param_pk_seq")</annotation>
>             <annotation>@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="param_seq")</annotation>
>             <annotation>@Column(name="param_id")</annotation>
>           </annotations>
>           <version>1.0.0</version>
>         </field>
> ...
>       <fields>
>         <field>
>           <name>em</name>
>           <type>javax.persistence.EntityManager</type>
>           <modifier>protected</modifier>
>           <version>1.0.0</version>
>         </field>

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Commented: (MODELLO-214) Add Java annotations generation

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/MODELLO-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=184612#action_184612 ]

Ludovic Maître commented on MODELLO-214:
----------------------------------------

Hi Hervé,

Many many thanks for your work, i will check if it works. For annotations on parameters, i have seen them used in Jersey, the JAX-RS implementation. Here is a snippet of code:

@GET
    @Produces("application/json")
    @Path("/network/{id: [0-9]+}/{nid}")
    public User getUserByNetworkId(@PathParam("id") int id, @PathParam("nid") String networkId) {
        Query q = em.createQuery("SELECT u FROM User u WHERE u.networkId = :id AND u.networkUserId = :nid");
        q.setParameter("id", id);
        q.setParameter("nid", networkId);
        return (User) q.getSingleResult();
    }

It come from this page: http://www.javarants.com/2008/12/25/using-jax-rs-jersey-to-build-a-jpajaxb-backed-json-rest-api/ , That i recommned you to read as it is short and show well the usefulness of JAX-RS combined to JAXB. Normally we can model everything in this page in Modello now :-)

> Add Java annotations generation
> -------------------------------
>
>                 Key: MODELLO-214
>                 URL: http://jira.codehaus.org/browse/MODELLO-214
>             Project: Modello
>          Issue Type: New Feature
>          Components: modello-core, modello-plugin-java
>    Affects Versions: 1.0.1
>            Reporter: Ludovic Maître
>         Attachments: annotation_and_modifier_core.diff, annotation_and_modifier_java.diff
>
>
> The attached patches (one for modello-core the other for modello-plugin-java) adds a new element <annotations> in the BaseElement and the CodeSegment, this element can contain <annotation> tags which contains annotations for java classes. It modify a few classes in core and plugin-java. The patch also include a subfeature : a <modifier> tag can be added to fields to define their visibility (see the end of the examples). I have spent a few hours checking my code and hope to have followed the code style :-) I apologize to not separate the annotation patch from the modifier patch but now that they are in my code it's not easy to do patch with the right line numbers if i separate the features.
> Examples:
>     <class>
>       <name>CRUDService</name>
>       <packageName>com.jsonapps.model.services</packageName>
>       <annotations>
>         <annotation>@Path("/crud")</annotation>
>       </annotations>
> ...
> <codeSegment>
>           <annotations>
>             <annotation>@GET</annotation>
>             <annotation>@Path("/internal/types")</annotation>
>             <annotation>@Produces({ "application/json", "application/xml" })</annotation>
>           </annotations>
>           <version>1.0.0</version>
>           <code>  public Map<String,String> getMappingsAsString() {
> ...
>     <class jpa.entity="true">
>       <name>Param</name>
>       <packageName>com.jsonapps.model</packageName>
>       <annotations>
>         <annotation>@XmlRootElement</annotation>
>         <annotation>@Entity</annotation>
>         <annotation>@Table(name="params",uniqueConstraints={@UniqueConstraint(columnNames="param_id"),@UniqueConstraint(columnNames="param_name")})</annotation>
>       </annotations>
>       <version>1.0.0</version>
>       <fields>
>         <field>
>           <name>id</name>
>           <type>int</type>
>           <annotations>
>             <annotation>@Id</annotation>
>             <annotation>@SequenceGenerator(name="param_seq", sequenceName="param_pk_seq")</annotation>
>             <annotation>@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="param_seq")</annotation>
>             <annotation>@Column(name="param_id")</annotation>
>           </annotations>
>           <version>1.0.0</version>
>         </field>
> ...
>       <fields>
>         <field>
>           <name>em</name>
>           <type>javax.persistence.EntityManager</type>
>           <modifier>protected</modifier>
>           <version>1.0.0</version>
>         </field>

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Commented: (MODELLO-214) Add Java annotations generation

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/MODELLO-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=184613#action_184613 ]

Benjamin Bentmann commented on MODELLO-214:
-------------------------------------------

bq. Annotations are supported on parameters? Can you give me a pointer to an example?

See also [java.lang.annotation.ElementType|http://java.sun.com/j2se/1.5.0/docs/api/java/lang/annotation/ElementType.html].

> Add Java annotations generation
> -------------------------------
>
>                 Key: MODELLO-214
>                 URL: http://jira.codehaus.org/browse/MODELLO-214
>             Project: Modello
>          Issue Type: New Feature
>          Components: modello-core, modello-plugin-java
>    Affects Versions: 1.0.1
>            Reporter: Ludovic Maître
>         Attachments: annotation_and_modifier_core.diff, annotation_and_modifier_java.diff
>
>
> The attached patches (one for modello-core the other for modello-plugin-java) adds a new element <annotations> in the BaseElement and the CodeSegment, this element can contain <annotation> tags which contains annotations for java classes. It modify a few classes in core and plugin-java. The patch also include a subfeature : a <modifier> tag can be added to fields to define their visibility (see the end of the examples). I have spent a few hours checking my code and hope to have followed the code style :-) I apologize to not separate the annotation patch from the modifier patch but now that they are in my code it's not easy to do patch with the right line numbers if i separate the features.
> Examples:
>     <class>
>       <name>CRUDService</name>
>       <packageName>com.jsonapps.model.services</packageName>
>       <annotations>
>         <annotation>@Path("/crud")</annotation>
>       </annotations>
> ...
> <codeSegment>
>           <annotations>
>             <annotation>@GET</annotation>
>             <annotation>@Path("/internal/types")</annotation>
>             <annotation>@Produces({ "application/json", "application/xml" })</annotation>
>           </annotations>
>           <version>1.0.0</version>
>           <code>  public Map<String,String> getMappingsAsString() {
> ...
>     <class jpa.entity="true">
>       <name>Param</name>
>       <packageName>com.jsonapps.model</packageName>
>       <annotations>
>         <annotation>@XmlRootElement</annotation>
>         <annotation>@Entity</annotation>
>         <annotation>@Table(name="params",uniqueConstraints={@UniqueConstraint(columnNames="param_id"),@UniqueConstraint(columnNames="param_name")})</annotation>
>       </annotations>
>       <version>1.0.0</version>
>       <fields>
>         <field>
>           <name>id</name>
>           <type>int</type>
>           <annotations>
>             <annotation>@Id</annotation>
>             <annotation>@SequenceGenerator(name="param_seq", sequenceName="param_pk_seq")</annotation>
>             <annotation>@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="param_seq")</annotation>
>             <annotation>@Column(name="param_id")</annotation>
>           </annotations>
>           <version>1.0.0</version>
>         </field>
> ...
>       <fields>
>         <field>
>           <name>em</name>
>           <type>javax.persistence.EntityManager</type>
>           <modifier>protected</modifier>
>           <version>1.0.0</version>
>         </field>

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Commented: (MODELLO-214) Add Java annotations generation

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/MODELLO-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=184642#action_184642 ]

Ludovic Maître commented on MODELLO-214:
----------------------------------------

Hi Hervé,

I checked out the source and do some tests but i see that you didn't patch modello-core for the moment, and my tests used a models which use annotations. Do you want i build a test only for the javasource part ? Else everything compile fine and the unit test you provide pass. For your informations i attach the testcase i would like to run.

> Add Java annotations generation
> -------------------------------
>
>                 Key: MODELLO-214
>                 URL: http://jira.codehaus.org/browse/MODELLO-214
>             Project: Modello
>          Issue Type: New Feature
>          Components: modello-core, modello-plugin-java
>    Affects Versions: 1.0.1
>            Reporter: Ludovic Maître
>         Attachments: annotation_and_modifier_core.diff, annotation_and_modifier_java.diff
>
>
> The attached patches (one for modello-core the other for modello-plugin-java) adds a new element <annotations> in the BaseElement and the CodeSegment, this element can contain <annotation> tags which contains annotations for java classes. It modify a few classes in core and plugin-java. The patch also include a subfeature : a <modifier> tag can be added to fields to define their visibility (see the end of the examples). I have spent a few hours checking my code and hope to have followed the code style :-) I apologize to not separate the annotation patch from the modifier patch but now that they are in my code it's not easy to do patch with the right line numbers if i separate the features.
> Examples:
>     <class>
>       <name>CRUDService</name>
>       <packageName>com.jsonapps.model.services</packageName>
>       <annotations>
>         <annotation>@Path("/crud")</annotation>
>       </annotations>
> ...
> <codeSegment>
>           <annotations>
>             <annotation>@GET</annotation>
>             <annotation>@Path("/internal/types")</annotation>
>             <annotation>@Produces({ "application/json", "application/xml" })</annotation>
>           </annotations>
>           <version>1.0.0</version>
>           <code>  public Map<String,String> getMappingsAsString() {
> ...
>     <class jpa.entity="true">
>       <name>Param</name>
>       <packageName>com.jsonapps.model</packageName>
>       <annotations>
>         <annotation>@XmlRootElement</annotation>
>         <annotation>@Entity</annotation>
>         <annotation>@Table(name="params",uniqueConstraints={@UniqueConstraint(columnNames="param_id"),@UniqueConstraint(columnNames="param_name")})</annotation>
>       </annotations>
>       <version>1.0.0</version>
>       <fields>
>         <field>
>           <name>id</name>
>           <type>int</type>
>           <annotations>
>             <annotation>@Id</annotation>
>             <annotation>@SequenceGenerator(name="param_seq", sequenceName="param_pk_seq")</annotation>
>             <annotation>@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="param_seq")</annotation>
>             <annotation>@Column(name="param_id")</annotation>
>           </annotations>
>           <version>1.0.0</version>
>         </field>
> ...
>       <fields>
>         <field>
>           <name>em</name>
>           <type>javax.persistence.EntityManager</type>
>           <modifier>protected</modifier>
>           <version>1.0.0</version>
>         </field>

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Updated: (MODELLO-214) Add Java annotations generation

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ http://jira.codehaus.org/browse/MODELLO-214?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ludovic Maître updated MODELLO-214:
-----------------------------------

    Attachment: UsersVerifier.java
                users.mdo
                UsersJavaGeneratorTest.java

The tescase for annotations. Notice that it also require the defaultImport patch (to import packages of the annotations) and the modello test patch to compile in Java 1.5 (annotations exist only since java 1.5), but do just check if the annotations are correctly recognized running the testcase without failure should suffice. It require changes in modello-core (mainly ModelReader) in order to recognize the <annotations><annotation>... tags in the model. The model of the test case use JAXB and JPA.

> Add Java annotations generation
> -------------------------------
>
>                 Key: MODELLO-214
>                 URL: http://jira.codehaus.org/browse/MODELLO-214
>             Project: Modello
>          Issue Type: New Feature
>          Components: modello-core, modello-plugin-java
>    Affects Versions: 1.0.1
>            Reporter: Ludovic Maître
>         Attachments: annotation_and_modifier_core.diff, annotation_and_modifier_java.diff, users.mdo, UsersJavaGeneratorTest.java, UsersVerifier.java
>
>
> The attached patches (one for modello-core the other for modello-plugin-java) adds a new element <annotations> in the BaseElement and the CodeSegment, this element can contain <annotation> tags which contains annotations for java classes. It modify a few classes in core and plugin-java. The patch also include a subfeature : a <modifier> tag can be added to fields to define their visibility (see the end of the examples). I have spent a few hours checking my code and hope to have followed the code style :-) I apologize to not separate the annotation patch from the modifier patch but now that they are in my code it's not easy to do patch with the right line numbers if i separate the features.
> Examples:
>     <class>
>       <name>CRUDService</name>
>       <packageName>com.jsonapps.model.services</packageName>
>       <annotations>
>         <annotation>@Path("/crud")</annotation>
>       </annotations>
> ...
> <codeSegment>
>           <annotations>
>             <annotation>@GET</annotation>
>             <annotation>@Path("/internal/types")</annotation>
>             <annotation>@Produces({ "application/json", "application/xml" })</annotation>
>           </annotations>
>           <version>1.0.0</version>
>           <code>  public Map<String,String> getMappingsAsString() {
> ...
>     <class jpa.entity="true">
>       <name>Param</name>
>       <packageName>com.jsonapps.model</packageName>
>       <annotations>
>         <annotation>@XmlRootElement</annotation>
>         <annotation>@Entity</annotation>
>         <annotation>@Table(name="params",uniqueConstraints={@UniqueConstraint(columnNames="param_id"),@UniqueConstraint(columnNames="param_name")})</annotation>
>       </annotations>
>       <version>1.0.0</version>
>       <fields>
>         <field>
>           <name>id</name>
>           <type>int</type>
>           <annotations>
>             <annotation>@Id</annotation>
>             <annotation>@SequenceGenerator(name="param_seq", sequenceName="param_pk_seq")</annotation>
>             <annotation>@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="param_seq")</annotation>
>             <annotation>@Column(name="param_id")</annotation>
>           </annotations>
>           <version>1.0.0</version>
>         </field>
> ...
>       <fields>
>         <field>
>           <name>em</name>
>           <type>javax.persistence.EntityManager</type>
>           <modifier>protected</modifier>
>           <version>1.0.0</version>
>         </field>

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Commented: (MODELLO-214) Add Java annotations generation

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/MODELLO-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=184705#action_184705 ]

Herve Boutemy commented on MODELLO-214:
---------------------------------------

thank you for your pointers: I added parameters annotation in r1298.

> Add Java annotations generation
> -------------------------------
>
>                 Key: MODELLO-214
>                 URL: http://jira.codehaus.org/browse/MODELLO-214
>             Project: Modello
>          Issue Type: New Feature
>          Components: modello-core, modello-plugin-java
>    Affects Versions: 1.0.1
>            Reporter: Ludovic Maître
>         Attachments: annotation_and_modifier_core.diff, annotation_and_modifier_java.diff, users.mdo, UsersJavaGeneratorTest.java, UsersVerifier.java
>
>
> The attached patches (one for modello-core the other for modello-plugin-java) adds a new element <annotations> in the BaseElement and the CodeSegment, this element can contain <annotation> tags which contains annotations for java classes. It modify a few classes in core and plugin-java. The patch also include a subfeature : a <modifier> tag can be added to fields to define their visibility (see the end of the examples). I have spent a few hours checking my code and hope to have followed the code style :-) I apologize to not separate the annotation patch from the modifier patch but now that they are in my code it's not easy to do patch with the right line numbers if i separate the features.
> Examples:
>     <class>
>       <name>CRUDService</name>
>       <packageName>com.jsonapps.model.services</packageName>
>       <annotations>
>         <annotation>@Path("/crud")</annotation>
>       </annotations>
> ...
> <codeSegment>
>           <annotations>
>             <annotation>@GET</annotation>
>             <annotation>@Path("/internal/types")</annotation>
>             <annotation>@Produces({ "application/json", "application/xml" })</annotation>
>           </annotations>
>           <version>1.0.0</version>
>           <code>  public Map<String,String> getMappingsAsString() {
> ...
>     <class jpa.entity="true">
>       <name>Param</name>
>       <packageName>com.jsonapps.model</packageName>
>       <annotations>
>         <annotation>@XmlRootElement</annotation>
>         <annotation>@Entity</annotation>
>         <annotation>@Table(name="params",uniqueConstraints={@UniqueConstraint(columnNames="param_id"),@UniqueConstraint(columnNames="param_name")})</annotation>
>       </annotations>
>       <version>1.0.0</version>
>       <fields>
>         <field>
>           <name>id</name>
>           <type>int</type>
>           <annotations>
>             <annotation>@Id</annotation>
>             <annotation>@SequenceGenerator(name="param_seq", sequenceName="param_pk_seq")</annotation>
>             <annotation>@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="param_seq")</annotation>
>             <annotation>@Column(name="param_id")</annotation>
>           </annotations>
>           <version>1.0.0</version>
>         </field>
> ...
>       <fields>
>         <field>
>           <name>em</name>
>           <type>javax.persistence.EntityManager</type>
>           <modifier>protected</modifier>
>           <version>1.0.0</version>
>         </field>

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email