- this.hasTimestamp = false;
- this.theTable="content_x_media";
- try { this.theEntityClass = Class.forName("mir.entity.GenericEntity"); }
- catch (Exception e) { throw new StorageObjectException(e.toString()); }
- }
-
- /**
- * get all the media-files belonging to a content entity
- *
- */
- public EntityList getMedia(EntityContent content)
- throws StorageObjectException {
- EntityList returnList=null;
- if (content != null) {
- // get all to_topic from media_x_topic
- String id = content.getId();
- //this is not supported by mysql
- String subselect = "id in (select media_id from " + theTable + " where content_id=" + id+")";
-
- try {
- // 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"
- returnList = DatabaseMedia.getInstance().selectByWhereClause(subselect,"id",-1);
- } catch (Exception e) {
- theLog.printDebugInfo("-- get media failed " + e.toString());
- throw new StorageObjectException("-- get media failed " + e.toString());
- }
- }
- return returnList;
- }
-
- public boolean hasMedia(EntityContent content)
- throws StorageObjectException {
- String wc = "content_id="+content.getId();
- if( content != null) {
- try {
- if(selectByWhereClause(wc,-1).size() == 0)
- return false;
- else
- return true;
- } catch (Exception e) {
- theLog.printError("-- hasMedia failed " + e.toString());
- throw new StorageObjectException("-- hasMedia failed " + e.toString());
- }
- } else {
- theLog.printError("-- hasMedia failed: content is NULL");
- throw new StorageObjectException("-- hasMedia failed: content is NULL");
- }
- }
-
-
-
-
- /**
- * get all the audio belonging to a content entity
- *
- */
- public EntityList getAudio(EntityContent content)
- throws StorageObjectException {
- EntityList returnList=null;
- if (content != null) {
- // get all to_topic from media_x_topic
- String id = content.getId();
- //this is not supported by mysql
- String subselect = "id in (select media_id from " + theTable + " where content_id=" + id+")";
-
- try {
- // 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"
- returnList = DatabaseAudio.getInstance().selectByWhereClause(subselect,"id",-1);
- } catch (Exception e) {
- theLog.printDebugInfo("-- get audio failed " + e.toString());
- throw new StorageObjectException("-- get audio failed " + e.toString());
- }
- }
- return returnList;
- }
-
- /**
- * get all the video belonging to a content entity
- *
- */
- public EntityList getVideo(EntityContent content)
- throws StorageObjectException {
- EntityList returnList=null;
- if (content != null) {
- // get all to_topic from media_x_topic
- String id = content.getId();
- //this is not supported by mysql
- String subselect = "id in (select media_id from " + theTable + " where content_id=" + id+")";
-
- try {
- // 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"
- returnList = DatabaseVideo.getInstance().selectByWhereClause(subselect,"id",-1);
- } catch (Exception e) {
- theLog.printDebugInfo("-- get video failed " + e.toString());
- throw new StorageObjectException("-- get video failed " + e.toString());
- }
- }
- return returnList;
- }
-
- /**
- * get all the images belonging to a content entity
- *
- */
- public EntityList getImages(EntityContent content)
- throws StorageObjectException {
- EntityList returnList=null;
- if (content != null) {
- // get all to_topic from media_x_topic
- String id = content.getId();
- //this is not supported by mysql
- String subselect = "id in (select media_id from " + theTable + " where content_id=" + id+")";
-
- try {
- // 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"
- returnList = DatabaseImages.getInstance().selectByWhereClause(subselect,"id",-1);
- } catch (Exception e) {
- theLog.printDebugInfo("-- get images failed " + e.toString());
- throw new StorageObjectException("-- get images failed " + e.toString());
- }
- }
- return returnList;
- }
-
-
- /**
- * get all the uploaded/other Media belonging to a content entity
- *
- */
- public EntityList getOther(EntityContent content)
- throws StorageObjectException
- {
- /** @todo this should only fetch published media / rk */
-
- EntityList returnList=null;
- if (content != null) {
- // get all to_topic from media_x_topic
- String id = content.getId();
- //this is not supported by mysql
- String subselect = "id in (select media_id from " + theTable +
- " where content_id=" + id+")";
-
- try {
- // 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"
- returnList = DatabaseOther.getInstance().selectByWhereClause(subselect,
- "id");
- } catch (Exception e) {
- e.printStackTrace();
- theLog.printDebugInfo("-- get Other failed " + e.toString());
- throw new StorageObjectException("-- get Other failed "
- + e.toString());
- }
- }
- return returnList;
- }