Changes for page EOF-Using EOF-EOGenerator
Last modified by Pascal Robert on 2012/01/21 22:03
From version 21.1
edited by Pascal Robert
on 2007/12/21 20:55
on 2007/12/21 20:55
Change comment:
There is no comment for this version
To version 32.2
edited by Pascal Robert
on 2012/01/21 22:03
on 2012/01/21 22:03
Change comment:
Changed document parent to [xwiki:WO.Home.Deprecated.WebHome].
Summary
-
Page properties (3 modified, 0 added, 0 removed)
-
Objects (0 modified, 1 added, 0 removed)
Details
- Page properties
-
- Parent
-
... ... @@ -1,0 +1,1 @@ 1 +WO.Home.Deprecated.WebHome - Tags
-
... ... @@ -1,0 +1,1 @@ 1 +wikireview - Content
-
... ... @@ -1,14 +1,20 @@ 1 -|= Contents 2 -| {{toc style="disc" minLevel="2"}}{{/toc}} 1 +{{warning}} 2 +This is deprecated information! 3 +{{/warning}} 3 3 5 +|=((( 6 +Contents 7 +))) 8 +|((( 9 +{{toc minLevel="2" style="disc"/}} 10 +))) 11 + 4 4 == Overview == 5 5 6 -If you've ever used EOModeler's Java source code generator, you know how much of a pain it can be when you make changes to your model objects and have to merge changes in later. 14 +If you've ever used EOModeler's Java source code generator, you know how much of a pain it can be when you make changes to your model objects and have to merge changes in later. One solution for this is to use [[EOGenerator>>url:http://www.rubicode.com/Software/EOGenerator/||shape="rect"]], an application developed by Rubicode Software, which uses the Generation Gap pattern to create your Java files from your EOModels. EOGenerator produces TWO java files for each Entity rather than one. Take the example of a Person entity. The first java file is _Person.java, which contains all of the autogenerated methods. The second java file is Person.java, and Person extends _Person. The second file is where you place all of your customizations. Any time your model changes, only your _Xxx.java files are updated, and your customizations are left untouched. Additionally, EOGenerator allows for the creation of extensive custom templates for your files, which provides the ability to place convenience methods in your _Xxx.java files. 7 7 8 8 {{warning}} 9 - 10 -EOGenerator don't work on Mac OS X 10.5. You either have to use [JavaEOGenerator|http://developer.apple.com/samplecode/JavaEOGenerator/] or [Velocity EOGenerator|WOL:Velocity EOGenerator (Veogen)]. 11 - 17 +EOGenerator doesn't work on Mac OS X 10.5. You have to use [[JavaEOGenerator>>url:http://developer.apple.com/samplecode/JavaEOGenerator/||shape="rect"]] or [[Velocity EOGenerator>>doc:WOL.Velocity EOGenerator (Veogen)]]. 12 12 {{/warning}} 13 13 14 14 == Advantages == ... ... @@ -15,45 +15,43 @@ 15 15 16 16 There are several advantages to using EOGenerator over EOModeler's default Java file generation and merging with FileMerge. 17 17 18 -* EOGenerator uses the Generation Gap pattern, which provides a much cleaner separation of autogenerated vs customized code with no need to deal with merging at all. 19 -* EOGenerator uses the MiscMerge language for its templates. 24 +* EOGenerator uses the Generation Gap pattern, which provides a much cleaner separation of autogenerated vs customized code with no need to deal with merging at all. There are border cases with FileMerge that can cause you to deal with annoying conflicts. 25 +* EOGenerator uses the MiscMerge language for its templates. This allows you to extend the core templates with extensive customizations (see the EOGenerator Mods section below), better supporting your own custom development process and workflow. 20 20 * As David LaBer put it, "all the cool kids use it - and we all know looking cool is the **most** important criteria". 21 21 22 22 == How To Use It == 23 23 24 -Kieran Kelleher has writtten an [[Introduction to EOGenerator>>http://homepage.mac.com/kelleherk/iblog/C1837526061/E1908382110/index.html]] on his blog. 30 +Kieran Kelleher has writtten an [[Introduction to EOGenerator>>url:http://homepage.mac.com/kelleherk/iblog/C1837526061/E1908382110/index.html||shape="rect"]] on his blog. 25 25 26 -It's actually very simple to use. 32 +It's actually very simple to use. The quick start is: 27 27 28 28 * Download and untar EOGenerator from the Rubicode site 29 29 * Run the following command: 30 30 31 31 {{panel}} 32 - 33 -eogenerator \-model /path/to/model/YourModel.eomodeld \-destination /path/to/source/folder 34 -\-subclassDestination /path/to/source/folder \-templatedir /path/to/EOGenerator/templates \-java \-packagedirs 35 - 38 +eogenerator -model /path/to/model/YourModel.eomodeld -destination /path/to/source/folder 39 + -subclassDestination /path/to/source/folder -templatedir /path/to/EOGenerator/templates -java -packagedirs 36 36 {{/panel}} 37 37 38 -Voila. 42 +Voila. EOGenerator will spit out your Java files for you. Let's break down the commands you can pass in: 39 39 40 -* define-EOGenericRecord <class>, allows you to specify the Person class's superclass. 41 -* destination <path>, the folder that Person.java-style java files will be produced in (the non-editable files) 42 -* java, produce java files 43 -* javaTemplate <filename>, the name of the Java template to use inside of the template dir ( //Person)//44 -* model <path>, Passes in the path of a .eomodeld you would like to generate Java files for. 45 -* packagedirs, produce package directory for any package statements defined in your Java files (not necessary if you don't specify package names on your entities. :-))46 -* refmodel <path>, Passes in the path of an .eomodeld that is required for generating Java files, but that won't actually have Java files generated for it. For instance, you should refmodel any prototypes, or any models in other frameworks that you depend on 47 -* subclassDestination <path>, the folder that Person.java-style java files will be produced in (the editable files) 48 -* subclassJavaTemplate <filename>, the name of the Java subclass template to use inside of the template dir (Person) 49 -* templatedir <path>, the path to the folder that contains EOGenerator templates 50 -* verbose, turn on verbose output 44 +* -define-EOGenericRecord <class>, allows you to specify the _Person class's superclass. For instance, if you use Project Wonder, you would specify -define-EOGenericRecord er.extensions.ERXGenericRecord 45 +* -destination <path>, the folder that _Person.java-style java files will be produced in (the non-editable files) 46 +* -java, produce java files 47 +* -javaTemplate <filename>, the name of the Java template to use inside of the template dir (_Person) 48 +* -model <path>, Passes in the path of a .eomodeld you would like to generate Java files for. You can actually include multiple -model commands on the commandline 49 +* -packagedirs, produce package directory for any package statements defined in your Java files (not necessary if you don't specify package names on your entities. By the way, you should specify packages on your entities ) 50 +* -refmodel <path>, Passes in the path of an .eomodeld that is required for generating Java files, but that won't actually have Java files generated for it. For instance, you should -refmodel any prototypes, or any models in other frameworks that you depend on 51 +* -subclassDestination <path>, the folder that Person.java-style java files will be produced in (the editable files) 52 +* -subclassJavaTemplate <filename>, the name of the Java subclass template to use inside of the template dir (Person) 53 +* -templatedir <path>, the path to the folder that contains EOGenerator templates 54 +* -verbose, turn on verbose output 51 51 52 52 == Custom EOGenerator Mods == 53 53 54 54 === Zak Burke === 55 55 56 -Allow setting nulls on a to-one relationship (and turn it into a remove). 60 +Allow setting nulls on a to-one relationship (and turn it into a remove). Note, this is also included in Jonathan Rentzsch's templates. 57 57 58 58 {{code}} 59 59 ... ... @@ -90,12 +90,12 @@ 90 90 91 91 Jonathan Rentzsch has provided his base EOGenerator templates, which are a must-have: 92 92 93 -[[http://rentzsch.com/share/eogenerator52templates.zip]] 97 +[[http:~~/~~/rentzsch.com/share/eogenerator52templates.zip>>url:http://rentzsch.com/share/eogenerator52templates.zip||shape="rect"]] 94 94 95 95 === Markus Ruggiero === 96 96 97 97 Constants for all attributes and relationships. This allows compile time error checking in situations like 98 -addObjecttoBothSidesOfRelationshipWithKey(myObject, Person.TO //MANY//Children)102 + addObjecttoBothSidesOfRelationshipWithKey(myObject, Person.TO_MANY_Children) 99 99 100 100 {{code}} 101 101 ... ... @@ -139,7 +139,7 @@ 139 139 140 140 === Mike Schrag === 141 141 142 -Add a constant that represents the name of the entity so that you can refer to Person.ENTITY //NAME in fetches rather than the String (allows refactoring support in Eclipse)~://146 +Add a constant that represents the name of the entity so that you can refer to Person.ENTITY_NAME in fetches rather than the String (allows refactoring support in Eclipse): 143 143 144 144 {{code}} 145 145 ... ... @@ -160,7 +160,7 @@ 160 160 161 161 {{/code}} 162 162 163 -Here's a little bitty fancier (read: nastier) version that also handles superclass mandatory attributes and fields (one level). 167 +Here's a little bitty fancier (read: nastier) version that also handles superclass mandatory attributes and fields (one level). It skips any attribute that is referenced in the restricting qualifier of your subclass (since you are probably going to set that in your awakeFromInsertion): 164 164 165 165 {{code}} 166 166 ... ... @@ -175,26 +175,21 @@ 175 175 176 176 {{/code}} 177 177 178 -Add a bunch of convience fetch methods (fetchAllPersons, fetchRequiredPerson, and other variants). 182 +Add a bunch of convience fetch methods (fetchAllPersons, fetchRequiredPerson, and other variants). It's not smart about pluralization, so it's just going to put an "s" on the end of the entity name: 179 179 180 180 {{code}} 181 - 182 182 public static NSArray fetchAll<$classNameWithoutPackage$>s(EOEditingContext _editingContext) { 183 183 return <$GEN_PREFIX$><$classNameWithoutPackage$>.fetchAll<$classNameWithoutPackage$>s(_editingContext, null); 184 184 } 188 +{{/code}} 185 185 186 -{{/code}} 187 - 188 188 {{code}} 189 - 190 190 public static NSArray fetchAll<$classNameWithoutPackage$>s(EOEditingContext _editingContext, NSArray _sortOrderings) { 191 191 return <$GEN_PREFIX$><$classNameWithoutPackage$>.fetch<$classNameWithoutPackage$>s(_editingContext, null, _sortOrderings); 192 192 } 194 +{{/code}} 193 193 194 -{{/code}} 195 - 196 196 {{code}} 197 - 198 198 public static NSArray fetch<$classNameWithoutPackage$>s(EOEditingContext _editingContext, EOQualifier _qualifier, NSArray _sortOrderings) { 199 199 EOFetchSpecification fetchSpec = new EOFetchSpecification(<$GEN_PREFIX$><$classNameWithoutPackage$>.ENTITY_NAME, _qualifier, _sortOrderings); 200 200 fetchSpec.setIsDeep(true); ... ... @@ -201,19 +201,15 @@ 201 201 NSArray eoObjects = _editingContext.objectsWithFetchSpecification(fetchSpec); 202 202 return eoObjects; 203 203 } 203 +{{/code}} 204 204 205 -{{/code}} 206 - 207 207 {{code}} 208 - 209 209 public static <$classNameWithoutPackage$> fetch<$classNameWithoutPackage$>(EOEditingContext _editingContext, String _keyName, Object _value) { 210 210 return <$GEN_PREFIX$><$classNameWithoutPackage$>.fetch<$classNameWithoutPackage$>(_editingContext, new EOKeyValueQualifier(_keyName, EOQualifier.QualifierOperatorEqual, _value)); 211 211 } 209 +{{/code}} 212 212 213 -{{/code}} 214 - 215 215 {{code}} 216 - 217 217 public static <$classNameWithoutPackage$> fetch<$classNameWithoutPackage$>(EOEditingContext _editingContext, EOQualifier _qualifier) { 218 218 NSArray eoObjects = <$GEN_PREFIX$><$classNameWithoutPackage$>.fetch<$classNameWithoutPackage$>s(_editingContext, _qualifier, null); 219 219 <$classNameWithoutPackage$> eoObject; ... ... @@ -229,17 +229,14 @@ 229 229 } 230 230 return eoObject; 231 231 } 227 +{{/code}} 232 232 233 -{{/code}} 234 - 235 235 {{code}} 236 - 237 237 public static <$classNameWithoutPackage$> fetchRequired<$classNameWithoutPackage$>(EOEditingContext _editingContext, String _keyName, Object _value) { 238 238 return <$GEN_PREFIX$><$classNameWithoutPackage$>.fetchRequired<$classNameWithoutPackage$>(_editingContext, new EOKeyValueQualifier(_keyName, EOQualifier.QualifierOperatorEqual, _value)); 239 239 } 233 +{{/code}} 240 240 241 -{{/code}} 242 - 243 243 {{code}} 244 244 245 245 public static <$classNameWithoutPackage$> fetchRequired<$classNameWithoutPackage$>(EOEditingContext _editingContext, EOQualifier _qualifier) { ... ... @@ -252,16 +252,14 @@ 252 252 253 253 {{/code}} 254 254 255 -Add methods for getting local instances of EO's. 247 +Add methods for getting local instances of EO's. The static one is handy if you have a reference to an EO that might be null (it does a null check first): 256 256 257 257 {{code}} 258 - 259 259 public <$classNameWithoutPackage$> localInstanceOf<$classNameWithoutPackage$>(EOEditingContext _editingContext) { 260 260 return (<$classNameWithoutPackage$>)EOUtilities.localInstanceOfObject(_editingContext, this); 261 261 } 253 +{{/code}} 262 262 263 -{{/code}} 264 - 265 265 {{code}} 266 266 267 267 public static <$classNameWithoutPackage$> localInstanceOf<$classNameWithoutPackage$>(EOEditingContext _editingContext, <$classNameWithoutPackage$> _eo) { ... ... @@ -326,7 +326,7 @@ 326 326 327 327 === John Huss === 328 328 329 -I wanted to share a wonderful bit of knowledge I learned today. 319 +I wanted to share a wonderful bit of knowledge I learned today. If you're using Java 1.5 you can add @SuppressWarnings("all") to the template for your _EO base classes and eliminate annoying compiler messages (usually uneeded import statements). 330 330 331 331 {{code}} 332 332
- XWiki.XWikiComments[0]
-
- Date
-
... ... @@ -1,0 +1,1 @@ 1 +2007-12-12 21:55:29.0 - Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.probert - Comment
-
... ... @@ -1,0 +1,1 @@ 1 +Please information about how to use the Java-based tools that are replacing EOGenerator.