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

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

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 Mac OS 10.5, (WO 5.4), even if you have the 5.3 frameworks installed, because the Java-objc bridge it uses is not available on 10.5. It uses MiscMerge templates, an open source objc library.

JavaEOGenerator is an Apple replacement that uses WO style templates (.html, .wod, etc.), which means it's 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 it's 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

There are two ways: create eclipse-wide settings, or create settings per project.

...

The WOLips EOGenerator is an integral part of WOLips and shares its codebase with Entity Modeler. It uses release 1.5 of the Velocity Templating Engine and template files that use the Velocity Template Language. This templating language is similar to the original Rubicode EOGenerator that many developers used with WebObjects 5.3 and earlier so migrating old templates to the new language is time consuming, but not difficult.

Default Setup

If you don't specify a custom template name in your .eogen file, then the WOLips EOGenerator will simply use the built-in ones. This is the way all developers should start out. You can always grab those templates and modify them, or use some of the many modifications shared by other WebObjects developers on the EOGenerator Templates and Additions page.

Customizing

There are two ways: create eclipse-wide settings, or create settings per project.

Note: There is actually no need to download Mike's templates as described below unless you want to customize them. WOLips includes two sets of default templates in the .jar files (so don't bother searching your file system for them) - one as described below and another for use with WOnder. If you are using WOnder, you need to follow Mike's instructions for their use: "Where it says "Entity.java" and "_Entity.java" you can use WonderEntity.java and _WonderEntity.java ... If your individual .eogen files override that, you will have to set it in there also". If you leave the "EOGenerator Template Folder" field empty, it will use the default templates...

eclipse-wide settings for EOGeneration

1. Download the templates that Mike Schrag made from httphttps://webobjectsgithub.mdimension.com/wolips/EOGeneratorwolips/Velocity%20EOGenerator%20Templates/tree/master/wolips/core/plugins/org.objectstyle.wolips.eogenerator.core/templates

and place them in a folder. In my case that was in

...

(Additional templates and a reference is are available [here|) 

2. Go to Preferences > WOLips > EOGenerator

...

7. If you are fine, you can start fine tuning your templates, or start defining templates per project.

making Velocity EOGenerator settings per project

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

...

3. Double check your model, so . It used to be true 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 could extend EOGenericRecord. That is no longer true and you can use either custom classes or EOGenericRecord as a class, or a mix of the two. We suggest that your entity classes should be in packages for this all to work optimally. In the example ", such as "your_com.projectname.eo._class". When it was tried with no package (class) there were If you use a class that is not in a package, there may be a number of errors in the resulting Java class files.

...