X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmircoders%2Fstorage%2FDatabaseContentToTopics.java;h=eca6c293dcd3eade7f3e82517e0f5185b135e791;hb=4451d4c8c25d46e9c405e966ff6bd016a1512f4f;hp=3d19a17ecf9b97510bc2bcd055e8190a97072b75;hpb=92ffdab0e35d5affcdffd9e239f7aafdbbe5cc34;p=mir.git diff --git a/source/mircoders/storage/DatabaseContentToTopics.java b/source/mircoders/storage/DatabaseContentToTopics.java index 3d19a17e..eca6c293 100755 --- a/source/mircoders/storage/DatabaseContentToTopics.java +++ b/source/mircoders/storage/DatabaseContentToTopics.java @@ -268,42 +268,28 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ freeConnection(con,stmt); } } - - + +/** + * Returns list of Content for a specific topic + * @param topic + * @return EntityList + * @throws StorageObjectFailure + */ public EntityList getContent(EntityTopics topic) throws StorageObjectFailure { EntityList returnList=null; if (topic != null) { - - // TODO rewrite with getByWhereClauseWithExtraTables - String id = topic.getId(); - String select = "select content_id from " + theTable + " where topic_id=" + id; - - // execute select statement - Connection con=null;Statement stmt=null; try { - con = getPooledCon(); - // should be a preparedStatement because is faster - stmt = con.createStatement(); - ResultSet rs = executeSql(stmt,select); - if (rs!=null) { - String topicSelect= "id IN ("; - boolean first=true; - while (rs.next()) { - if (first==false) topicSelect+=","; - topicSelect += rs.getString(1); - first=false; - } - topicSelect+=")"; - if (first==false) - returnList = DatabaseContent.getInstance().selectByWhereClause(topicSelect,-1); - } + Vector extraTables = new Vector(); + extraTables.add(theTable+" cxt"); + returnList = DatabaseContent.getInstance() + .selectByWhereClauseWithExtraTables("c",extraTables, + "c.id=cxt.content_id and cxt.topic_id="+id ); } catch (Exception e) { logger.error("-- get content failed"); } - finally { freeConnection(con,stmt);} } return returnList; }