RE: Cayenne Enumerations

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Jun 14 2005 - 12:11:39 EDT

  • Next message: Mike Kienenberger: "Re: Cayenne Enumerations"

    But what is the point of having an automated generator (template or bash
    script), if you have to hardcode all the value-to-name mapping in this
    script (or a separate XML file)? It seems to me that creating a Java class
    by hand is the same amount of work. What would XML file buy you?

    Andrus

    > I'm not certain a DB is the place to keep that information. To generate
    > the enumerations, you would need to know the superclass (integer or
    > string), the enumeration class name, the symbolic names and database
    > values (these would be in pairs). You'd also need conditionals around
    > the initializers and constructor, depending on if it is integer or
    > string based.
    >
    > I'm pretty sure I could wing it with a bash script, but that wouldn't be
    > too friendly to the Windows users. I'll ponder it a bit more. The data
    > source which describes the enumerations could be a flat-type
    > configuration file or XML, but I'd hate for people to have to edit XML
    > by hand. Of course, creating enumerations by hand could be cumbersome,
    > too.
    >
    > Is the "fromPropertiesFile" a cgen thing? Maybe I could look into that
    > ...
    >
    > Thanks,
    >
    > /dev/mrg
    >
    >
    > -----Original Message-----
    > From: Mike Kienenberger [mailto:mkienen..laska.net]
    > Sent: Tuesday, June 14, 2005 11:34 AM
    > To: cayenne-use..bjectstyle.org
    > Cc: cayenne-use..bjectstyle.org
    > Subject: Re: Cayenne Enumerations
    >
    >
    > Andrus Adamchik <andru..bjectstyle.org> wrote:
    >> But even with a template I still don't understand where would you get
    > the
    >> enum info. E.g. if you have a color enum (RED -> 1, GREEN -> 2, BLUE
    > ->
    >> 3), there is nothing in the DataMap that would allow you to generate
    > such
    >> class.
    >
    > I probably should have been more clear about the enumeration generation
    > tool:
    >
    > You'd have it do something along the lines of "select distinct COLUMN
    > from
    > TABLE" from the datasource. -- those would be your enumerations. At
    > least,
    > I'm guessing that's what Michael had in mind.
    >
    > #foreach ($enumerationValue in
    > $enumerationGeneratorTool.fromDistinctColumnValues(DATASOURCEINFO,
    > TABLE,
    > COLUMN))
    >
    > Or from a property file:
    >
    > #foreach ($enumerationValue in
    > $enumerationGeneratorTool.fromPropertiesFile(FILENAME))
    >
    > etc
    >
    > -Mike
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Jun 14 2005 - 12:11:40 EDT