[Bedework-commit] calendarapi r643 - in trunk: calCore/resources/hbms calFacade/src/org/bedework/calfacade calsvc/src/org/bedework/calsvc

svnadmin at bedework.org svnadmin at bedework.org
Sat May 31 00:38:35 EDT 2008


Author: douglm
Date: 2008-05-31 00:38:29 -0400 (Sat, 31 May 2008)
New Revision: 643

Modified:
   trunk/calCore/resources/hbms/ResourceContent.hbm.xml
   trunk/calFacade/src/org/bedework/calfacade/BwResourceContent.java
   trunk/calsvc/src/org/bedework/calsvc/ResourcesImpl.java
Log:
Some changes to the resources schema. Fix a number of problems and make deletes work

Modified: trunk/calCore/resources/hbms/ResourceContent.hbm.xml
===================================================================
--- trunk/calCore/resources/hbms/ResourceContent.hbm.xml	2008-05-29 14:21:33 UTC (rev 642)
+++ trunk/calCore/resources/hbms/ResourceContent.hbm.xml	2008-05-31 04:38:29 UTC (rev 643)
@@ -17,11 +17,17 @@
 
     <version name="seq" column="bwseq" type="integer" />
 
-    <!-- The path is the key to this -->
-    <property name="path" column="bwpath" type="string" length="3000"
-              not-null="true"
-              index="bwidx_rsrccpath" lazy="false" />
+    <!-- Key is calendar + name -->
+    <many-to-one name="calendar"
+                 class="org.bedework.calfacade.BwCalendar"
+                 index="bwidx_rsrc_calendar"
+                 foreign-key="bw_rsrc_cal_fk" >
+      <column name="collectionid" />
+    </many-to-one>
 
+    <property name="name" column="bwname" type="string"
+              length="100" not-null="true" />
+
     <property name="value" column="bw_value" type="binary"/>
   </class>
 
@@ -29,4 +35,3 @@
         queries
        ================================================================= -->
 </hibernate-mapping>
-

Modified: trunk/calFacade/src/org/bedework/calfacade/BwResourceContent.java
===================================================================
--- trunk/calFacade/src/org/bedework/calfacade/BwResourceContent.java	2008-05-29 14:21:33 UTC (rev 642)
+++ trunk/calFacade/src/org/bedework/calfacade/BwResourceContent.java	2008-05-31 04:38:29 UTC (rev 643)
@@ -35,8 +35,12 @@
  *  @author Mike Douglass   douglm - rpi.edu
  */
 public class BwResourceContent extends BwDbentity<BwResourceContent> {
-  private String path;
+  /* The collection this belongs to
+   */
+  private BwCalendar collection;
 
+  private String name;
+
   private byte[] value;
 
   /** Constructor
@@ -49,31 +53,49 @@
    *                      Bean methods
    * ==================================================================== */
 
-  /** Set the path
+  // CALWRAPPER
+  /** Set the object's collection
    *
-   * @param val    String path
+   * @param val    BwCalendar object's collection
    */
-  public void setPath(String val) {
-    path = val;
+  public void setCalendar(BwCalendar val) {
+    collection = val;
   }
 
-  /** Get the path
+  // CALWRAPPER
+  /** Get the object's collection
    *
-   * @return String   path
+   * @return BwCalendar   the object's collection
    */
-  public String getPath() {
-    return path;
+  public BwCalendar getCalendar() {
+    return collection;
   }
 
-  /** Set the length
+  /** Set the name
    *
+   * @param val    String name
+   */
+  public void setName(String val) {
+    name = val;
+  }
+
+  /** Get the name
+   *
+   * @return String   name
+   */
+  public String getName() {
+    return name;
+  }
+
+  /** Set the value
+   *
    *  @param  val   byte[]
    */
   public void setValue(byte[] val) {
     value = val;
   }
 
-  /** Get the length
+  /** Get the value
    *
    *  @return byte[]     length
    */
@@ -90,7 +112,8 @@
    * @param val
    */
   public void copyTo(BwResourceContent val) {
-    val.setPath(getPath());
+    val.setCalendar(getCalendar());
+    val.setName(getName());
     val.setValue(getValue());
   }
 
@@ -107,7 +130,7 @@
       return 0;
     }
 
-    int res = CalFacadeUtil.cmpObjval(getPath(), that.getPath());
+    int res = CalFacadeUtil.cmpObjval(getCalendar(), that.getCalendar());
     if (res != 0) {
       return res;
     }
@@ -156,7 +179,9 @@
 
     toStringSegment(sb);
     sb.append(", path=");
-    sb.append(getPath());
+    sb.append(getCalendar().getPath());
+    sb.append(", name=");
+    sb.append(getName());
 
     sb.append(", value.length=");
     sb.append(getValue().length);

Modified: trunk/calsvc/src/org/bedework/calsvc/ResourcesImpl.java
===================================================================
--- trunk/calsvc/src/org/bedework/calsvc/ResourcesImpl.java	2008-05-29 14:21:33 UTC (rev 642)
+++ trunk/calsvc/src/org/bedework/calsvc/ResourcesImpl.java	2008-05-31 04:38:29 UTC (rev 643)
@@ -82,9 +82,10 @@
     sess.save(val);
 
     BwResourceContent rc = val.getContent();
-    rc.setPath(val.getCalendar().getPath() + "/" + val.getName());
+    rc.setCalendar(val.getCalendar());
+    rc.setName(val.getName());
 
-    sess.save(val.getContent());
+    sess.save(rc);
   }
 
   /* (non-Javadoc)
@@ -103,10 +104,11 @@
 
     sb.append("from ");
     sb.append(BwResourceContent.class.getName());
-    sb.append(" as rc where rc.path=:path");
+    sb.append(" as rc where rc.calendar.path=:path and rc.name=:name");
 
     sess.createQuery(sb.toString());
-    sess.setString("path", val.getCalendar().getPath() + "/" + val.getName());
+    sess.setString("path", val.getCalendar().getPath());
+    sess.setString("name", val.getName());
     sess.cacheableQuery();
 
     BwResourceContent rc = (BwResourceContent)sess.getUnique();
@@ -153,7 +155,8 @@
 
     if (updateContent && (val.getContent() != null)) {
       BwResourceContent rc = val.getContent();
-      rc.setPath(val.getCalendar().getPath() + "/" + val.getName());
+      rc.setCalendar(val.getCalendar());
+      rc.setName(val.getName());
 
       sess.update(rc);
     }
@@ -173,7 +176,14 @@
       throw new CalFacadeException(CalFacadeException.unknownResource, path);
     }
 
+    getContent(r);
+    BwResourceContent rc = r.getContent();
+
     sess.delete(r);
+
+    if (rc != null) {
+      sess.delete(rc);
+    }
   }
 
   /** Allows svc to retrieve the calSuite object used to configure a public



More information about the Bedework-commit mailing list