* <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.4 2003/11/26 19:21:06 rk Exp $
+ * @version $Id: DatabaseContentToMedia.java,v 1.19.2.5 2004/01/18 17:31:01 zapata Exp $
*
*/
logger = new LoggerWrapper("Database.ContentToMedia");
hasTimestamp = false;
- theTable = "content_x_media";
+ mainTable = "content_x_media";
theEntityClass = mir.entity.GenericEntity.class;
}
public boolean hasMedia(EntityContent content) throws StorageObjectFailure,
StorageObjectExc {
if (content != null) {
- try {
+ try {
return (getSize("content_id=" + content.getId()) == 0) ? false:true;
}
catch (Exception e) {
private EntityList getMultiMediaForContent(StorageObject store, EntityContent content)
throws StorageObjectFailure {
-
+
EntityList returnList = null;
if (content != null) {
String id = content.getId();
- try {
+ try {
Vector extraTable = new Vector();
- extraTable.add(theTable+" cxm");
+ extraTable.add(mainTable+" cxm");
// media should stay in uploaded order. this is especially important
// for photo stories which require a specific chronologic order.
- // this is why we have the the second parameter "id"
- store.selectByWhereClause("m", extraTable,
+ // this is why we have the the second parameter "id"
+ store.selectByWhereClause("m", extraTable,
"m.id=cxm.media_id and cxm.content_id="+id, "id", -1, -1);
-
+
} catch (Exception e) {
logger.error("DatabaseContentToMedia.getMultiMediaForContent: " + e.toString());
throw new StorageObjectFailure("DatabaseContentToMedia.etMultiMediaForContent: " +
}
return returnList;
}
-
+
/**
* get all the audio belonging to a content entity
*/
return;
}
//first delete all row with content_id=contentId
- String sql = "delete from " + theTable + " where content_id=" + contentId;
+ String sql = "delete from " + mainTable + " where content_id=" + contentId;
Connection con = null;
Statement stmt = null;
//now insert
//first delete all row with content_id=contentId
for (int i = 0; i < mediaId.length; i++) {
- sql = "insert into " + theTable + " (content_id,media_id) values ("
+ sql = "insert into " + mainTable + " (content_id,media_id) values ("
+ contentId + "," + mediaId[i] + ")";
try {
con = getPooledCon();
Statement stmt = null;
//now insert
- String sql = "insert into " + theTable + " (content_id,media_id) values ("
+ String sql = "insert into " + mainTable + " (content_id,media_id) values ("
+ contentId + "," + mediaId + ")";
try {
con = getPooledCon();
return;
}
//first delete all row with content_id=contentId
- String sql = "delete from " + theTable + " where content_id=" + contentId;
+ String sql = "delete from " + mainTable + " where content_id=" + contentId;
Connection con = null;
Statement stmt = null;
//now insert
//first delete all row with content_id=contentId
- sql = "insert into " + theTable + " (content_id,media_id) values ("
+ sql = "insert into " + mainTable + " (content_id,media_id) values ("
+ contentId + "," + mediaId + ")";
try {
con = getPooledCon();
return;
}
//delete all row with content_id=contentId
- String sql = "delete from " + theTable + " where content_id=" + contentId;
+ String sql = "delete from " + mainTable + " where content_id=" + contentId;
Connection con = null;
Statement stmt = null;
}
public void deleteByMediaId(String mediaId) throws StorageObjectFailure {
-
+
if (mediaId == null) {
//theLog.printDebugInfo("-- delete topics failed -- no topic id");
return;
}
//delete all row with content_id=contentId
- String sql = "delete from " + theTable + " where media_id=" + mediaId;
+ String sql = "delete from " + mainTable + " where media_id=" + mediaId;
Connection con = null;
Statement stmt = null;
return;
}
//delete all row with content_id=contentId and media_id=mediaId
- String sql = "delete from " + theTable + " where media_id=" + mediaId +
+ String sql = "delete from " + mainTable + " where media_id=" + mediaId +
" and content_id= " + contentId;
Connection con = null;
public EntityList getContent(EntityUploadedMedia media) throws
StorageObjectFailure {
-
+
EntityList returnList = null;
if (media != null) {
String id = media.getId();
Vector extraTables = new Vector();
- extraTables.add(theTable + " cxm");
-
+ extraTables.add(mainTable + " cxm");
+
String mediaSelect = "cxm.content_id=c.id and cxm.media_id="+id;
try {
returnList = DatabaseContent.getInstance().selectByWhereClause("c",
extraTables, mediaSelect, "c.id" );
-
+
}
catch (Exception e) {
logger.error("-- get content failed");
public EntityList getContent() throws StorageObjectFailure {
EntityList returnList = null;
-
+
Vector extraTables = new Vector();
- extraTables.add(theTable + " cxm");
-
+ extraTables.add(mainTable + " cxm");
+
String mediaSelect = "cxm.content_id=c.id";
try {
returnList = DatabaseContent.getInstance().selectByWhereClause("c",
extraTables, mediaSelect, "c.webdb_lastchange desc" );
-
+
}
catch (Exception e) {
logger.error("-- get content failed");