handy eogenerator template
handy eogenerator template
- Subject: handy eogenerator template
- From: Mike Schrag <email@hidden>
- Date: Wed, 31 Aug 2005 18:46:49 -0400
Here's a new eogenerator method I added to my template that I thought
other people might find handy. It creates a factory method on each
entity like:
(from the _MyEO class):
public static MyEO createMyEO(EOEditingContext _editingContext,
NSTimestamp _requiredAttr1, NSTimestamp _requiredAttr2,
com.whatever.model.AnotherEO _mandatoryToOneEO) {
MyEO eoObject = (MyEO)EOUtilities.createAndInsertInstance
(_editingContext, _MyEO.ENTITY_NAME);
eoObject.setRequiredAttr1(_requiredAttr1);
eoObject.setRequiredAttr2(_requiredAttr2);
eoObject.setMandatoryToOneEORelationship(_mandatoryToOneEO);
return eoObject;
}
where the parameters to the method are all of the not-null attributes
and mandatory to-one relationships of the EO.
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$>) {
<$classNameWithoutPackage$> eoObject = (<
$classNameWithoutPackage$>)EOUtilities.createAndInsertInstance
(_editingContext, <$GEN_PREFIX$><$classNameWithoutPackage
$>.ENTITY_NAME);<$foreach Attribute classAttributes.@sortedNameArray
do$><$if !Attribute.allowsNull$>
eoObject.set<$Attribute.name.initialCapitalString$>
(_<$Attribute.name$>);<$endif$><$endforeach do$><$foreach
ToOneRelationship classToOneRelationships.@sortedNameArray do$><$if
ToOneRelationship.isMandatory$>
eoObject.set<
$ToOneRelationship.name.initialCapitalString$>Relationship(_<
$ToOneRelationship.name$>);<$endif$><$endforeach do$>
return eoObject;
}
note, it depends on having:
public static final String ENTITY_NAME = "<$name$>";
and also rentzsch's setXxxRelationship to-one set methods.
ms
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden