Adding a new ImageMagickImageProcessor class to replace
[mir.git] / source / mircoders / entity / EntityUploadedMedia.java
index 436cdb0..74cb05c 100755 (executable)
@@ -35,14 +35,13 @@ import java.util.Map;
 import mir.entity.AbstractEntity;
 import mir.entity.Entity;
 import mir.log.LoggerWrapper;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
+import mir.storage.DatabaseFailure;
 import mircoders.storage.DatabaseUploadedMedia;
 
 /**
  *
  * @author mh, mir-coders group
- * @version $Id: EntityUploadedMedia.java,v 1.26.2.6 2004/01/18 17:30:58 zapata Exp $
+ * @version $Id: EntityUploadedMedia.java,v 1.26.2.12 2005/03/26 11:26:26 zapata Exp $
  */
 
 public class EntityUploadedMedia extends AbstractEntity {
@@ -52,30 +51,39 @@ public class EntityUploadedMedia extends AbstractEntity {
     logger = new LoggerWrapper("Entity.UploadedMedia");
   }
 
-  public EntityUploadedMedia(StorageObject theStorage) {
-    this();
-
-    setStorage(theStorage);
-  }
-
-  public void update() throws StorageObjectFailure {
+  public void update() throws DatabaseFailure {
     super.update();
 
     try {
-      storageObject.executeUpdate( "update content set is_produced='0' where exists(select * from content_x_media where content_id=content.id and media_id=" + getId()+")");
-      storageObject.executeUpdate( "update content set is_produced='0' where exists(select * from comment_x_media, comment where comment_x_media.comment_id=comment.id and comment.to_media=content.id and comment_x_media.media_id=" + getId()+")");
+      database.executeUpdate(
+          "update content " +
+          "set is_produced='0' " +
+          "from content_x_media cxm " +
+          "where" +
+          "   cxm.content_id=content.id and cxm.media_id=" + getId()
+      );
+
+      database.executeUpdate(
+          "update content " +
+          "set is_produced='0' " +
+          "from comment_x_media cxm, comment c "+
+          "where " +
+          "   cxm.comment_id = c.id and " +
+          "   c.to_media=content.id and " +
+          "   cxm.media_id=" + getId()
+      );
     }
     catch (SQLException e) {
-      throw new StorageObjectFailure(e);
+      throw new DatabaseFailure(e);
     }
   }
 
-  public void setValues(Map theStringValues) {
+  public void setFieldValues(Map theStringValues) {
     if (theStringValues != null) {
       if (!theStringValues.containsKey("is_published"))
         theStringValues.put("is_published", "0");
     }
-    super.setValues(theStringValues);
+    super.setFieldValues(theStringValues);
   }
 
 
@@ -84,13 +92,13 @@ public class EntityUploadedMedia extends AbstractEntity {
    *
    * @return mir.entity.Entity
    */
-  public Entity getMediaType() throws StorageObjectFailure {
+  public Entity getMediaType() throws DatabaseFailure {
     Entity ent = null;
     try {
       ent = DatabaseUploadedMedia.getInstance().getMediaType(this);
     }
-    catch (StorageObjectFailure e) {
-      throw new StorageObjectFailure(e);
+    catch (DatabaseFailure e) {
+      throw new DatabaseFailure(e);
     }
     return ent;
   }