cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgen...@apache.org
Subject svn commit: r1206823 - in /cayenne/main/trunk/framework/cayenne-tools/src: main/resources/templates/v1_2/superclass.vm test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
Date Sun, 27 Nov 2011 20:16:42 GMT
Author: mgentry
Date: Sun Nov 27 20:16:41 2011
New Revision: 1206823

URL: http://svn.apache.org/viewvc?rev=1206823&view=rev
Log:
Update for CAY-1643, update Velocity templates to use _PROPERTY fields.

Modified:
    cayenne/main/trunk/framework/cayenne-tools/src/main/resources/templates/v1_2/superclass.vm
    cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java

Modified: cayenne/main/trunk/framework/cayenne-tools/src/main/resources/templates/v1_2/superclass.vm
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/main/resources/templates/v1_2/superclass.vm?rev=1206823&r1=1206822&r2=1206823&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-tools/src/main/resources/templates/v1_2/superclass.vm
(original)
+++ cayenne/main/trunk/framework/cayenne-tools/src/main/resources/templates/v1_2/superclass.vm
Sun Nov 27 20:16:41 2011
@@ -72,22 +72,22 @@ public abstract class ${superClassName} 
 #foreach( $attr in ${object.DeclaredAttributes} )
 #if ("true" != "${object.isReadOnly()}")
     public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type})
$stringUtils.formatVariableName(${attr.Name})) {
-        writeProperty("${attr.Name}", $stringUtils.formatVariableName(${attr.Name}));
+        writeProperty(${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY, $stringUtils.formatVariableName(${attr.Name}));
     }
 #end
 #if ( $importUtils.isBoolean(${attr.Type}) )
 	public boolean is${stringUtils.capitalized($attr.Name)}() {
-        Boolean value = (Boolean)readProperty("${attr.Name}");
+        Boolean value = (Boolean)readProperty(${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY);
         return (value != null) ? value.booleanValue() : false;
     }
 #elseif ( $importUtils.isNonBooleanPrimitive(${attr.Type}) )
     public ${importUtils.formatJavaType($attr.Type)} get${stringUtils.capitalized($attr.Name)}()
{
-        Object value = readProperty("${attr.Name}");
+        Object value = readProperty(${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY);
         return (value != null) ? ($importUtils.formatJavaTypeAsNonBooleanPrimitive(${attr.Type}))
value : 0;
     }
 #else
     public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}()
{
-        return ($importUtils.formatJavaType(${attr.Type}))readProperty("${attr.Name}");
+        return ($importUtils.formatJavaType(${attr.Type}))readProperty(${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY);
     }
 #end
 
@@ -98,31 +98,31 @@ public abstract class ${superClassName} 
 #if( $rel.ToMany )
 #if ( ! $rel.ReadOnly )
     public void addTo${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName})
obj) {
-        addToManyTarget("${rel.name}", obj, true);
+        addToManyTarget(${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY, obj, true);
     }
     public void removeFrom${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName})
obj) {
-        removeToManyTarget("${rel.name}", obj, true);
+        removeToManyTarget(${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY, obj,
true);
     }
 #end
     @SuppressWarnings("unchecked")
 #if ( ${rel.CollectionType} == "java.util.Map")
     public $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)),
$importUtils.formatJavaType($rel.TargetEntity.ClassName)> get${stringUtils.capitalized($rel.Name)}()
{
-        return ($importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)),
$importUtils.formatJavaType($rel.TargetEntity.ClassName)>)readProperty("${rel.name}");
+        return ($importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)),
$importUtils.formatJavaType($rel.TargetEntity.ClassName)>)readProperty(${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY);
     }
 #else
     public $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClassName)>
get${stringUtils.capitalized($rel.Name)}() {
-        return ($importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClassName)>)readProperty("${rel.name}");
+        return ($importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClassName)>)readProperty(${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY);
     }
 #end
 #else
 #if ( !${object.isReadOnly()} && !$rel.ReadOnly )
     public void set${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName})
$stringUtils.formatVariableName(${rel.name})) {
-        setToOneTarget("${rel.name}", $stringUtils.formatVariableName(${rel.name}), true);
+        setToOneTarget(${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY, $stringUtils.formatVariableName(${rel.name}),
true);
     }
 #end
 
     public $importUtils.formatJavaType(${rel.TargetEntity.ClassName}) get${stringUtils.capitalized($rel.Name)}()
{
-        return ($importUtils.formatJavaType(${rel.TargetEntity.ClassName}))readProperty("${rel.name}");
+        return ($importUtils.formatJavaType(${rel.TargetEntity.ClassName}))readProperty(${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY);
     }
 #end
 

Modified: cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java?rev=1206823&r1=1206822&r2=1206823&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
Sun Nov 27 20:16:41 2011
@@ -143,17 +143,17 @@ public class ClassGenerationActionTest e
         String superclass = generated.get(0);
         
         assertTrue(superclass, superclass.contains("public void setID(int ID)"));
-        assertTrue(superclass, superclass.contains("writeProperty(\"ID\", ID);"));
+        assertTrue(superclass, superclass.contains("writeProperty(ID_PROPERTY, ID);"));
         
         assertTrue(superclass, superclass.contains("public int getID()"));
-        assertTrue(superclass, superclass.contains("Object value = readProperty(\"ID\");"));
+        assertTrue(superclass, superclass.contains("Object value = readProperty(ID_PROPERTY);"));
         assertTrue(superclass, superclass.contains("return (value != null) ? (Integer) value
: 0;"));
         
         assertTrue(superclass, superclass.contains("public void setName(char name)"));
-        assertTrue(superclass, superclass.contains("writeProperty(\"name\", name);"));
+        assertTrue(superclass, superclass.contains("writeProperty(NAME_PROPERTY, name);"));
         
         assertTrue(superclass, superclass.contains("public char getName()"));
-        assertTrue(superclass, superclass.contains("Object value = readProperty(\"name\");"));
+        assertTrue(superclass, superclass.contains("Object value = readProperty(NAME_PROPERTY);"));
         assertTrue(superclass, superclass.contains("return (value != null) ? (Character)
value : 0;"));
 
     }



Mime
View raw message