Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-08-26 18:49:51 +0000
committerrescobar2010-08-26 18:49:51 +0000
commitbf7ecbb03b69f9d8a69f6c40cd0bfeed647f8996 (patch)
treee84be90b77c92c30ca64f7e8da95e72d8e68ffee /plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/SearchTagDataStore.java
parente5cf9854fa0f0ffa6cc019d7e15aba7cfc77e2fd (diff)
downloadorg.eclipse.osee-bf7ecbb03b69f9d8a69f6c40cd0bfeed647f8996.tar.gz
org.eclipse.osee-bf7ecbb03b69f9d8a69f6c40cd0bfeed647f8996.tar.xz
org.eclipse.osee-bf7ecbb03b69f9d8a69f6c40cd0bfeed647f8996.zip
"Team Workflow" - TGYTK - "Quick search needs to support special quotation marks"
Refactored for testability
Diffstat (limited to 'plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/SearchTagDataStore.java')
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/SearchTagDataStore.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/SearchTagDataStore.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/SearchTagDataStore.java
index 5af803900f8..ff5400f2aaa 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/SearchTagDataStore.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/SearchTagDataStore.java
@@ -16,6 +16,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.database.core.ConnectionHandler;
import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.framework.database.core.OseeConnection;
@@ -40,17 +41,23 @@ public class SearchTagDataStore {
private static final String SELECT_SEARCH_TAGS =
"select ost1.gamma_id from osee_search_tags ost1 where ost1.coded_tag_id = ?";
- public static long getTotalQueryIdsInQueue() throws OseeDataStoreException {
- return ConnectionHandler.runPreparedQueryFetchLong(-1L, SELECT_TOTAL_QUERY_IDS_IN_QUEUE);
+ private final IOseeDatabaseService databaseService;
+
+ public SearchTagDataStore(IOseeDatabaseService databaseService) {
+ this.databaseService = databaseService;
+ }
+
+ public long getTotalQueryIdsInQueue() throws OseeDataStoreException {
+ return databaseService.runPreparedQueryFetchObject(-1L, SELECT_TOTAL_QUERY_IDS_IN_QUEUE);
}
- public static long getTotalTags() throws OseeDataStoreException {
- return ConnectionHandler.runPreparedQueryFetchLong(-1L, SELECT_TOTAL_TAGS);
+ public long getTotalTags() throws OseeDataStoreException {
+ return databaseService.runPreparedQueryFetchObject(-1L, SELECT_TOTAL_TAGS);
}
- public static int deleteTags(OseeConnection connection, int queryId) throws OseeDataStoreException {
+ public int deleteTags(OseeConnection connection, int queryId) throws OseeDataStoreException {
int numberDeleted = 0;
- IOseeStatement chStmt = ConnectionHandler.getStatement(connection);
+ IOseeStatement chStmt = databaseService.getStatement(connection);
try {
chStmt.runPreparedQuery("select gamma_id from osee_join_transaction where query_id = ?", queryId);
List<Object[]> datas = new ArrayList<Object[]>();
@@ -58,7 +65,7 @@ public class SearchTagDataStore {
datas.add(new Object[] {chStmt.getLong("gamma_id")});
}
if (!datas.isEmpty()) {
- numberDeleted = ConnectionHandler.runBatchUpdate(connection, DELETE_SEARCH_TAGS, datas);
+ numberDeleted = databaseService.runBatchUpdate(connection, DELETE_SEARCH_TAGS, datas);
}
} finally {
chStmt.close();
@@ -66,23 +73,23 @@ public class SearchTagDataStore {
return numberDeleted;
}
- public static int deleteTags(OseeConnection connection, Collection<IAttributeLocator> locators) throws OseeDataStoreException {
+ public int deleteTags(OseeConnection connection, Collection<IAttributeLocator> locators) throws OseeDataStoreException {
return deleteTags(connection, locators.toArray(new IAttributeLocator[locators.size()]));
}
- public static int deleteTags(OseeConnection connection, IAttributeLocator... locators) throws OseeDataStoreException {
+ public int deleteTags(OseeConnection connection, IAttributeLocator... locators) throws OseeDataStoreException {
int numberDeleted = 0;
if (locators.length > 0) {
List<Object[]> datas = new ArrayList<Object[]>();
for (IAttributeLocator locator : locators) {
datas.add(new Object[] {locator.getGammaId()});
}
- numberDeleted = ConnectionHandler.runBatchUpdate(connection, DELETE_SEARCH_TAGS, datas);
+ numberDeleted = databaseService.runBatchUpdate(connection, DELETE_SEARCH_TAGS, datas);
}
return numberDeleted;
}
- public static int storeTags(OseeConnection connection, Collection<SearchTag> searchTags) throws OseeDataStoreException {
+ public int storeTags(OseeConnection connection, Collection<SearchTag> searchTags) throws OseeDataStoreException {
return storeTags(connection, searchTags.toArray(new SearchTag[searchTags.size()]));
}

Back to the top