To edit or add content to this Wiki, you can simply create a new account at http://wocommunity.org/account.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

This is a basic guide to getting the Velocity Generator to work under Leopard, using Eclipse 3.3.1.1 and WOLips 3.3.4669, later versions should work. The guide is basic in that it should work the way it's detailed below, it doesn't represent the only way, nor probably an optimized way to work with Velocity Generator

History and Context

(from Pierce T Wetter III)
EOModeler had built in code generation, which always sucked, because it didn't use the Generation Gap Pattern. It used some kind of Apple-specific template format.

EOGenerator, written in objc, relied on an objc-EOF framework to parse the model. That's broken in 5.4, not sure about 5.3/Leopard but I think so. It uses MiscMerge templates, an open source objc library.

What people are calling JavaEOGenerator is an Apple replacement that uses WO style templates (.html, .wod, etc.), which means its actually written as a .woa. It uses the WO code to parse the model. The advantage of it is that if Apple changes the model file format, presumably they might change JavaEOGenerator. The disadvantage is that you have to rewrite your templates anyways.

What people are calling VelocityGenerator is built into WOLips, and uses the code from EntityModeler inside WOLips to parse the model. Given that Apple is funding EntityModeler these days, presumably it will be inherently compatible with any/all .eomodel files going forward. It uses a template library in Velocity format, Velocity being an open source Java library. It's main advantage is that its built into WOLips, so there's nothing else to install, and it has some useful built-in defaults (like looking in a templates folder for the templates).

My decision: After considering the above, I went with the Velocity templates. They were built in, the .eogen default was to use that anyways, so I'll have zero-config issues with the other team members, and Mike Shrag's public much-more-capable template examples were in that format anyways.

Tutorial

1. Under Preferences > WOLips > EOGenerator
-> Remove all entries (this is not strictly necessary, but it rules out any errors at the project level)

2. Add a folder named templates in your project folder, inside of which you place your template files.
For starters, don't rename them. You can download them here:
http://webobjects.mdimension.com/wolips/EOGenerator/Velocity%20EOGenerator%20Templates/

Other options for Veogen to pick up any changes you wish to make to the templates:

  • inside your eogen file you need to set template path to the folder containing _Entity.java, and if it's named something other than _Entity.java, you need to also set template name. Note that template name is ONLY a name, not a full path.
  • or locate the template files in one of the paths that Velocity EOGenerator looks in by default (~/Library/Application Support/WOLips/EOGenerator/_Entity.java, for example).

3. Double check your model, so that none of your entities extend EOGenericRecord,
otherwise the generation gap pattern won't work, as the velocity generator generates all files,
rather than just those extending custom classes. this is a change from the old eogenerator. Also, your entities should be in packages for this all to work optimally. In the example "projectname.eo.class". When it was tried with no package (class) there were a number of errors in the resulting Java class files.

4. Create or edit your .eogen file, mine looks like this:

5. Double check, and open the .eogen file using open with > text editor:

6. If you are not seeing your entity files that start with the underscore character "_" in Eclipse, it is because you have them filtered out. Select filters from the down triangle in the package explorer:

7. Then uncheck 'EOGenerator _Files':

  • No labels