* Treiber, Host, User und Passwort, ueber den der Zugriff auf die
* Datenbank erfolgt.
*
- * @version $Id: Database.java,v 1.44.2.14 2003/11/25 01:05:11 rk Exp $
+ * @version $Id: Database.java,v 1.44.2.15 2003/11/26 19:21:05 rk Exp $
* @author rk
*
*/
public EntityList selectByWhereClauseWithExtraTables(String mainTablePrefix,
List extraTables, String aWhereClause )
throws StorageObjectFailure {
- return selectByWhereClause( mainTablePrefix, extraTables, aWhereClause, "", 0, -1);
+ return selectByWhereClause( mainTablePrefix, extraTables, aWhereClause, "", 0, defaultLimit);
}
/**
return selectByWhereClause(where, order, 0);
}
+ public EntityList selectByWhereClause(String mainTablePrefix, List extraTables, String where, String order) throws StorageObjectFailure {
+ return selectByWhereClause(mainTablePrefix, extraTables, where, order, 0, defaultLimit);
+ }
+
/**
* select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck.
* Als maximale Anzahl wird das Limit auf der Konfiguration genommen.
return selectByWhereClause("", null, aWhereClause, anOrderByClause, offset, limit);
}
+
/**
* select-Operator returns EntityList with matching rows in Database.
* @param aWhereClause where-Clause
/**
*
* @author mh, mir-coders group
- * @version $Id: EntityUploadedMedia.java,v 1.26.2.2 2003/11/24 23:37:18 rk Exp $
+ * @version $Id: EntityUploadedMedia.java,v 1.26.2.3 2003/11/26 19:21:04 rk Exp $
*/
public void update() throws StorageObjectFailure {
super.update();
- try {
- // TODO rewrite as relational sql
- theStorageObject.executeUpdate("update content set is_produced='0' where exists(select * from content_x_media where to_content=content.id and to_media=" + getId()+")");
+ try {
+ theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from content_x_media where to_content=content.id and to_media=" + getId()+")");
}
catch (SQLException e) {
- throwStorageObjectFailure(e, "EntityAudio :: update :: failed!! ");
+ throwStorageObjectFailure(e, "EntityUploadedMedia :: update :: failed!! ");
}
}
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Iterator;
+import java.util.Vector;
import mir.config.MirPropertiesConfiguration;
import mir.entity.EntityBrowser;
* source
*/
- Iterator images = new EntityBrowser(
- // TODO rewrite as relational select
- DatabaseImages.getInstance(),
- "exists (select * from content_x_media where content_id=" + entityContent.getId() + " and media_id=id)",
- "id desc", 30, -1, 0);
+ Vector extraTables = new Vector();
+ extraTables.add("content_x_media cxm");
+ Iterator images = new EntityBrowser(
+ DatabaseImages.getInstance(), "i", extraTables,
+ "cxm.content_id="+entityContent.getId()+"and cxm.media_id=i.id",
+ "i.id desc", 30, -1, 0);
String isHTML = entityContent.getValue("is_html");
String theTitle = entityContent.getValue("title");
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Vector;
import mir.entity.Entity;
import mir.entity.EntityBrowser;
ArrayList brokenUpContent = new ArrayList();
+
+ Vector extraTables = new Vector();
+ extraTables.add("content_x_media cxm");
Iterator images = new EntityBrowser(
- // TODO rewrite as relational sql, see also PDF Generator
- DatabaseImages.getInstance(),
- "exists (select * from content_x_media where content_id=" + entity.getId() + " and media_id=id)",
- "id desc", 30, -1, 0);
+ DatabaseImages.getInstance(), "i", extraTables,
+ "cxm.content_id="+entity.getId()+"and cxm.media_id=i.id",
+ "i.id desc", 30, -1, 0);
String theContent = ((EntityContent) entity).getValue("content_data");
//remove pesky characters
* <b>implements abstract DB connection to the comment_x_media SQL table
*
* @author RK, mir-coders group
- * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.3 2003/11/25 02:04:43 rk Exp $
+ * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.4 2003/11/26 19:21:06 rk Exp $
*
*/
}
/**
- * Returns a EntityList with all comment-objects having a relation to a media
+ * Returns a EntityList with all comment-objects having
+ * a relation to a media
*/
public EntityList getComment() throws StorageObjectFailure {
EntityList returnList = null;
-
-// TODO rewrite as relational sql
- String select = "select distinct comment_id from " + theTable;
- // execute select statement
- Connection con = null;
- Statement stmt = null;
+
+ Vector extraTables = new Vector();
+ extraTables.add(theTable + " cxm");
+
+ String mediaSelect = "cxm.comment_id=c.id";
try {
- con = getPooledCon();
- // should be a preparedStatement because is faster
- stmt = con.createStatement();
- ResultSet rs = executeSql(stmt, select);
- if (rs != null) {
- String mediaSelect = "id IN (";
- boolean first = true;
- while (rs.next()) {
- if (first == false)
- mediaSelect += ",";
- mediaSelect += rs.getString(1);
- first = false;
- }
- mediaSelect += ")";
- if (first == false)
- returnList = DatabaseComment.getInstance().selectByWhereClause(
- mediaSelect, "webdb_lastchange desc");
- }
+ returnList = DatabaseComment.getInstance().selectByWhereClause("c",
+ extraTables, mediaSelect, "c.webdb_lastchange desc" );
+
}
catch (Exception e) {
logger.error("-- get comment failed");
throw new StorageObjectFailure("-- get comment failed -- ", e);
}
- finally {
- freeConnection(con, stmt);
- }
-
return returnList;
+
}
}
* <b>implements abstract DB connection to the content_x_media SQL table
*
* @author RK, mir-coders group
- * @version $Id: DatabaseContentToMedia.java,v 1.19.2.3 2003/11/25 02:04:43 rk Exp $
+ * @version $Id: DatabaseContentToMedia.java,v 1.19.2.4 2003/11/26 19:21:06 rk Exp $
*
*/
public EntityList getContent(EntityUploadedMedia media) throws
StorageObjectFailure {
+
EntityList returnList = null;
if (media != null) {
-// TODO rewrite as relational sql
- String id = media.getId();
- String select = "select content_id from " + theTable + " where media_id=" +
- id;
- // execute select statement
- Connection con = null;
- Statement stmt = null;
+ String id = media.getId();
+ Vector extraTables = new Vector();
+ extraTables.add(theTable + " cxm");
+
+ String mediaSelect = "cxm.content_id=c.id and cxm.media_id="+id;
try {
- con = getPooledCon();
- // should be a preparedStatement because is faster
- stmt = con.createStatement();
- ResultSet rs = executeSql(stmt, select);
- if (rs != null) {
- String mediaSelect = "id IN (";
- boolean first = true;
- while (rs.next()) {
- if (first == false)
- mediaSelect += ",";
- mediaSelect += rs.getString(1);
- first = false;
- }
- mediaSelect += ")";
- if (first == false)
- returnList = DatabaseContent.getInstance().selectByWhereClause(
- mediaSelect, -1);
- }
+ returnList = DatabaseContent.getInstance().selectByWhereClause("c",
+ extraTables, mediaSelect, "c.id" );
+
}
catch (Exception e) {
logger.error("-- get content failed");
throw new StorageObjectFailure("-- get content failed -- ", e);
}
- finally {
- freeConnection(con, stmt);
- }
}
return returnList;
}
*/
public EntityList getContent() throws StorageObjectFailure {
- EntityList returnList = null;
- String select = "select distinct content_id from " + theTable;
- // execute select statement
- Connection con = null;
- Statement stmt = null;
+ EntityList returnList = null;
+
+ Vector extraTables = new Vector();
+ extraTables.add(theTable + " cxm");
+
+ String mediaSelect = "cxm.content_id=c.id";
try {
-// TODO rewrite as relational sql
- con = getPooledCon();
- // should be a preparedStatement because is faster
- stmt = con.createStatement();
- ResultSet rs = executeSql(stmt, select);
- if (rs != null) {
- String mediaSelect = "id IN (";
- boolean first = true;
- while (rs.next()) {
- if (first == false)
- mediaSelect += ",";
- mediaSelect += rs.getString(1);
- first = false;
- }
- mediaSelect += ")";
- if (first == false)
- returnList = DatabaseContent.getInstance().selectByWhereClause(
- mediaSelect, "webdb_lastchange desc");
- }
+ returnList = DatabaseContent.getInstance().selectByWhereClause("c",
+ extraTables, mediaSelect, "c.webdb_lastchange desc" );
+
}
catch (Exception e) {
logger.error("-- get content failed");
throw new StorageObjectFailure("-- get content failed -- ", e);
}
- finally {
- freeConnection(con, stmt);
- }
-
return returnList;
}