Author: tfischer
Date: Fri Mar 2 04:18:24 2012
New Revision: 1296047
URL: http://svn.apache.org/viewvc?rev=1296047&view=rev
Log:
TORQUE-180 make more easily testable by allowing the save method location being
set on the table itself
Modified:
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/saveMethods.vm
Modified:
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java?rev=1296047&r1=1296046&r2=1296047&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java
(original)
+++
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java
Fri Mar 2 04:18:24 2012
@@ -462,8 +462,27 @@ public class OMTableTransformer extends
SourceElement tableElement,
ControllerState controllerState)
{
- boolean saveMethodsInDbObjects = controllerState.getBooleanOption(
- TemplateOptionName.OM_SAVE_METHODS_IN_DB_OBJECTS);
+ // check save method location definitions (prio descending):
+ // - Attribute saveMethodsInDbObjects in table
+ // - option TemplateOptionName.OM_SAVE_METHODS_IN_DB_OBJECTS
+ String saveMethodLocationOptionName
+ = TemplateOptionName.OM_SAVE_METHODS_IN_DB_OBJECTS.getName();
+ String saveMethodLocationAttributeName
+ = saveMethodLocationOptionName.substring(
+ saveMethodLocationOptionName.lastIndexOf('.') + 1);
+ boolean saveMethodsInDbObjects;
+ if (tableElement.getAttribute(saveMethodLocationAttributeName) != null)
+ {
+ saveMethodsInDbObjects = Boolean.parseBoolean(
+ tableElement.getAttribute(saveMethodLocationAttributeName)
+ .toString());
+ }
+ else
+ {
+ saveMethodsInDbObjects = controllerState.getBooleanOption(
+ TemplateOptionName.OM_SAVE_METHODS_IN_DB_OBJECTS);
+ }
+
if (!saveMethodsInDbObjects)
{
tableElement.setAttribute(
Modified:
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/saveMethods.vm
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/saveMethods.vm?rev=1296047&r1=1296046&r2=1296047&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/saveMethods.vm
(original)
+++
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/saveMethods.vm
Fri Mar 2 04:18:24 2012
@@ -199,12 +199,12 @@
#set ( $foreignField =
$referencingForeignKeyElement.getChild("foreign-field").getAttribute("field"))
#set ( $foreignFieldGetter =
$referencingForeignKeyElement.getChild("foreign-field").getAttribute("getter"))
#set ( $foreignFieldIsInitialized =
$referencingForeignKeyElement.getChild("foreign-field").getAttribute("isInitialized"))
- #if (${torqueGen.booleanOption("torque.om.saveMethodsInDbObjects")})
- #set ( $otherObjectContainsSaveMethod = ${foreignField} )
- #set ( $otherToSaveVariableWithComma = "" )
- #else
+ #if ($otherTable.getAttribute("saveMethodToSaveVariable"))
#set ( $otherObjectContainsSaveMethod = $otherPeerClassName )
#set ( $otherToSaveVariableWithComma = "${foreignField}, " )
+ #else
+ #set ( $otherObjectContainsSaveMethod = ${foreignField} )
+ #set ( $otherToSaveVariableWithComma = "" )
#end
## if the referencing table is in an external schema, field is null.
## In this case,skip the following code
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]