Anonymous avatar Anonymous committed 15c086c

Comments (0)

Files changed (6)

src/java/com/opensymphony/module/propertyset/hibernate/HibernatePropertySet.java

 
         if (item == null) {
             update = false;
-            item = new PropertySetItem(entityName, entityId.longValue(), key);
+            item = configProvider.getPropertySetDAO().create(entityName, entityId.longValue(), key);
         } else if (item.getType() != type) {
             throw new PropertyException("Existing key '" + key + "' does not have matching type of " + type);
         }

src/java/com/opensymphony/module/propertyset/hibernate/HibernatePropertySetDAO.java

 
     Collection getKeys(String entityName, Long entityId, String prefix, int type);
 
+    PropertySetItem create(String entityName, long entityId, String key);
+
     PropertySetItem findByKey(String entityName, Long entityId, String key);
 
     void remove(String entityName, Long entityId, String key);

src/java/com/opensymphony/module/propertyset/hibernate/HibernatePropertySetDAOImpl.java

         return list;
     }
 
+    public PropertySetItem create(String entityName, long entityId, String key) {
+        return new PropertySetItemImpl(entityName, entityId, key);
+    }
+
     public PropertySetItem findByKey(String entityName, Long entityId, String key) {
         Session session = null;
         PropertySetItem item = null;

src/java/com/opensymphony/module/propertyset/hibernate/HibernatePropertySetDAOUtils.java

  * User: Mike
  * Date: Jul 26, 2003
  * Time: 5:46:58 PM
- * To change this template use Options | File Templates.
  */
 public class HibernatePropertySetDAOUtils {
     //~ Methods ////////////////////////////////////////////////////////////////
 
     public static PropertySetItem getItem(Session session, String entityName, Long entityId, String key) throws HibernateException {
-        return (PropertySetItem) session.load(PropertySetItem.class, new PropertySetItem(entityName, entityId.longValue(), key));
+        return (PropertySetItem) session.load(PropertySetItem.class, new PropertySetItemImpl(entityName, entityId.longValue(), key));
     }
 
     /**

src/java/com/opensymphony/module/propertyset/hibernate/PropertySetItem.java

  */
 package com.opensymphony.module.propertyset.hibernate;
 
-import java.io.Serializable;
-
 import java.util.Date;
 
 
 /**
- *
- *
- * @author $Author$
+ * Interface to be implemented by the concrete class that hibernate persists.
+ * @author $author$
  * @version $Revision$
  */
-public class PropertySetItem implements Serializable {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    Date dateVal;
-    String entityName;
-    String key;
-    String stringVal;
-    boolean booleanVal;
-    double doubleVal;
-    int intVal;
-    int type;
-    long entityId;
-    long longVal;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    //needed for hibernate
-    public PropertySetItem() {
-    }
-
-    public PropertySetItem(String entityName, long entityId, String key) {
-        this.entityName = entityName;
-        this.entityId = entityId;
-        this.key = key;
-    }
-
+public interface PropertySetItem {
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public void setBooleanVal(boolean booleanVal) {
-        this.booleanVal = booleanVal;
-    }
-
-    public boolean getBooleanVal() {
-        return booleanVal;
-    }
-
-    public void setDateVal(Date dateVal) {
-        this.dateVal = dateVal;
-    }
-
-    public Date getDateVal() {
-        return dateVal;
-    }
-
-    public void setDoubleVal(double doubleVal) {
-        this.doubleVal = doubleVal;
-    }
+    void setBooleanVal(boolean booleanVal);
 
-    public double getDoubleVal() {
-        return doubleVal;
-    }
+    boolean getBooleanVal();
 
-    public void setEntityId(long entityId) {
-        this.entityId = entityId;
-    }
+    void setDateVal(Date dateVal);
 
-    public long getEntityId() {
-        return entityId;
-    }
+    Date getDateVal();
 
-    public void setEntityName(String entityName) {
-        this.entityName = entityName;
-    }
+    void setDoubleVal(double doubleVal);
 
-    public String getEntityName() {
-        return entityName;
-    }
+    double getDoubleVal();
 
-    public void setIntVal(int intVal) {
-        this.intVal = intVal;
-    }
+    void setEntityId(long entityId);
 
-    public int getIntVal() {
-        return intVal;
-    }
+    long getEntityId();
 
-    public void setKey(String key) {
-        this.key = key;
-    }
+    void setEntityName(String entityName);
 
-    public String getKey() {
-        return key;
-    }
+    String getEntityName();
 
-    public void setLongVal(long longVal) {
-        this.longVal = longVal;
-    }
+    void setIntVal(int intVal);
 
-    public long getLongVal() {
-        return longVal;
-    }
+    int getIntVal();
 
-    public void setStringVal(String stringVal) {
-        this.stringVal = stringVal;
-    }
+    void setKey(String key);
 
-    public String getStringVal() {
-        return stringVal;
-    }
+    String getKey();
 
-    public void setType(int type) {
-        this.type = type;
-    }
+    void setLongVal(long longVal);
 
-    public int getType() {
-        return type;
-    }
+    long getLongVal();
 
-    public boolean equals(Object obj) {
-        if (!(obj instanceof PropertySetItem)) {
-            return false;
-        }
+    void setStringVal(String stringVal);
 
-        PropertySetItem item = (PropertySetItem) obj;
+    String getStringVal();
 
-        return ((item.getEntityId() == entityId) && item.getEntityName().equals(entityName) && item.getKey().equals(key));
-    }
+    void setType(int type);
 
-    public int hashCode() {
-        return (int) (entityId + entityName.hashCode() + key.hashCode());
-    }
+    int getType();
 }

src/java/com/opensymphony/module/propertyset/hibernate/PropertySetItemImpl.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.module.propertyset.hibernate;
+
+import java.io.Serializable;
+
+import java.util.Date;
+
+
+/**
+ *
+ *
+ * @author $Author$
+ * @version $Revision$
+ */
+public class PropertySetItemImpl implements Serializable, PropertySetItem {
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    Date dateVal;
+    String entityName;
+    String key;
+    String stringVal;
+    boolean booleanVal;
+    double doubleVal;
+    int intVal;
+    int type;
+    long entityId;
+    long longVal;
+
+    //~ Constructors ///////////////////////////////////////////////////////////
+
+    //needed for hibernate
+    public PropertySetItemImpl() {
+    }
+
+    public PropertySetItemImpl(String entityName, long entityId, String key) {
+        this.entityName = entityName;
+        this.entityId = entityId;
+        this.key = key;
+    }
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public void setBooleanVal(boolean booleanVal) {
+        this.booleanVal = booleanVal;
+    }
+
+    public boolean getBooleanVal() {
+        return booleanVal;
+    }
+
+    public void setDateVal(Date dateVal) {
+        this.dateVal = dateVal;
+    }
+
+    public Date getDateVal() {
+        return dateVal;
+    }
+
+    public void setDoubleVal(double doubleVal) {
+        this.doubleVal = doubleVal;
+    }
+
+    public double getDoubleVal() {
+        return doubleVal;
+    }
+
+    public void setEntityId(long entityId) {
+        this.entityId = entityId;
+    }
+
+    public long getEntityId() {
+        return entityId;
+    }
+
+    public void setEntityName(String entityName) {
+        this.entityName = entityName;
+    }
+
+    public String getEntityName() {
+        return entityName;
+    }
+
+    public void setIntVal(int intVal) {
+        this.intVal = intVal;
+    }
+
+    public int getIntVal() {
+        return intVal;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setLongVal(long longVal) {
+        this.longVal = longVal;
+    }
+
+    public long getLongVal() {
+        return longVal;
+    }
+
+    public void setStringVal(String stringVal) {
+        this.stringVal = stringVal;
+    }
+
+    public String getStringVal() {
+        return stringVal;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    public boolean equals(Object obj) {
+        if (!(obj instanceof PropertySetItem)) {
+            return false;
+        }
+
+        PropertySetItem item = (PropertySetItem) obj;
+
+        return ((item.getEntityId() == entityId) && item.getEntityName().equals(entityName) && item.getKey().equals(key));
+    }
+
+    public int hashCode() {
+        return (int) (entityId + entityName.hashCode() + key.hashCode());
+    }
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.