change the way, size, height, OID, etc is entered in the DB: do it via the Entity...
authormh <mh>
Fri, 6 Dec 2002 08:08:14 +0000 (08:08 +0000)
committermh <mh>
Fri, 6 Dec 2002 08:08:14 +0000 (08:08 +0000)
source/mircoders/entity/EntityImages.java

index 597c281..6e66358 100755 (executable)
@@ -53,8 +53,8 @@ import mir.storage.*;
 /**
  * Diese Klasse enthält die Daten eines MetaObjekts
  *
- * @author RK, mh
- * @version $Id: EntityImages.java,v 1.11 2002/12/01 15:05:51 zapata Exp $
+ * @author RK, mh, mir-coders
+ * @version $Id: EntityImages.java,v 1.12 2002/12/06 08:08:14 mh Exp $
  */
 
 
@@ -153,21 +153,18 @@ public class EntityImages extends EntityUploadedMedia
         webdbImage.setIcon(lobIcon.getOutputStream());
         lobImage.close();
         lobIcon.close();
-        String sql = "update images set img_height='"
-                   +webdbImage.getImageHeight() +
-                     "',img_width='"   + webdbImage.getImageWidth() +
-                     "',icon_height='" + webdbImage.getIconHeight() +
-                     "',icon_width='"  + webdbImage.getIconWidth()
-                   +  "', image_data="+oidImage+", icon_data="+oidIcon
-                   +" where id="+getId();
-        theLog.printDebugInfo("settimage :: updating sizes: "+ sql);
-        pstmt = con.prepareStatement(sql);
-        //pstmt.setBytes(1, imageData);
-        //pstmt.setBytes(2, iconData);
-        pstmt.executeUpdate();
-        sql="update content set is_produced='0' where to_media="+getId();
-        pstmt = con.prepareStatement(sql);
-        pstmt.executeUpdate();
+
+        setValueForProperty("img_height",
+                          new Integer(webdbImage.getImageHeight()).toString());
+        setValueForProperty("img_width",
+                          new Integer(webdbImage.getImageWidth()).toString());
+        setValueForProperty("icon_height",
+                          new Integer(webdbImage.getIconHeight()).toString());
+        setValueForProperty("icon_width",
+                          new Integer(webdbImage.getIconWidth()).toString());
+        setValueForProperty("image_data", new Integer(oidImage).toString());
+        setValueForProperty("icon_data", new Integer(oidIcon).toString());
+        update();
       }
       catch (Exception e) {
         throwStorageObjectException(e, "settimage :: setImage gescheitert: ");
@@ -188,24 +185,6 @@ public class EntityImages extends EntityUploadedMedia
     }
   }
 
-  public void update() throws StorageObjectException {
-    super.update();
-    try {
-      theStorageObject.executeUpdate("update content set is_produced='0' where to_media="+getId());
-    } catch (SQLException e) {
-      throwStorageObjectException(e, "EntityImages :: update :: failed!! ");
-    }
-  }
-
-  public void setValues(HashMap theStringValues)
-  {
-    if (theStringValues != null) {
-      if (!theStringValues.containsKey("is_published"))
-        theStringValues.put("is_published","0");
-    }
-    super.setValues(theStringValues);
-  }
-
   /**
    * Takes an OutputStream as an argument and reads in the data
    * from the DB and writes it to the OutputStream.
@@ -292,4 +271,4 @@ public class EntityImages extends EntityUploadedMedia
     }
 
   }
-}
\ No newline at end of file
+}