jon 01/05/10 16:01:43
Modified: conf/torque/templates/om Peer.vm
Log:
support for abstract tables
Revision Changes Path
1.55 +40 -7 jakarta-turbine/conf/torque/templates/om/Peer.vm
Index: Peer.vm
===================================================================
RCS file: /home/cvs/jakarta-turbine/conf/torque/templates/om/Peer.vm,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- Peer.vm 2001/05/09 00:08:59 1.54
+++ Peer.vm 2001/05/10 23:01:42 1.55
@@ -116,7 +116,8 @@
}
-#if ($table.ChildrenColumn)
+#if ($table.ChildrenColumn || $table.isAbstract())
+
#set ($col = $table.ChildrenColumn)
#set ( $tfc=$table.JavaName )
#set ( $cfc=$col.JavaName )
@@ -161,7 +162,6 @@
}
return c;
}
-
#end
#end
#end
@@ -475,9 +475,14 @@
for ( int i=0; i<records.size(); i++ )
{
Record row = (Record)records.elementAt(i);
-#if ($table.ChildrenColumn)
+#if ($table.ChildrenColumn || $table.isAbstract())
+ #if ($table.isAbstract())
+ results.add(${table.JavaName}Peer.row2Object(row, 1,
+ ${table.JavaName}Peer.getOMClass()));
+ #else
results.add(${table.JavaName}Peer.row2Object(row, 1,
${table.JavaName}Peer.getOMClass(row, 1)));
+ #end
#else
results.add(${table.JavaName}Peer
.row2Object( row,1, CLASS_DEFAULT ));
@@ -485,11 +490,30 @@
}
return results;
}
+
+#if ($table.ChildrenColumn || $table.isAbstract())
+
+ #if ($table.isAbstract())
+
+ /**
+ * If the BO is abstract then you must implement this method
+ * in the BO.
+ */
+ public static Class getOMClass()
+ throws Exception
+ {
+ String error = "You must implement the getOMClass method in your";
+ error += " Peer object in order for things to work properly.";
+ error += " This method should return the proper Class that";
+ error += " represents the Peer's Business Object.";
+ throw new Exception (error);
+ }
-#if ($table.ChildrenColumn)
+ #else
+
#set ($col = $table.ChildrenColumn)
/**
- * The returned vector will contain objects of the default type or
+ * The returned Class will contain objects of the default type or
* objects that inherit from the default.
*/
public static Class getOMClass(Record record, int offset)
@@ -522,6 +546,7 @@
record.getValue(offset-1 + $col.Position).asString());
#end
}
+ #end
#end
@@ -1078,9 +1103,13 @@
Record row = (Record)rows.elementAt(i);
#set ($classDecl = "Class")
-#if ($table.ChildrenColumn)
+#if ($table.ChildrenColumn || $table.isAbstract())
#set ($col = $table.ChildrenColumn)
+ #if ($table.isAbstract())
+ $classDecl omClass = ${table.JavaName}Peer.getOMClass();
+ #else
$classDecl omClass = ${table.JavaName}Peer.getOMClass(row, 1);
+ #end
#set ($classDecl = "")
$className obj1 = ${table.JavaName}Peer
.row2Object( row, 1, omClass);
@@ -1091,10 +1120,10 @@
#if ($joinTable.ChildrenColumn)
+
#set ($col = $joinTable.ChildrenColumn)
$classDecl omClass = ${joinClassName}Peer.getOMClass(row, offset);
#set ($classDecl = "")
-
$joinClassName obj2 = ${joinClassName}Peer
.row2Object(row, offset, omClass);
#else
@@ -1235,7 +1264,11 @@
#set ($classDecl = "Class")
#if ($table.ChildrenColumn)
#set ($col = $table.ChildrenColumn)
+ #if ($table.isAbstract())
+ $classDecl omClass = ${table.JavaName}Peer.getOMClass();
+ #else
$classDecl omClass = ${table.JavaName}Peer.getOMClass(row, 1);
+ #end
#set ($classDecl = "")
$className obj1 = ${table.JavaName}Peer
.row2Object( row, 1, omClass);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]