Changes for page EOGenerator

Last modified by David Avendasora on 2011/08/25 00:02

From version 78.1
edited by Chuck Hill
on 2008/07/31 18:13
Change comment: There is no comment for this version
To version 80.1
edited by David Avendasora
on 2011/08/25 00:02
Change comment: Migrated to Confluence 5.3

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -Velocity EOGenerator (Veogen)
1 +EOGenerator
Parent
... ... @@ -1,0 +1,1 @@
1 +Home
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.chillatgvc
1 +XWiki.avendasora
Content
... ... @@ -1,52 +1,39 @@
1 -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.
1 +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>>url:http://velocity.apache.org||shape="rect"]] and template files that use the [[Velocity Template Language>>url:http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html||shape="rect"]]. 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.
2 2  
3 -See also [[EOGenerator Templates & Additions>>EOGenerator Templates and Additions]] for detailed information on template contents.
3 +=== Default Setup ===
4 4  
5 -=== History and Context ===
5 +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 [[doc:EOGenerator Templates and Additions]] page.
6 6  
7 -(from Pierce T Wetter III)
8 -EOModeler had built in code generation, which always sucked, because it didn't use the [[Generation Gap Pattern>>http://www.research.ibm.com/designpatterns/pubs/gg.html]]. It used some kind of Apple-specific template format.
7 +=== Customizing ===
9 9  
10 -[[EOGenerator>>http://www.rubicode.com/Software/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.
11 -
12 -[[JavaEOGenerator>>http://developer.apple.com/samplecode/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.
13 -
14 -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>>http://velocity.apache.org/engine/releases/velocity-1.5/vtl-reference-guide.html]], [[Velocity>>http://velocity.apache.org/]] 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).
15 -
16 -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.
17 -
18 -=== Tutorial ===
19 -
20 20  There are two ways: create eclipse-wide settings, or create settings per project.
21 21  
22 -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...
11 +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...
23 23  
24 24  ==== eclipse-wide settings for EOGeneration ====
25 25  
26 -~1. Download the templates that Mike Schrag made from [[http://webobjects.mdimension.com/wolips/EOGenerator/Velocity%20EOGenerator%20Templates/]]
15 +~1. Download the templates that Mike Schrag made from [[https:~~/~~/github.com/wolips/wolips/tree/master/wolips/core/plugins/org.objectstyle.wolips.eogenerator.core/templates>>url:https://github.com/wolips/wolips/tree/master/wolips/core/plugins/org.objectstyle.wolips.eogenerator.core/templates||shape="rect"]]
27 27  
28 28  and place them in a folder. In my case that was in
29 29  
30 30  /Applications/Developing/VelocityEOGeneratorTemplates
31 31  
32 -Inside this folder you will have two standard templates: Entity.java en Entity.java. Do not change them for the moment.
21 +Inside this folder you will have two standard templates: _Entity.java en Entity.java. Do not change them for the moment.
33 33  
34 -(Additional templates and a reference are available [[here>>EOGenerator Templates and Additions]])
23 +(Additional templates and a reference are available [[here>>doc:EOGenerator Templates and Additions]])
35 35  
36 -2. Go to Preferences > WOLips > EOGenerator
25 +2. Go to Preferences > WOLips > EOGenerator
37 37  
38 38  In EOGenerator Template Folder, fill in the folder you have placed the templates
39 -In EOGenerator Java Template fill in Entity.java
40 -In EOGenerator Subclass Java Template fill in Entity.java
28 + In EOGenerator Java Template fill in _Entity.java
29 + In EOGenerator Subclass Java Template fill in Entity.java
41 41  
42 42  This is how it looks in my settings:
43 43  
44 44  {{panel bgColor="#d8e4f1"}}
45 45  
46 -\\ !VEOGeneratorSettingsEclipse.png|align=center!\\
47 -\\
48 -\\
49 -
35 +[[image:attach:VEOGeneratorSettingsEclipse.png]]
36 +\\\\\\
50 50  {{/panel}}
51 51  
52 52  3. Go to the eomodel from which you want to create classes and subclasses in the WOPackage sidebar of Eclipse
... ... @@ -55,22 +55,18 @@
55 55  
56 56  {{panel bgColor="#d8e4f1"}}
57 57  
58 -\\ !CreateEOGenContextualMenu.png|align=center!\\
59 -\\
60 -\\
61 -
45 +[[image:attach:CreateEOGenContextualMenu.png]]
46 +\\\\\\
62 62  {{/panel}}
63 63  
64 64  Now a eogen file is created which has the name of the EOModel and an .eogen extension.
65 -If there is already an eogen file, then another one will be created, with a number between the EOModel name and the extension.
66 -The one with the highest number will be the newest (unless you decided to throw earlier ones away, then the numbering starts all over again).
50 + If there is already an eogen file, then another one will be created, with a number between the EOModel name and the extension.
51 + The one with the highest number will be the newest (unless you decided to throw earlier ones away, then the numbering starts all over again).
67 67  
68 68  {{panel bgColor="#d8e4f1"}}
69 69  
70 -\\ !MoreEogenfiles.png|align=center!\\
71 -\\
72 -\\
73 -
55 +[[image:attach:MoreEogenfiles.png]]
56 +\\\\\\
74 74  {{/panel}}
75 75  
76 76  5. Go to the eogen file, right click and choose EOGenerate... from the contextual menu.
... ... @@ -77,15 +77,13 @@
77 77  
78 78  {{panel bgColor="#d8e4f1"}}
79 79  
80 -\\ !EOGenerateContextualMenu.png|align=center!\\
81 -\\
82 -\\
83 -
63 +[[image:attach:EOGenerateContextualMenu.png]]
64 +\\\\\\
84 84  {{/panel}}
85 85  
86 86  If you have some definitions in your EOModel that have a Class Name that is not an EOGenericRecord, then the appropriate java class and subclass will be generated.
87 87  
88 -For instance: a Person class name in EOModel will result in a Person.java file (which will be overwritten the next time EOGeneration will take place) and a Person.java file. The java file without the underscore is the file that will not be overwritten the next time. This file is the file that you would add your own methods. The next time the model changes, the underscore.java file will be overwritten, but your methods are safe.
69 +For instance: a Person class name in EOModel will result in a _Person.java file (which will be overwritten the next time EOGeneration will take place) and a Person.java file. The java file without the underscore is the file that will not be overwritten the next time. This file is the file that you would add your own methods. The next time the model changes, the _underscore.java file will be overwritten, but your methods are safe.
89 89  
90 90  6. Check if everything worked out fine. If not (e.g. you made a typing error and a java file happens to be empty) throw away the generated file yo do not want, and restart the process.
91 91  
... ... @@ -94,43 +94,35 @@
94 94  ==== making Velocity EOGenerator settings per project ====
95 95  
96 96  ~1. Under Preferences > WOLips > EOGenerator
97 -~> Remove all entries (this is not strictly necessary, but it rules out any errors at the project level)
78 + -> Remove all entries (this is not strictly necessary, but it rules out any errors at the project level)
98 98  
99 99  {{panel bgColor="#d8e4f1"}}
100 100  
101 -\\ !1. EOGenerator Project.png|align=center!\\
102 -\\
103 -\\
104 -
82 +[[image:attach:1. EOGenerator Project.png]]
83 +\\\\\\
105 105  {{/panel}}
106 106  
107 107  2. Add a folder named templates in your project folder, inside of which you place your template files.
108 -For starters, don't rename them. You can download them here:
109 -[[http://webobjects.mdimension.com/wolips/EOGenerator/Velocity%20EOGenerator%20Templates/]]
87 + For starters, don't rename them. You can download them here:
88 + [[http:~~/~~/webobjects.mdimension.com/wolips/EOGenerator/Velocity%20EOGenerator%20Templates/>>url:http://webobjects.mdimension.com/wolips/EOGenerator/Velocity%20EOGenerator%20Templates/||shape="rect"]]
110 110  
111 111  {{panel bgColor="#d8e4f1"}}
112 112  
113 -\\ !2. Directory Structure.png|align=center!\\
114 -\\
115 -\\
116 -
92 +[[image:attach:2. Directory Structure.png]]
93 +\\\\\\
117 117  {{/panel}}
118 118  
119 119  Other options for Veogen to pick up any changes you wish to make to the templates:
120 120  
121 -* 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.
122 -* 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).//,,
98 +* 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.
99 +* 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).
123 123  
124 -3. Double check your model, so that none of your entities extend EOGenericRecord,
125 -otherwise the generation gap pattern won't work, as the velocity generator generates all files,
126 -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.
101 +3. Double check your model. It used to be true that none of 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, such as "your_com.projectname.eo_class". If you use a class that is not in a package, there may be a number of errors in the resulting Java class files.
127 127  
128 128  {{panel bgColor="#d8e4f1"}}
129 129  
130 -\\ !3. Entities Snapshot.png|align=center!\\
131 -\\
132 -\\
133 -
105 +[[image:attach:3. Entities Snapshot.png]]
106 +\\\\\\
134 134  {{/panel}}
135 135  
136 136  4. Create or edit your .eogen file, mine looks like this:
... ... @@ -137,17 +137,17 @@
137 137  
138 138  {{panel bgColor="#d8e4f1"}}
139 139  
140 -\\ !4. Config Overview.png|align=center!\\
141 -\\
142 -\\
143 -
113 +[[image:attach:4. Config Overview.png]]
114 +\\\\\\
144 144  {{/panel}}
145 145  
146 146  5. Double check, and open the .eogen file using open with > text editor. The whole command must all be on a single line; this is formatted for clarity:
147 147  
148 148  {{panel bgColor="#d8e4f1"}}
120 +
149 149  
150 -{code}
122 +{{code}}
123 +
151 151  1. -destination Sources
152 152   -java
153 153   -javaTemplate _Entity.java
... ... @@ -157,26 +157,22 @@
157 157   -subclassJavaTemplate Entity.java
158 158   -templatedir templates
159 159   -verbose
160 -{code}
161 161  
134 +{{/code}}
162 162  {{/panel}}
163 163  
164 -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~://
137 +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:
165 165  
166 166  {{panel bgColor="#d8e4f1"}}
167 167  
168 -\\ !select.png|align=center!\\
169 -\\
170 -\\
171 -
141 +[[image:attach:select.png]]
142 +\\\\\\
172 172  {{/panel}}
173 173  
174 -7. Then uncheck 'EOGenerator Files':
145 +7. Then uncheck 'EOGenerator _Files':
175 175  
176 176  {{panel bgColor="#d8e4f1"}}
177 177  
178 -\\ !filters.png|align=center!\\
179 -\\
180 -\\
181 -
149 +[[image:attach:filters.png]]
150 +\\\\\\
182 182  {{/panel}}
1. EOGenerator Project.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +62.0 KB
Content
2. Directory Structure.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +28.5 KB
Content
3. Entities Snapshot.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +53.9 KB
Content
4. Config Overview.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +71.9 KB
Content
5. Text Config.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +26.9 KB
Content
CreateEOGenContextualMenu.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +127.4 KB
Content
EOGenerateContextualMenu.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +31.8 KB
Content
MoreEogenfiles.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +7.2 KB
Content
VEOGeneratorSettingsEclipse.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +86.9 KB
Content
filters.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +52.5 KB
Content
select.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +64.3 KB
Content