"Gentry, Michael (Contractor)" <michael_gentr..anniemae.com> wrote:
> 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
No, what I was trying to say is that the source of the enumerations could be
anything, and would be delegated to an "enumeration generator" java class.
They could be retrieved from the database (which would most likely be my use
case), or from a property file, or from whatever other source you wanted --
$enumerationGeneratorTool.fromBashScript(FILE).
We could provide some convenient default implementations (grabbing them from
the database or manually specifying them via the modeler application =>
file), but it could be left open for providing alternative enumeration data
sources.
I'm just throwing out vague ideas, not providing any specific implementation
details.
If we're merging this into Cayenne versus just a local mod, you'd probably
want to have enumerationGeneratorTool initialized with the data in the
constructor or setup, and then just have
$enumerationGeneratorTool.getEnumerations() called from the template.
-Mike
> -----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:17:57 EDT