cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From and...@apache.org
Subject svn commit: r723425 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/map/ClientObjAttribute.java main/java/org/apache/cayenne/map/ObjAttribute.java test/java/org/apache/cayenne/map/ObjEntityTest.java
Date Thu, 04 Dec 2008 20:29:02 GMT
Author: andrey
Date: Thu Dec  4 12:29:02 2008
New Revision: 723425

URL: http://svn.apache.org/viewvc?rev=723425&view=rev
Log:
CAY-991 isMandatory() and getMaxLength() should be members of ObjAttributeб not only ClientObjAttribute

ObjAttribute API Change

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ClientObjAttribute.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/ObjEntityTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ClientObjAttribute.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ClientObjAttribute.java?rev=723425&r1=723424&r2=723425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ClientObjAttribute.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ClientObjAttribute.java
Thu Dec  4 12:29:02 2008
@@ -42,6 +42,7 @@
     /**
      * @see DbAttribute#isMandatory()
      */
+    @Override
     public boolean isMandatory() {
         return mandatory;
     }
@@ -53,6 +54,7 @@
     /**
      * @see DbAttribute#getMaxLength()
      */
+    @Override
     public int getMaxLength() {
         return maxLength;
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java?rev=723425&r1=723424&r2=723425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
Thu Dec  4 12:29:02 2008
@@ -250,6 +250,7 @@
      * @deprecated since 3.0 - this method only works for non-flattened attributes.
      *             'setDbAttributePath' should be used instead.
      */
+    @Deprecated
     public void setDbAttribute(DbAttribute dbAttribute) {
         if (dbAttribute == null) {
             setDbAttributePath(null);
@@ -282,6 +283,7 @@
      * 
      * @deprecated since 3.0 use {@link #setDbAttributePath(String)}.
      */
+    @Deprecated
     public void setDbAttributeName(String name) {
         setDbAttributePath(name);
     }
@@ -306,6 +308,7 @@
     /**
      * @deprecated since 3.0 use 'isFlattened'.
      */
+    @Deprecated
     public boolean isCompound() {
         return isFlattened();
     }
@@ -319,6 +322,24 @@
     public boolean isFlattened() {
         return dbAttributePath != null && dbAttributePath.indexOf('.') >= 0;
     }
+    
+    /**
+     * Returns whether this attribute is mandatory
+     * @see DbAttribute#isMandatory()
+     */
+    public boolean isMandatory() {
+        DbAttribute dbAttribute = getDbAttribute();
+        return dbAttribute == null ? false : dbAttribute.isMandatory();
+    }
+    
+    /**
+     * Returns this attribute's maximum allowed length
+     * @see DbAttribute#getMaxLength()
+     */
+    public int getMaxLength() {
+        DbAttribute dbAttribute = getDbAttribute();
+        return dbAttribute == null ? -1 : dbAttribute.getMaxLength();
+    }
 
     /**
      * Returns an ObjAttribute stripped of any server-side information, such as
@@ -339,8 +360,8 @@
                 attribute.setPrimaryKey(true);
             }
 
-            attribute.setMandatory(dbAttribute.isMandatory());
-            attribute.setMaxLength(dbAttribute.getMaxLength());
+            attribute.setMandatory(isMandatory());
+            attribute.setMaxLength(getMaxLength());
         }
 
         // TODO: will likely need "userForLocking" property as well.

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/ObjEntityTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/ObjEntityTest.java?rev=723425&r1=723424&r2=723425&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/ObjEntityTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/ObjEntityTest.java
Thu Dec  4 12:29:02 2008
@@ -103,10 +103,19 @@
         assertEquals("java.lang.Integer", clientmpk.getType());
         assertTrue(clientMeaningfulPKE.getAttributes().contains(clientmpk));
     }
+    
+    public void testAttributes() {
+        ObjEntity artistE = getObjEntity("Artist");
+        ObjAttribute attr = (ObjAttribute) artistE.getAttribute("artistName");
+        
+        assertEquals(attr.getMaxLength(), attr.getDbAttribute().getMaxLength());
+        assertEquals(attr.isMandatory(), attr.getDbAttribute().isMandatory());
+    }
 
     /**
      * @deprecated since 3.0 as the method being tested is deprecated.
      */
+    @Deprecated
     public void testLastPathComponentLegacy() {
         ObjEntity artistE = getObjEntity("Artist");
 



Mime
View raw message