Re: Cayenne Modeler Question

From: Mike Kienenberger (mkienen..mail.com)
Date: Wed Oct 17 2007 - 11:03:23 EDT

  • Next message: Mike Kienenberger: "Re: More on Callbacks!"

    On 10/16/07, Dov Rosenberg <DRosenber..nquira.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.



    This archive was generated by hypermail 2.0.0 : Wed Oct 17 2007 - 11:10:55 EDT