Re: EOGenerator and prototypes
Re: EOGenerator and prototypes
- Subject: Re: EOGenerator and prototypes
- From: Mike Schrag <email@hidden>
- Date: Tue, 15 May 2007 07:02:07 -0400
It does not, by default, generate the correct subclass because I
believe EO doesn't give back anything but Number. Here's is the
workaround from a discussion thread a while back:
<$foreach Attribute classAttributes.@sortedNameArray do$><$if
Attribute.userInfo.ERXConstantClassName.length > 0$>
public <$Attribute.userInfo.ERXConstantClassName$> <$Attribute.name
$>() {
Number value = (Number)storedValueForKey("<$Attribute.name$>");
return (<$Attribute.userInfo.ERXConstantClassName$>)value;
}
public void set<$Attribute.name.initialCapitalString$>(<
$Attribute.userInfo.ERXConstantClassName$> aValue) {
takeStoredValueForKey(aValue, "<$Attribute.name$>");
}
<$else$><$
identify currentValueType = Attribute.javaValueClassName$><$
if currentValueType == 'Number'$><$
if Attribute.valueType == 'B'$><$
identify currentValueType = 'BigDecimal'$><$
elseif Attribute.valueType == 'b'$><$
identify currentValueType = 'Byte'$><$
elseif Attribute.valueType == 'd'$><$
identify currentValueType = 'Double'$><$
elseif Attribute.valueType == 'f'$><$
identify currentValueType = 'Float'$><$
elseif Attribute.valueType == 'i'$><$
identify currentValueType = 'Integer'$><$
elseif Attribute.valueType == 'l'$><$
identify currentValueType = 'Long'$><$
elseif Attribute.valueType == 's'$><$
identify currentValueType = 'Short'$><$
endif$><$
endif$>
public <$currentValueType$> <$Attribute.name$>() {
return (<$currentValueType$>) storedValueForKey("<$Attribute.name
$>");
}
public void set<$Attribute.name.initialCapitalString$>(<
$currentValueType$> aValue) {
if (<$GEN_PREFIX$><$classNameWithoutPackage$>.LOG.isDebugEnabled
()) {
<$GEN_PREFIX$><$classNameWithoutPackage$>.LOG.debug( "updating
<$Attribute.name$> from "+<$Attribute.name$>()+" to "+aValue );
}
takeStoredValueForKey(aValue, "<$Attribute.name$>");
}
<$endif$>
and the same thing in the .createXxx "constructor" functions that I use:
public static <$classNameWithoutPackage$> create<
$classNameWithoutPackage$>(EOEditingContext editingContext<$foreach
Attribute classAttributes.@sortedNameArray do$><$if !
Attribute.allowsNull$>, <$if
Attribute.userInfo.ERXConstantClassName.length > 0$><
$Attribute.userInfo.ERXConstantClassName$><$else$><$
identify currentValueType = Attribute.javaValueClassName$><$
if currentValueType == 'Number'$><$
if Attribute.valueType == 'B'$><$
identify currentValueType = 'BigDecimal'$><$
elseif Attribute.valueType == 'b'$><$
identify currentValueType = 'Byte'$><$
elseif Attribute.valueType == 'd'$><$
identify currentValueType = 'Double'$><$
elseif Attribute.valueType == 'f'$><$
identify currentValueType = 'Float'$><$
elseif Attribute.valueType == 'i'$><$
identify currentValueType = 'Integer'$><$
elseif Attribute.valueType == 'l'$><$
identify currentValueType = 'Long'$><$
elseif Attribute.valueType == 's'$><$
identify currentValueType = 'Short'$><$
endif$><$
endif$><$currentValueType$><$endif$> <$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$>, <$if
Attribute.userInfo.ERXConstantClassName.length > 0$><
$Attribute.userInfo.ERXConstantClassName$><$else$><$
identify currentValueType = Attribute.javaValueClassName$><$
if currentValueType == 'Number'$><$
if Attribute.valueType == 'B'$><$
identify currentValueType = 'BigDecimal'$><$
elseif Attribute.valueType == 'b'$><$
identify currentValueType = 'Byte'$><$
elseif Attribute.valueType == 'd'$><$
identify currentValueType = 'Double'$><$
elseif Attribute.valueType == 'f'$><$
identify currentValueType = 'Float'$><$
elseif Attribute.valueType == 'i'$><$
identify currentValueType = 'Integer'$><$
elseif Attribute.valueType == 'l'$><$
identify currentValueType = 'Long'$><$
elseif Attribute.valueType == 's'$><$
identify currentValueType = 'Short'$><$
endif$><$
endif$><$currentValueType$><$endif$> <$Attribute.name$><$endif$><
$endif$><$endforeach do$><$foreach ToOneRelationship
classToOneRelationships.@sortedNameArray do$><$if
ToOneRelationship.isMandatory and !(ToOneRelationship.ownsDestination
and ToOneRelationship.propagatesPrimaryKey) $>, <
$ToOneRelationship.destinationEntity.referenceJavaClassName$> <
$ToOneRelationship.name$><$endif$><$endforeach do$><$foreach
ToOneRelationship
parentEntity.classToOneRelationships.@sortedNameArray do$><$if
ToOneRelationship.isMandatory and !(ToOneRelationship.ownsDestination
and ToOneRelationship.propagatesPrimaryKey)$>, <
$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 and !(ToOneRelationship.ownsDestination
and ToOneRelationship.propagatesPrimaryKey)$>
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$>
eoObject.set<$Attribute.name.initialCapitalString$>(<
$Attribute.name$>);<$endif$><$endif$><$endforeach do$><$foreach
ToOneRelationship
parentEntity.classToOneRelationships.@sortedNameArray do$><$if
ToOneRelationship.isMandatory and !(ToOneRelationship.ownsDestination
and ToOneRelationship.propagatesPrimaryKey)$>
eoObject.set<$ToOneRelationship.name.initialCapitalString
$>Relationship(<$ToOneRelationship.name$>);<$endif$><$endforeach do$>
return eoObject;
}
On May 15, 2007, at 12:24 AM, Lachlan Deck wrote:
Hi there,
I've just reworked a model to utilise a prototypes model - but when
eogenerating the classes I'm finding that I'm no longer getting
BigDecimal, for example, in the signature but Number instead.
e.g.,
// template snippet...
public <$Attribute.javaValueClassName$> <$Attribute.name$>() {
return ( <$Attribute.javaValueClassName$> )storedValueForKey( <
$Attribute.name.initialCapitalString$>Key );
}
// is producing something like:
public Number name() {
return ( Number )storedValueForKey( NameKey );
}
Example prototype:
MyPrototypes.eomodeld/
EOJDBCMySQLPrototypes.plist
<...>
{
allowsNull = Y;
columnName = "";
externalType = NUMERIC;
name = "decimal(14,2)";
precision = 14;
scale = 2;
valueClassName = NSNumber;
valueType = B;
},
<...>
Any ideas?
with regards,
--
Lachlan Deck
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mdimension.com
This email sent to email@hidden
_______________________________________________
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