Wiki source code of Generating EO Java Classes

Version 45.1 by Kieran Kelleher on 2007/07/29 16:00

Hide last authors
Mike Schrag 41.1 1 WOLips encapsulates the functionality of [[EOGenerator>>http://www.rubicode.com/Software/EOGenerator/]] so that the Java classes can be generated from within Eclipse. WOLips can create an **.eogen** definition for you when the model is created or you can create one after the model has been created by going to **File** **New** **Other...** and selecting **EOGenerator**.
chuckhill 18.1 2
Kieran Kelleher 25.1 3 === Install and Configure EOGenerator ===
chuckhill 18.1 4
Kieran Kelleher 45.1 5 Before you can generate Java classes you will need to download (from [[http://www.rubicode.com/Software/EOGenerator/]]) and install EOGenerator. **EOGenerator is not part of Eclipse or WOLips.** It is a command line tool which needs a number of parameters/preferences to run. **Do not use** EOGenerator's instructions for installation as an Eclipse builder. EOGenerator is run using a WOLips configuration. After it is installed, tell Eclipse/WOLips where it is in preferences:
chuckhill 18.1 6
ianjoyner 33.1 7 [[image:EOGeneratorPreferences.jpg]]
Kieran Kelleher 25.1 8
9 === Setup Configuration for a Model ===
10
bardi 37.1 11 The next step is to fill in the .eogen configuration for your model.
Kieran Kelleher 25.1 12
13 {{info title="Multiple Models"}}
14
bardi 37.1 15 If you have multiple models that you need to generate Java classes for, and they need different settings (templates, destination directories etc), each of these will need its own .eogen configuration.
Kieran Kelleher 25.1 16
17 {{/info}}
18
Mike Schrag 41.1 19 {{info title="Autogenerating"}}
20
Mike Schrag 43.1 21 If you already have an EOModel file that opens in Entity Modeler properly, you can bypass the manual .eogen file creation described below by right-clicking on your EOModel in WOLips and selecting WOLips Tools=>Create EOGenerator File.
Mike Schrag 41.1 22
23 {{/info}}
24
bardi 37.1 25 Double click on the <ModelName>.eogen icon in the Package Explorer or Navigator:
Kieran Kelleher 25.1 26 [[image:eogenIcon.jpg]]
27 The top section of the editor looks like this:
28
29 [[image:EOGenerator1.jpg]]
30
31 Set the model(s) to generate Java for in the first area. In the second include models containing prototypes and models that are referenced by the models in the first group, but which should not have Java generated for the entities in them.
32
bardi 37.1 33 The File Names settings can be ignored unless you need to generate oddly formed file names. You will usually want to **Create Packages** (place the generated files in a directory corresponding to their package). It can useful to have different **Destination** and **Subclass Destination** directories. The totally generated classes in the Destination directory are not very interesting and can be tucked away out of sight.
chuckhill 18.1 34
35 [[image:EOGenerator2.jpg]]
36
37 The **Templates** determine how the Java code is generated. The setting should be self explanatory. The **Defines** are useful for extending the templates with custom values.
38
39 [[image:EOGenerator3.jpg]]
40
41 === Generate the Classes ===
42
Kieran Kelleher 45.1 43 ==== The Simplest Way is Set it on Automatic ====
chuckhill 18.1 44
Kieran Kelleher 45.1 45 Use the WOLips build preferences to ensure your classes are regenerated every time you save changes to the EOModel
chuckhill 18.1 46
Kieran Kelleher 45.1 47 {{panel}}
chuckhill 18.1 48
Kieran Kelleher 45.1 49 !Picture 16.jpg!
chuckhill 18.1 50
Kieran Kelleher 45.1 51 {{/panel}}
chuckhill 18.1 52
Kieran Kelleher 45.1 53 ==== Manual Generation during Development ====
chuckhill 18.1 54
Kieran Kelleher 45.1 55 To generate the Java classes manually, simply right (control) click on the .eogen configuration and select **EOGenerate...** from the context menu. A dialog window will be shown when EOGenerator finishes so that you can verify what it did.
chuckhill 18.1 56
Kieran Kelleher 45.1 57 ==== Troubleshooting ====
ianjoyner 33.1 58
Kieran Kelleher 45.1 59 {{note title="EOGenerator Not Running?"}}
ianjoyner 33.1 60
Kieran Kelleher 45.1 61 Nothing happens? Just see a flicker of a progress bar at the bottom right? Go back to the Preferences. The path to the eogenerator executable is missing or incorrect.
ianjoyner 33.1 62
Kieran Kelleher 45.1 63 {{/note}}