Changes for page EOF-Using EOF-EOGenerator
Last modified by Pascal Robert on 2012/01/21 22:03
From version 28.1
edited by Quinton Dolan
on 2007/07/16 22:26
on 2007/07/16 22:26
Change comment:
There is no comment for this version
To version 27.1
edited by Quinton Dolan
on 2007/07/09 06:52
on 2007/07/09 06:52
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -145,27 +145,79 @@ 145 145 146 146 Add a static factory method to your EO's ( Person createPerson(...) ) that shows you what required attributes and relationships are configured for you entity (attempts to provide a replacement "constructor" since EO constructors are empty): 147 147 148 -{{code bar="true"}}148 +{{code}} 149 149 150 -public static <$classNameWithoutPackage$> create<$classNameWithoutPackage$>(EOEditingContext _editingContext<$foreach Attribute classAttributes.@sortedNameArray do$><$if !Attribute.allowsNull$>, <$Attribute.javaValueClassName$> _<$Attribute.name$><$endif$><$endforeach do$><$foreach ToOneRelationship classToOneRelationships.@sortedNameArray do$><$if ToOneRelationship.isMandatory$>, <$ToOneRelationship.destinationEntity.referenceJavaClassName$> _<$ToOneRelationship.name$><$endif$><$endforeach do$>) { 151 - <$classNameWithoutPackage$> eoObject = (<$classNameWithoutPackage$>)EOUtilities.createAndInsertInstance(_editingContext, <$GEN_PREFIX$><$classNameWithoutPackage$>.ENTITY_NAME);<$foreach Attribute classAttributes.@sortedNameArray do$><$if !Attribute.allowsNull$> 152 - eoObject.set<$Attribute.name.initialCapitalString$>(_<$Attribute.name$>);<$endif$><$endforeach do$><$foreach ToOneRelationship classToOneRelationships.@sortedNameArray do$><$if ToOneRelationship.isMandatory$> 153 - eoObject.set<$ToOneRelationship.name.initialCapitalString$>Relationship(_<$ToOneRelationship.name$>);<$endif$><$endforeach do$> 154 - return eoObject; 155 -} 150 + public static <$classNameWithoutPackage$> create<$classNameWithoutPackage$>(EOEditingContext _editingContext< 151 + $foreach Attribute classAttributes.@sortedNameArray do$>< 152 + $if !Attribute.allowsNull$>, <$Attribute.javaValueClassName$> _<$Attribute.name$><$endif$>< 153 + $endforeach do$>< 154 + $foreach ToOneRelationship classToOneRelationships.@sortedNameArray do$>< 155 + $if ToOneRelationship.isMandatory$>, <$ToOneRelationship.destinationEntity.referenceJavaClassName$> _<$ToOneRelationship.name$><$endif$>< 156 + $endforeach do$>) { 157 + <$classNameWithoutPackage$> eoObject = (<$classNameWithoutPackage$>)EOUtilities.createAndInsertInstance(_editingContext, 158 + <$GEN_PREFIX$><$classNameWithoutPackage$>.ENTITY_NAME);< 159 + $foreach Attribute classAttributes.@sortedNameArray do$>< 160 + $if !Attribute.allowsNull$> 161 + eoObject.set<$Attribute.name.initialCapitalString$>(_<$Attribute.name$>);< 162 + $endif$>< 163 + $endforeach do$>< 164 + $foreach ToOneRelationship classToOneRelationships.@sortedNameArray do$>< 165 + $if ToOneRelationship.isMandatory$> 166 + eoObject.set<$ToOneRelationship.name.initialCapitalString$>Relationship(_<$ToOneRelationship.name$>);< 167 + $endif$>< 168 + $endforeach do$> 169 + return eoObject; 170 + } 156 156 157 157 {{/code}} 158 158 159 159 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): 160 160 161 -{{code bar="true"}}176 +{{code}} 162 162 163 -public static <$classNameWithoutPackage$> create<$classNameWithoutPackage$>(EOEditingContext editingContext<$foreach Attribute classAttributes.@sortedNameArray do$><$if !Attribute.allowsNull$>, <$Attribute.javaValueClassName$> <$Attribute.name$><$endif$><$endforeach do$><$foreach Attribute parentEntity.classAttributes.@sortedNameArray do$><$if !Attribute.allowsNull$><$set RestrictingQualifierKey = false$><$foreach QualifierKey restrictingQualifier.allQualifierKeys do$><$if Attribute.name = QualifierKey$><$set RestrictingQualifierKey = true$><$endif$><$endforeach do$><$if RestrictingQualifierKey = false$>, <$Attribute.javaValueClassName$> <$Attribute.name$><$endif$><$endif$><$endforeach do$><$foreach ToOneRelationship classToOneRelationships.@sortedNameArray do$><$if ToOneRelationship.isMandatory$>, <$ToOneRelationship.destinationEntity.referenceJavaClassName$> <$ToOneRelationship.name$><$endif$><$endforeach do$><$foreach ToOneRelationship parentEntity.classToOneRelationships.@sortedNameArray do$><$if ToOneRelationship.isMandatory$>, <$ToOneRelationship.destinationEntity.referenceJavaClassName$> <$ToOneRelationship.name$><$endif$><$endforeach do$>) { 164 - <$classNameWithoutPackage$> eoObject = (<$classNameWithoutPackage$>)EOUtilities.createAndInsertInstance(editingContext, <$GEN_PREFIX$><$classNameWithoutPackage$>.ENTITY_NAME);<$foreach Attribute classAttributes.@sortedNameArray do$><$if !Attribute.allowsNull$> 165 - eoObject.set<$Attribute.name.initialCapitalString$>(<$Attribute.name$>);<$endif$><$endforeach do$><$foreach ToOneRelationship classToOneRelationships.@sortedNameArray do$><$if ToOneRelationship.isMandatory$> 166 - eoObject.set<$ToOneRelationship.name.initialCapitalString$>Relationship(<$ToOneRelationship.name$>);<$endif$><$endforeach do$><$foreach Attribute parentEntity.classAttributes.@sortedNameArray do$><$if !Attribute.allowsNull$><$set RestrictingQualifierKey = false$><$foreach QualifierKey restrictingQualifier.allQualifierKeys do$><$if Attribute.name = QualifierKey$><$set RestrictingQualifierKey = true$><$endif$><$endforeach do$><$if RestrictingQualifierKey = false$> 167 - eoObject.set<$Attribute.name.initialCapitalString$>(<$Attribute.name$>);<$endif$><$endif$><$endforeach do$><$foreach ToOneRelationship parentEntity.classToOneRelationships.@sortedNameArray do$><$if ToOneRelationship.isMandatory$> 168 - eoObject.set<$ToOneRelationship.name.initialCapitalString$>Relationship(<$ToOneRelationship.name$>);<$endif$><$endforeach do$> 178 +public static <$classNameWithoutPackage$> create<$classNameWithoutPackage$>(EOEditingContext editingContext< 179 + $foreach Attribute classAttributes.@sortedNameArray do$>< 180 + $if !Attribute.allowsNull$>, <$Attribute.javaValueClassName$> <$Attribute.name$><$endif$>< 181 + $endforeach do$>< 182 + $foreach Attribute parentEntity.classAttributes.@sortedNameArray do$>< 183 + $if !Attribute.allowsNull$><$set RestrictingQualifierKey = false$>< 184 + $foreach QualifierKey restrictingQualifier.allQualifierKeys do$>< 185 + $if Attribute.name = QualifierKey$><$set RestrictingQualifierKey = true$><$endif$>< 186 + $endforeach do$><$if RestrictingQualifierKey = false$>, <$Attribute.javaValueClassName$> <$Attribute.name$><$endif$>< 187 + $endif$>< 188 + $endforeach do$>< 189 + $foreach ToOneRelationship classToOneRelationships.@sortedNameArray do$>< 190 + $if ToOneRelationship.isMandatory$>, <$ToOneRelationship.destinationEntity.referenceJavaClassName$> <$ToOneRelationship.name$><$endif$>< 191 + $endforeach do$>< 192 + $foreach ToOneRelationship parentEntity.classToOneRelationships.@sortedNameArray do$>< 193 + $if ToOneRelationship.isMandatory$>, <$ToOneRelationship.destinationEntity.referenceJavaClassName$> <$ToOneRelationship.name$><$endif$>< 194 + $endforeach do$>) { 195 + <$classNameWithoutPackage$> eoObject = (<$classNameWithoutPackage$>)EOUtilities.createAndInsertInstance(editingContext, <$GEN_PREFIX$><$classNameWithoutPackage$>.ENTITY_NAME);< 196 + $foreach Attribute classAttributes.@sortedNameArray do$>< 197 + $if !Attribute.allowsNull$> 198 + eoObject.set<$Attribute.name.initialCapitalString$>(<$Attribute.name$>);< 199 + $endif$>< 200 + $endforeach do$>< 201 + $foreach ToOneRelationship classToOneRelationships.@sortedNameArray do$>< 202 + $if ToOneRelationship.isMandatory$> 203 + eoObject.set<$ToOneRelationship.name.initialCapitalString$>Relationship(<$ToOneRelationship.name$>);< 204 + $endif$>< 205 + $endforeach do$>< 206 + $foreach Attribute parentEntity.classAttributes.@sortedNameArray do$>< 207 + $if !Attribute.allowsNull$><$set RestrictingQualifierKey = false$>< 208 + $foreach QualifierKey restrictingQualifier.allQualifierKeys do$>< 209 + $if Attribute.name = QualifierKey$><$set RestrictingQualifierKey = true$><$endif$>< 210 + $endforeach do$>< 211 + $if RestrictingQualifierKey = false$> 212 + eoObject.set<$Attribute.name.initialCapitalString$>(<$Attribute.name$>);< 213 + $endif$>< 214 + $endif$>< 215 + $endforeach do$>< 216 + $foreach ToOneRelationship parentEntity.classToOneRelationships.@sortedNameArray do$>< 217 + $if ToOneRelationship.isMandatory$> 218 + eoObject.set<$ToOneRelationship.name.initialCapitalString$>Relationship(<$ToOneRelationship.name$>);< 219 + $endif$>< 220 + $endforeach do$> 169 169 return eoObject; 170 170 } 171 171