From fb6f3ffb59c23e6ef19fd12520551bdc40aa8206 Mon Sep 17 00:00:00 2001 From: rescobar Date: Mon, 20 Sep 2010 12:44:47 -0700 Subject: refactor: Update IAttributeType to AttributeType conversion to use Collection --- .../search/engine/attribute/AttributeDataStore.java | 11 ++++++----- .../search/engine/internal/search/SearchEngine.java | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java index 662c4c9ec1e..ab1f80b8d7c 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java @@ -68,12 +68,12 @@ public final class AttributeDataStore { return attributeData; } - public static Set getAttributesByTags(int branchId, DeletionFlag deletionFlag, final Collection tagData, final AttributeType... attributeTypes) throws OseeCoreException { + public static Set getAttributesByTags(int branchId, DeletionFlag deletionFlag, final Collection tagData, final Collection attributeTypes) throws OseeCoreException { final Set toReturn = new HashSet(); IdJoinQuery oseeIdJoin = null; IOseeStatement chStmt = ConnectionHandler.getStatement(); - boolean useAttrTypeJoin = attributeTypes.length > 1; + boolean useAttrTypeJoin = attributeTypes.size() > 1; try { String sqlQuery = @@ -81,7 +81,7 @@ public final class AttributeDataStore { List params = new ArrayList(); params.addAll(tagData); - if (attributeTypes.length == 1) { + if (attributeTypes.size() == 1) { sqlQuery += " and attr1.attr_type_id = ?"; } else if (useAttrTypeJoin) { oseeIdJoin = JoinUtility.createIdJoinQuery(); @@ -95,8 +95,9 @@ public final class AttributeDataStore { if (branchId > -1) { params.add(branchId); } - if (attributeTypes.length == 1) { - params.add(attributeTypes[0].getId()); + if (attributeTypes.size() == 1) { + AttributeType type = attributeTypes.iterator().next(); + params.add(type.getId()); } chStmt.runPreparedQuery(sqlQuery, params.toArray(new Object[params.size()])); diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchEngine.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchEngine.java index 67a70dc1bd5..c178e8600c1 100644 --- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchEngine.java +++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchEngine.java @@ -11,11 +11,13 @@ package org.eclipse.osee.framework.search.engine.internal.search; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.logging.Level; import org.eclipse.osee.framework.core.data.IAttributeType; import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.exception.OseeStateException; import org.eclipse.osee.framework.core.message.SearchOptions; import org.eclipse.osee.framework.core.message.SearchRequest; import org.eclipse.osee.framework.core.message.SearchResponse; @@ -51,11 +53,16 @@ public class SearchEngine implements ISearchEngine { this.branchCache = branchCache; } - private AttributeType[] getAttributeTypes(Collection tokens) throws OseeCoreException { - AttributeType[] attributeTypes = new AttributeType[tokens.size()]; - int index = 0; + private Collection getAttributeTypes(Collection tokens) throws OseeCoreException { + Collection attributeTypes = new HashSet(); for (IAttributeType identity : tokens) { - attributeTypes[index++] = attributeTypeCache.get(identity); + AttributeType type = attributeTypeCache.get(identity); + if (type != null) { + attributeTypes.add(type); + } else { + throw new OseeStateException(String.format("Search Attribute Type Filter - attribute type [%s] not found", + identity)); + } } return attributeTypes; } @@ -82,7 +89,7 @@ public class SearchEngine implements ISearchEngine { SearchOptions options = searchRequest.getOptions(); Collection attributeTypeTokens = options.getAttributeTypeFilter(); - AttributeType[] attributeTypes = getAttributeTypes(attributeTypeTokens); + Collection attributeTypes = getAttributeTypes(attributeTypeTokens); int branchId = branchCache.get(searchRequest.getBranch()).getId(); Collection tagMatches = -- cgit v1.2.3