From b003cf31d384287909701ded92bc6c9023f6ed58 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 5 Dec 2002 08:40:18 +0000 Subject: [PATCH] change the way, size, height, OID, etc is entered in the DB: do it via the Entity interface and not via manual SQL. with manual SQL, the entity becomes out of sync w/ data in the DB and this is bad. It's not as fast as the manual SQL, but more consistent and nicer. also move the update override method that sets content that has this media item attached to EntityUploadedMedia so all media types can take advantage of it --- source/mircoders/entity/EntityImages.java | 47 +++++++++---------------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/source/mircoders/entity/EntityImages.java b/source/mircoders/entity/EntityImages.java index 6f718205..942cd124 100755 --- a/source/mircoders/entity/EntityImages.java +++ b/source/mircoders/entity/EntityImages.java @@ -54,7 +54,7 @@ import mir.storage.*; * Diese Klasse enthält die Daten eines MetaObjekts * * @author RK, mh - * @version $Id: EntityImages.java,v 1.6.4.4 2002/11/27 21:16:54 mh Exp $ + * @version $Id: EntityImages.java,v 1.6.4.5 2002/12/05 08:40:18 mh Exp $ */ @@ -152,21 +152,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: ");} finally { @@ -181,24 +178,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. -- 2.11.0