Author: torehalset
Date: Sat Sep 30 15:13:57 2006
New Revision: 451684

URL: http://svn.apache.org/viewvc?view=rev&rev=451684
Log:
CAY-674

Added:
    
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/ClientObjAttribute.java
Modified:
    
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/ObjAttribute.java

Added: 
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/ClientObjAttribute.java
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/ClientObjAttribute.java?view=auto&rev=451684
==============================================================================
--- 
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/ClientObjAttribute.java
 (added)
+++ 
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/ClientObjAttribute.java
 Sat Sep 30 15:13:57 2006
@@ -0,0 +1,70 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.map;
+
+/**
+ * A client version of ObjAttribute that has some properties from DbAttribute 
that the
+ * client may want.
+ * 
+ * @author Tore Halset
+ * @since 3.0
+ */
+public class ClientObjAttribute extends ObjAttribute {
+    
+    protected boolean mandatory;
+    protected int maxLength = -1;
+
+
+    public ClientObjAttribute() {
+        super();
+    }
+
+    public ClientObjAttribute(String name, String type, ObjEntity entity) {
+        super(name, type, entity);
+    }
+
+    public ClientObjAttribute(String name) {
+        super(name);
+    }
+
+    /**
+     * 
+     * @see DbAttribute#isMandatory()
+     */
+    public boolean isMandatory() {
+        return mandatory;
+    }
+
+    public void setMandatory(boolean mandatory) {
+        this.mandatory = mandatory;
+    }
+    
+    /**
+     * 
+     * @see DbAttribute#getMaxLength()
+     */
+    public int getMaxLength() {
+        return maxLength;
+    }
+
+    public void setMaxLength(int maxLength) {
+        this.maxLength = maxLength;
+    }
+
+}

Modified: 
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/ObjAttribute.java
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/ObjAttribute.java?view=diff&rev=451684&r1=451683&r2=451684
==============================================================================
--- 
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/ObjAttribute.java
 (original)
+++ 
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/ObjAttribute.java
 Sat Sep 30 15:13:57 2006
@@ -239,8 +239,14 @@
      * @since 1.2
      */
     public ObjAttribute getClientAttribute() {
-        ObjAttribute attribute = new ObjAttribute(getName());
+        ClientObjAttribute attribute = new ClientObjAttribute(getName());
         attribute.setType(getType());
+        
+        DbAttribute dbAttribute = getDbAttribute();
+        if (dbAttribute != null) {
+            attribute.setMandatory(dbAttribute.isMandatory());
+            attribute.setMaxLength(dbAttribute.getMaxLength());
+        }
 
         // TODO: will likely need "userForLocking" property as well.
 


Reply via email to