// DO NOT EDIT. Make changes to ${entity.classNameWithOptionalPackage}.java instead. #if ($entity.superclassPackageName) package $entity.superclassPackageName; #end import com.webobjects.eocontrol.*; import com.webobjects.foundation.*; import java.math.*; import java.util.*; import org.apache.log4j.Logger; @SuppressWarnings("serial") public abstract class ${entity.prefixClassNameWithoutPackage} extends #if ($entity.parentSet)${entity.parent.classNameWithDefault}#elseif ($EOGenericRecord)${EOGenericRecord}#else EOGenericRecord#end { public static final String ENTITY_NAME = "$entity.name"; // Client-Side Attributes #foreach ($attribute in $entity.sortedClientClassAttributes) public static final String ${attribute.uppercaseUnderscoreName}_KEY = "$attribute.name"; #end // Client-Side Relationships #foreach ($relationship in $entity.sortedClientClassRelationships) public static final String ${relationship.uppercaseUnderscoreName}_KEY = "$relationship.name"; #end private static Logger LOG = Logger.getLogger(${entity.prefixClassNameWithoutPackage}.class); // Client-Side Attribute Getters and Setters #foreach ($attribute in $entity.sortedClientClassAttributes) #if (!$attribute.inherited) public $attribute.javaClassName ${attribute.name}() { return ($attribute.javaClassName) storedValueForKey(${attribute.uppercaseUnderscoreName}_KEY); } public void set${attribute.capitalizedName}($attribute.javaClassName ${attribute.name}) { #if ($attribute.javaClassName == "java.math.BigDecimal") if (${attribute.name} != null) { ${attribute.name} = ${attribute.name}.setScale(${attribute.scale}, RoundingMode.HALF_UP); } #end if (${entity.prefixClassNameWithoutPackage}.LOG.isDebugEnabled()) { ${entity.prefixClassNameWithoutPackage}.LOG.debug( "updating $attribute.name from " + ${attribute.name}() + " to " + ${attribute.name}); } takeStoredValueForKey(${attribute.name}, ${attribute.uppercaseUnderscoreName}_KEY); } #end #end #if (!$entity.abstractEntity) public ${entity.classNameWithOptionalPackage} create${entity.name}(EOEditingContext ec #foreach ($attribute in $entity.sortedClientClassAttributes) #if (!$attribute.allowsNull) #set ($restrictingQualifierKey = 'false') #foreach ($qualifierKey in $entity.restrictingQualifierKeys) #if ($attribute.name == $qualifierKey) #set ($restrictingQualifierKey = 'true') #end #end #if ($restrictingQualifierKey == 'false') #if ($attribute.userInfo.ERXConstantClassName) , ${attribute.userInfo.ERXConstantClassName} #else , ${attribute.javaClassName}#end ${attribute.name} #end #end #end #foreach ($relationship in $entity.sortedClientClassToOneRelationships) #if ($relationship.mandatory && !($relationship.ownsDestination && $relationship.propagatesPrimaryKey)) , ${relationship.actualDestination.classNameWithDefault} ${relationship.name} #end #end ) { ${entity.classNameWithOptionalPackage} new${entity.name} = new ${entity.classNameWithOptionalPackage}(); ec.insertObject(new${entity.name}); #foreach ($attribute in $entity.sortedClientClassAttributes) #if (!$attribute.allowsNull) #set ($restrictingQualifierKey = 'false') #foreach ($qualifierKey in $entity.restrictingQualifierKeys) #if ($attribute.name == $qualifierKey) #set ($restrictingQualifierKey = 'true') #end #end #if ($restrictingQualifierKey == 'false') new${entity.name}.set${attribute.capitalizedName}(${attribute.name}); #end #end #end #foreach ($relationship in $entity.sortedClientClassToOneRelationships) #if ($relationship.mandatory && !($relationship.ownsDestination && $relationship.propagatesPrimaryKey)) new${entity.name}.set${relationship.capitalizedName}Relationship(${relationship.name}); #end #end return new${entity.name}; } #end // Client-Side To-One Relationship Getters and Setters #foreach ($relationship in $entity.sortedClientClassToOneRelationships) #if (!$relationship.inherited) public $relationship.actualDestination.classNameWithDefault ${relationship.name}() { return ($relationship.actualDestination.classNameWithDefault) storedValueForKey(${relationship.uppercaseUnderscoreName}_KEY); } public void set${relationship.capitalizedName}($relationship.actualDestination.classNameWithDefault value) { if (${entity.prefixClassNameWithoutPackage}.LOG.isDebugEnabled()) { ${entity.prefixClassNameWithoutPackage}.LOG.debug("updating $relationship.name from " + ${relationship.name}() + " to " + value); } takeStoredValueForKey(value, ${relationship.uppercaseUnderscoreName}_KEY); } public void set${relationship.capitalizedName}Relationship($relationship.actualDestination.classNameWithDefault value) { if (${entity.prefixClassNameWithoutPackage}.LOG.isDebugEnabled()) { ${entity.prefixClassNameWithoutPackage}.LOG.debug("updating $relationship.name from " + ${relationship.name}() + " to " + value); } if (value == null) { if (${relationship.name}() != null) { removeObjectFromBothSidesOfRelationshipWithKey(${relationship.name}(), ${relationship.uppercaseUnderscoreName}_KEY); } } else { addObjectToBothSidesOfRelationshipWithKey(value, ${relationship.uppercaseUnderscoreName}_KEY); } } #end #end // Client-Side To-Many Relationship Getters and Setters #foreach ($relationship in $entity.sortedClientClassToManyRelationships) #if (!$relationship.inherited) @SuppressWarnings("unchecked") public NSArray ${relationship.name}() { return (NSArray) storedValueForKey(${relationship.uppercaseUnderscoreName}_KEY); } public void addTo${relationship.capitalizedName}Relationship($relationship.actualDestination.classNameWithDefault object) { if (${entity.prefixClassNameWithoutPackage}.LOG.isDebugEnabled()) { ${entity.prefixClassNameWithoutPackage}.LOG.debug("adding " + object + " to ${relationship.name} relationship"); } addObjectToBothSidesOfRelationshipWithKey(object, ${relationship.uppercaseUnderscoreName}_KEY); } public void removeFrom${relationship.capitalizedName}Relationship($relationship.actualDestination.classNameWithDefault object) { if (${entity.prefixClassNameWithoutPackage}.LOG.isDebugEnabled()) { ${entity.prefixClassNameWithoutPackage}.LOG.debug("removing " + object + " from ${relationship.name} relationship"); } removeObjectFromBothSidesOfRelationshipWithKey(object, ${relationship.uppercaseUnderscoreName}_KEY); } public $relationship.actualDestination.classNameWithDefault create${relationship.capitalizedName}Relationship() { EOClassDescription eoClassDesc = EOClassDescription.classDescriptionForEntityName("${relationship.actualDestination.name}"); EOEnterpriseObject eo = eoClassDesc.createInstanceWithEditingContext(editingContext(), null); editingContext().insertObject(eo); addObjectToBothSidesOfRelationshipWithKey(eo, ${relationship.uppercaseUnderscoreName}_KEY); return ($relationship.actualDestination.classNameWithDefault) eo; } public void delete${relationship.capitalizedName}Relationship($relationship.actualDestination.classNameWithDefault object) { removeObjectFromBothSidesOfRelationshipWithKey(object, ${relationship.uppercaseUnderscoreName}_KEY); #if (!$relationship.ownsDestination) editingContext().deleteObject(object); #end } public void deleteAll${relationship.capitalizedName}Relationships() { Enumeration objects = ${relationship.name}().immutableClone().objectEnumerator(); while (objects.hasMoreElements()) { delete${relationship.capitalizedName}Relationship(($relationship.actualDestination.classNameWithDefault)objects.nextElement()); } } #end #end }