You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Dov Rosenberg <DR...@Inquira.Com> on 2007/10/17 03:11:12 UTC

Cayenne Modeler Question

I am interested in perhaps using the Cayenne Modeler to do some additional
tasks. Specifically I was interested in adding in some additional data into
the cayenne.xml or *.map.xml files for our own usage (like indexes,
constraints, comments and potentially other stuff specific to our
application). I would like to add my own code generators to be able to
generate other config and documentation files as well.

Does the Cayenne Modeler have any documentation on where I might change
things or add new functionality. I don¹t think my changes would be of
interest to the general public (maybe)

Thanks in advance

Dov Rosenberg



Re: Cayenne Modeler Question

Posted by Mike Kienenberger <mk...@gmail.com>.
On 10/16/07, Dov Rosenberg <DR...@inquira.com> wrote:
> I am interested in perhaps using the Cayenne Modeler to do some additional
> tasks. Specifically I was interested in adding in some additional data into
> the cayenne.xml or *.map.xml files for our own usage (like indexes,
> constraints, comments and potentially other stuff specific to our
> application). I would like to add my own code generators to be able to
> generate other config and documentation files as well.
>
> Does the Cayenne Modeler have any documentation on where I might change
> things or add new functionality. I don¹t think my changes would be of
> interest to the general public (maybe)


Dov, as Andrus pointed out, most of what you've asked for has been
requested in the past, so it's definitely of interest to the general
public.

Here's generally how it would work:

Add a field with accessors to a meta object,

src/cayenne/java/org/apache/cayenne/map/*.java, for instance,
description to DbEntity.

protected String description;
public String getDescription() { return description; }
public void setDescription(String description) { this.description =
description; }

Add an encoder entry for writing the field out in the same file:

       if (null != getDescription()) {
           encoder.print(" description=\"");
           encoder.print(getDescription());
           encoder.print('\"');
       }

In src/cayenne/java/org/apache/cayenne/map/MapLoader.java, add code
for reading the value into the modeler to the appropriate method.

For example, processStartDbEntity()

       String description = atts.getValue("", "description");
       if (description != null) {
          dbEntity.setDescription(description);
      }

At this point you have the ability to hold, save, and load the attribute value.

At some point, we should probably clean up the modeler code so that
the loading/saving occurs in the same place.


> I would like to add my own code generators to be able to
> generate other config and documentation files as well.

This is already supported by the modeler as well as by the ant cgen
task.   All you need to do is create a new template and specify the
necessary generator options for your particular situation.

Re: Cayenne Modeler Question

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi Dov,

Some objects in cayenne.xml and *.map.xml support a <property> child  
tag, so standard XML format is almost suitable for what you are  
looking for. Also there is an often-requested and a long-standing  
issue [1] to implement support for arbitrary properties for all  
mapped objects in the Modeler and runtime. Would be nice if your work  
would advance this task as well. (and we need to address it at some  
point, I am really embarrassed that we haven't yet).


> Does the Cayenne Modeler have any documentation on where I might  
> change
> things or add new functionality.

Not really. But I think it won't be too hard to find your way around.  
Please ask questions on the dev list about specific things you want  
to do, and somebody should be able to point you in the right direction.

Thanks
Andrus


[1] https://issues.apache.org/cayenne/browse/CAY-400


On Oct 17, 2007, at 4:11 AM, Dov Rosenberg wrote:
> I am interested in perhaps using the Cayenne Modeler to do some  
> additional
> tasks. Specifically I was interested in adding in some additional  
> data into
> the cayenne.xml or *.map.xml files for our own usage (like indexes,
> constraints, comments and potentially other stuff specific to our
> application). I would like to add my own code generators to be able to
> generate other config and documentation files as well.
>
> Does the Cayenne Modeler have any documentation on where I might  
> change
> things or add new functionality. I don’t think my changes would be of
> interest to the general public (maybe)
>
> Thanks in advance
>
> Dov Rosenberg
>
>