diff options
author | Roberto E. Escobar | 2013-08-05 22:00:33 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2013-08-21 20:29:09 +0000 |
commit | a464fef91967e654a0a85079f2f23e18f290ad66 (patch) | |
tree | 36255ecf0a860a2e1dfb38a1eefe1ff841d2835f | |
parent | 4265ab02087418fe8890c7790278163d2fdb3fe8 (diff) | |
download | org.eclipse.osee-a464fef91967e654a0a85079f2f23e18f290ad66.tar.gz org.eclipse.osee-a464fef91967e654a0a85079f2f23e18f290ad66.tar.xz org.eclipse.osee-a464fef91967e654a0a85079f2f23e18f290ad66.zip |
refinement: Improve artifact type inheritance search API
Make artifact type inheritance search similar to java:
- andIsOfType similar to instanceof
- andTypeEquals similar to object.getClass() == Object.class
Change-Id: I348bcecdf85be828a42b7febf118766439984e9f
28 files changed, 265 insertions, 202 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java index 61ba32a571b..929f956ed31 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java @@ -227,7 +227,7 @@ public class ArtifactQueryBuilder { } if (Conditions.hasValues(artifactTypes)) { - builder.andIsOfType(artifactTypes); + builder.andTypeEquals(artifactTypes); } if (guidOrHrid != null) { diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryOptions.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryOptions.java index f23b924893a..49d845024bc 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryOptions.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryOptions.java @@ -16,7 +16,6 @@ package org.eclipse.osee.orcs.core.ds; public class QueryOptions extends Options { private boolean includeCache = true; - private boolean includeTypeInheritance = false; public QueryOptions() { super(); @@ -26,37 +25,27 @@ public class QueryOptions extends Options { public void reset() { super.reset(); includeCache = true; - includeTypeInheritance = false; } public boolean isCacheIncluded() { return includeCache; } - public boolean isTypeInheritanceIncluded() { - return includeTypeInheritance; - } - public void setIncludeCache(boolean enabled) { includeCache = enabled; } - public void setIncludeTypeInheritance(boolean enabled) { - includeTypeInheritance = enabled; - } - @Override public QueryOptions clone() { QueryOptions clone = new QueryOptions(); clone.setIncludeDeleted(this.areDeletedIncluded()); clone.setFromTransaction(this.getFromTransaction()); clone.includeCache = this.includeCache; - clone.includeTypeInheritance = this.includeTypeInheritance; return clone; } @Override public String toString() { - return "QueryOptions [includeCache=" + includeCache + ", includeTypeInheritance=" + includeTypeInheritance + " [" + super.toString() + "]]"; + return "QueryOptions [includeCache=" + includeCache + " [" + super.toString() + "]]"; } } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaArtifactType.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaArtifactType.java index 3ea4faf7bb9..3c904b50847 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaArtifactType.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaArtifactType.java @@ -26,11 +26,13 @@ public class CriteriaArtifactType extends Criteria<QueryOptions> { private final Collection<? extends IArtifactType> artifactTypes; private final ArtifactTypes artTypeCache; + private final boolean includeTypeInheritance; - public CriteriaArtifactType(ArtifactTypes artTypeCache, Collection<? extends IArtifactType> artifactTypes) { + public CriteriaArtifactType(ArtifactTypes artTypeCache, Collection<? extends IArtifactType> artifactTypes, boolean includeTypeInheritance) { super(); this.artifactTypes = artifactTypes; this.artTypeCache = artTypeCache; + this.includeTypeInheritance = includeTypeInheritance; } @Override @@ -39,27 +41,30 @@ public class CriteriaArtifactType extends Criteria<QueryOptions> { Conditions.checkNotNullOrEmpty(artifactTypes, "artifact types"); } - public Collection<? extends IArtifactType> getTypes() { + public Collection<? extends IArtifactType> getOriginalTypes() { return artifactTypes; } - @Override - public String toString() { - return "CriteriaArtifactType [artifactTypes=" + artifactTypes + "]"; - } - - public Collection<? extends IArtifactType> getTypes(QueryOptions options) throws OseeCoreException { - Collection<IArtifactType> typesToUse = new LinkedHashSet<IArtifactType>(); - boolean includeTypeInheritance = options.isTypeInheritanceIncluded(); - for (IArtifactType type : artifactTypes) { - if (includeTypeInheritance) { + public Collection<? extends IArtifactType> getTypes() throws OseeCoreException { + Collection<? extends IArtifactType> toReturn; + if (includeTypeInheritance) { + Collection<IArtifactType> typesToUse = new LinkedHashSet<IArtifactType>(); + for (IArtifactType type : getOriginalTypes()) { for (IArtifactType descendant : artTypeCache.getAllDescendantTypes(type)) { typesToUse.add(descendant); } + typesToUse.add(type); } - typesToUse.add(type); + toReturn = typesToUse; + } else { + toReturn = getOriginalTypes(); } - return typesToUse; + return toReturn; + } + + @Override + public String toString() { + return "CriteriaArtifactType [artifactTypes=" + artifactTypes + ", includeTypeInheritance=" + includeTypeInheritance + "]"; } } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CriteriaFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CriteriaFactory.java index 947d983dec1..728e2abedee 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CriteriaFactory.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CriteriaFactory.java @@ -86,7 +86,11 @@ public class CriteriaFactory { } public Criteria<QueryOptions> createArtifactTypeCriteria(Collection<? extends IArtifactType> artifactTypes) throws OseeCoreException { - return new CriteriaArtifactType(artifactTypeCache, artifactTypes); + return new CriteriaArtifactType(artifactTypeCache, artifactTypes, false); + } + + public Criteria<QueryOptions> createArtifactTypeCriteriaWithInheritance(Collection<? extends IArtifactType> artifactTypes) throws OseeCoreException { + return new CriteriaArtifactType(artifactTypeCache, artifactTypes, true); } public Criteria<QueryOptions> createArtifactIdCriteria(Collection<Integer> artifactIds) throws OseeCoreException { diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java index 02a84fe85f6..93ba7f6846d 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java @@ -102,23 +102,6 @@ public class QueryBuilderImpl implements QueryBuilder { } @Override - public QueryBuilder includeTypeInheritance() { - includeTypeInheritance(true); - return this; - } - - @Override - public QueryBuilder includeTypeInheritance(boolean enabled) { - getOptions().setIncludeTypeInheritance(enabled); - return this; - } - - @Override - public boolean isTypeInheritanceIncluded() { - return getOptions().isTypeInheritanceIncluded(); - } - - @Override public QueryBuilder fromTransaction(int transactionId) { getOptions().setFromTransaction(transactionId); return this; @@ -153,18 +136,6 @@ public class QueryBuilderImpl implements QueryBuilder { } @Override - public QueryBuilder excludeTypeInheritance() { - includeTypeInheritance(false); - return this; - } - - @Override - public QueryBuilder resetToDefaults() { - getOptions().reset(); - return this; - } - - @Override public QueryBuilder andLocalId(int... artifactIds) throws OseeCoreException { Set<Integer> ids = new HashSet<Integer>(); for (Integer id : artifactIds) { @@ -216,12 +187,22 @@ public class QueryBuilderImpl implements QueryBuilder { @Override public QueryBuilder andIsOfType(IArtifactType... artifactType) throws OseeCoreException { - Criteria<QueryOptions> criteria = criteriaFactory.createArtifactTypeCriteria(Arrays.asList(artifactType)); - return addAndCheck(getQueryData(), criteria); + return andIsOfType(Arrays.asList(artifactType)); } @Override public QueryBuilder andIsOfType(Collection<? extends IArtifactType> artifactType) throws OseeCoreException { + Criteria<QueryOptions> criteria = criteriaFactory.createArtifactTypeCriteriaWithInheritance(artifactType); + return addAndCheck(getQueryData(), criteria); + } + + @Override + public QueryBuilder andTypeEquals(IArtifactType... artifactType) throws OseeCoreException { + return andTypeEquals(Arrays.asList(artifactType)); + } + + @Override + public QueryBuilder andTypeEquals(Collection<? extends IArtifactType> artifactType) throws OseeCoreException { Criteria<QueryOptions> criteria = criteriaFactory.createArtifactTypeCriteria(artifactType); return addAndCheck(getQueryData(), criteria); } diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java index 25b832773a1..8d345588e6d 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java @@ -68,7 +68,8 @@ public class QueryEngineImplTest { private static final Criteria<?> GUIDS = new CriteriaArtifactGuids(Arrays.asList(GUID.create(), GUID.create())); private static final Criteria<?> IDS = new CriteriaArtifactIds(Arrays.asList(1, 2, 3, 4, 5)); private static final Criteria<?> HRIDS = new CriteriaArtifactHrids(Arrays.asList("ABCDE", "FGHIJ")); - private static final Criteria<?> TYPES = new CriteriaArtifactType(null, Arrays.asList(CoreArtifactTypes.CodeUnit)); + private static final Criteria<?> TYPES = new CriteriaArtifactType(null, Arrays.asList(CoreArtifactTypes.CodeUnit), + false); private static final Criteria<?> ATTRIBUTE = new CriteriaAttributeOther(CoreAttributeTypes.Name, Arrays.asList("Hello"), Operator.EQUAL); diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlHandlerFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlHandlerFactoryImplTest.java index aad186fd5d1..d1994cc029f 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlHandlerFactoryImplTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlHandlerFactoryImplTest.java @@ -91,7 +91,7 @@ public class QuerySqlHandlerFactoryImplTest { criteria.add(new CriteriaArtifactGuids(null)); criteria.add(new CriteriaArtifactHrids(null)); criteria.add(new CriteriaArtifactIds(null)); - criteria.add(new CriteriaArtifactType(null, null)); + criteria.add(new CriteriaArtifactType(null, null, true)); criteria.add(new CriteriaRelationTypeExists(null)); criteria.add(new CriteriaAttributeTypeExists(null)); criteria.add(new CriteriaAttributeOther(null, null, null)); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/ArtifactTypeSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/ArtifactTypeSqlHandler.java index d5b34cf9ee9..9f14216d911 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/ArtifactTypeSqlHandler.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/ArtifactTypeSqlHandler.java @@ -45,7 +45,7 @@ public class ArtifactTypeSqlHandler extends SqlHandler<CriteriaArtifactType, Que @Override public void addTables(AbstractSqlWriter<QueryOptions> writer) throws OseeCoreException { - typeIds = getLocalTypeIds(writer.getOptions()); + typeIds = getLocalTypeIds(); if (typeIds.size() > 1) { jIdAlias = writer.addTable(TableEnum.ID_JOIN_TABLE); } @@ -63,8 +63,8 @@ public class ArtifactTypeSqlHandler extends SqlHandler<CriteriaArtifactType, Que txsAliases = writer.getAliases(TableEnum.TXS_TABLE); } - private Collection<Integer> getLocalTypeIds(QueryOptions options) throws OseeCoreException { - Collection<? extends IArtifactType> types = criteria.getTypes(options); + private Collection<Integer> getLocalTypeIds() throws OseeCoreException { + Collection<? extends IArtifactType> types = criteria.getTypes(); Collection<Integer> toReturn = new HashSet<Integer>(); for (IArtifactType type : types) { int localId = getIdentityService().getLocalId(type); diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java index 444fd82da55..ea3ddfae3de 100644 --- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java +++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java @@ -43,12 +43,6 @@ public interface QueryBuilder { boolean areDeletedIncluded(); - QueryBuilder includeTypeInheritance(); - - QueryBuilder includeTypeInheritance(boolean enabled); - - boolean isTypeInheritanceIncluded(); - QueryBuilder fromTransaction(int transactionId); int getFromTransaction(); @@ -61,13 +55,6 @@ public interface QueryBuilder { QueryBuilder excludeDeleted(); - QueryBuilder excludeTypeInheritance(); - - /** - * Resets query builder to default settings. This also clear all criteria added to original query. - */ - QueryBuilder resetToDefaults(); - /** * Search criteria that finds a given artifact id */ @@ -99,16 +86,26 @@ public interface QueryBuilder { QueryBuilder andIds(Collection<? extends IArtifactToken> artifactTokens) throws OseeCoreException; /** - * Search criteria that finds a given artifact type + * Search criteria that finds a given artifact type using type inheritance */ QueryBuilder andIsOfType(IArtifactType... artifactType) throws OseeCoreException; /** - * Search criteria that finds a given artifact types + * Search criteria that finds a given artifact types using type inheritance */ QueryBuilder andIsOfType(Collection<? extends IArtifactType> artifactType) throws OseeCoreException; /** + * Search criteria that finds a given artifact type by matching type exactly + */ + QueryBuilder andTypeEquals(IArtifactType... artifactType) throws OseeCoreException; + + /** + * Search criteria that finds a given artifact types by matching type exactly + */ + QueryBuilder andTypeEquals(Collection<? extends IArtifactType> artifactType) throws OseeCoreException; + + /** * Search criteria that checks for the existence of an attribute type(s). */ QueryBuilder andExists(IAttributeType... attributeType) throws OseeCoreException; diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactory.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactory.java index dc80e16565a..798438a8100 100644 --- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactory.java +++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactory.java @@ -31,7 +31,9 @@ public interface PredicateFactory { Predicate createIdSearch(Collection<? extends Identity<String>> ids); - Predicate createTypeSearch(Collection<? extends IArtifactType> artifactType); + Predicate createIsOfTypeSearch(Collection<? extends IArtifactType> artifactType); + + Predicate createTypeEqualsSearch(Collection<? extends IArtifactType> artifactType); Predicate createAttributeTypeSearch(Collection<? extends IAttributeType> attributeTypes, String value, QueryOption... options); diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java index e11b7762fe0..35b8716e30c 100644 --- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java @@ -73,13 +73,20 @@ public class PredicateFactoryImpl implements PredicateFactory { } @Override - public Predicate createTypeSearch(Collection<? extends IArtifactType> artifactType) { + public Predicate createIsOfTypeSearch(Collection<? extends IArtifactType> artifactType) { List<String> typeIds = getLongIds(artifactType); return new Predicate(SearchMethod.IS_OF_TYPE, emptyStringList, SearchOp.EQUALS, emptySearchFlagList, Strings.EMPTY_STRING, typeIds); } @Override + public Predicate createTypeEqualsSearch(Collection<? extends IArtifactType> artifactType) { + List<String> typeIds = getLongIds(artifactType); + return new Predicate(SearchMethod.TYPE_EQUALS, emptyStringList, SearchOp.EQUALS, emptySearchFlagList, + Strings.EMPTY_STRING, typeIds); + } + + @Override public Predicate createAttributeTypeSearch(Collection<? extends IAttributeType> attributeTypes, String value, QueryOption... options) { List<String> typeIds = getLongIds(attributeTypes); List<String> values = Collections.singletonList(value); @@ -158,5 +165,4 @@ public class PredicateFactoryImpl implements PredicateFactory { visitor.accept(options); return visitor; } - } diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java index 4e7e3d06bcd..b474549524f 100644 --- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java +++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java @@ -46,12 +46,6 @@ public class QueryBuilderImpl implements QueryBuilder { this.options = options; this.predicateFactory = predicateFactory; this.executor = executor; - reset(); - } - - private void reset() { - options.reset(); - predicates.clear(); } @Override @@ -87,23 +81,6 @@ public class QueryBuilderImpl implements QueryBuilder { } @Override - public QueryBuilder includeTypeInheritance() { - includeTypeInheritance(true); - return this; - } - - @Override - public QueryBuilder includeTypeInheritance(boolean enabled) { - options.setIncludeTypeInheritance(enabled); - return this; - } - - @Override - public boolean isTypeInheritanceIncluded() { - return options.isTypeInheritanceIncluded(); - } - - @Override public QueryBuilder fromTransaction(int transactionId) { options.setFromTransaction(transactionId); return this; @@ -137,18 +114,6 @@ public class QueryBuilderImpl implements QueryBuilder { } @Override - public QueryBuilder excludeTypeInheritance() { - includeTypeInheritance(false); - return this; - } - - @Override - public QueryBuilder resetToDefaults() { - reset(); - return this; - } - - @Override public QueryBuilder andLocalId(int... artifactId) { Collection<Integer> ids = new LinkedList<Integer>(); for (int id : artifactId) { @@ -192,7 +157,18 @@ public class QueryBuilderImpl implements QueryBuilder { @Override public QueryBuilder andIsOfType(Collection<? extends IArtifactType> artifactTypes) { - predicates.add(predicateFactory.createTypeSearch(artifactTypes)); + predicates.add(predicateFactory.createIsOfTypeSearch(artifactTypes)); + return this; + } + + @Override + public QueryBuilder andTypeEquals(IArtifactType... artifactType) { + return andTypeEquals(Arrays.asList(artifactType)); + } + + @Override + public QueryBuilder andTypeEquals(Collection<? extends IArtifactType> artifactTypes) { + predicates.add(predicateFactory.createTypeEqualsSearch(artifactTypes)); return this; } diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java index b8913eebe8e..d24512371d2 100644 --- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java +++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java @@ -21,9 +21,9 @@ import org.eclipse.osee.orcs.rest.model.ExceptionEntity; import org.eclipse.osee.orcs.rest.model.search.OutputFormat; import org.eclipse.osee.orcs.rest.model.search.Predicate; import org.eclipse.osee.orcs.rest.model.search.RequestType; -import org.eclipse.osee.orcs.rest.model.search.SearchResult; import org.eclipse.osee.orcs.rest.model.search.SearchRequest; import org.eclipse.osee.orcs.rest.model.search.SearchResponse; +import org.eclipse.osee.orcs.rest.model.search.SearchResult; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; @@ -59,11 +59,6 @@ public class QueryExecutorV1 implements QueryExecutor { fromTx = options.getFromTransaction(); } - boolean includeTypeInh = false; - if (options.isTypeInheritanceIncluded()) { - includeTypeInh = true; - } - boolean includeCache = false; if (options.isCacheIncluded()) { includeCache = true; @@ -76,7 +71,7 @@ public class QueryExecutorV1 implements QueryExecutor { SearchRequest params = new SearchRequest(branch.getGuid(), predicates, outputFormat.name().toLowerCase(), - requestType.name().toLowerCase(), fromTx, includeTypeInh, includeCache, includeDeleted); + requestType.name().toLowerCase(), fromTx, includeCache, includeDeleted); URI uri = uriProvider.getEncodedURI(String.format("oseex/branch/%s/artifact/search/v1", branch.getGuid()), null); diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryOptions.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryOptions.java index 4596eaf326b..8cdfaad5fcf 100644 --- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryOptions.java +++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryOptions.java @@ -18,7 +18,6 @@ import org.eclipse.osee.orcs.rest.client.internal.Options; public class QueryOptions extends Options { private boolean includeCache = true; - private boolean includeTypeInheritance = false; public QueryOptions() { super(); @@ -28,37 +27,27 @@ public class QueryOptions extends Options { public void reset() { super.reset(); includeCache = true; - includeTypeInheritance = false; } public boolean isCacheIncluded() { return includeCache; } - public boolean isTypeInheritanceIncluded() { - return includeTypeInheritance; - } - public void setIncludeCache(boolean enabled) { includeCache = enabled; } - public void setIncludeTypeInheritance(boolean enabled) { - includeTypeInheritance = enabled; - } - @Override public QueryOptions clone() { QueryOptions clone = new QueryOptions(); clone.setIncludeDeleted(this.areDeletedIncluded()); clone.setFromTransaction(this.getFromTransaction()); clone.includeCache = this.includeCache; - clone.includeTypeInheritance = this.includeTypeInheritance; return clone; } @Override public String toString() { - return "QueryOptions [includeCache=" + includeCache + ", includeTypeInheritance=" + includeTypeInheritance + " [" + super.toString() + "]]"; + return "QueryOptions [includeCache=" + includeCache + " [" + super.toString() + "]]"; } } diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchMethod.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchMethod.java index cf45ead3381..adc577c4df4 100644 --- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchMethod.java +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchMethod.java @@ -21,6 +21,7 @@ public enum SearchMethod { IDS("ids"), GUID_OR_HRIDS("guids"), IS_OF_TYPE("isOfType"), + TYPE_EQUALS("typeEquals"), EXISTS_TYPE("exists"), ATTRIBUTE_TYPE("attrType"), RELATED_TO("related"); diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchParameters.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchParameters.java index 87d910a823e..a7e76239675 100644 --- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchParameters.java +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchParameters.java @@ -26,14 +26,10 @@ public interface SearchParameters { String getFields(); - boolean isIncludeTypeInheritance(); - boolean isIncludeCache(); boolean isIncludeDeleted(); int getFromTx(); - boolean isIncludeTypeInh(); - } diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchRequest.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchRequest.java index 7a2862cf666..76320e38421 100644 --- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchRequest.java +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchRequest.java @@ -27,7 +27,6 @@ public class SearchRequest implements SearchParameters { private String alt; private String fields; private int fromTx; - private boolean includeTypeInh; private boolean includeCache; private boolean includeDeleted; @@ -38,14 +37,13 @@ public class SearchRequest implements SearchParameters { super(); } - public SearchRequest(String branchUuid, List<Predicate> predicates, String alt, String fields, int fromTx, boolean includeTypeInheritance, boolean includeCache, boolean includeDeleted) { + public SearchRequest(String branchUuid, List<Predicate> predicates, String alt, String fields, int fromTx, boolean includeCache, boolean includeDeleted) { super(); this.branchUuid = branchUuid; this.predicates = predicates; this.alt = alt; this.fields = fields; this.fromTx = fromTx; - this.includeTypeInh = includeTypeInheritance; this.includeCache = includeCache; this.includeDeleted = includeDeleted; } @@ -89,11 +87,6 @@ public class SearchRequest implements SearchParameters { } @Override - public boolean isIncludeTypeInheritance() { - return includeTypeInh; - } - - @Override public boolean isIncludeCache() { return includeCache; } @@ -112,15 +105,6 @@ public class SearchRequest implements SearchParameters { this.fromTx = fromTx; } - @Override - public boolean isIncludeTypeInh() { - return includeTypeInh; - } - - public void setIncludeTypeInh(boolean includeTypeInh) { - this.includeTypeInh = includeTypeInh; - } - public void setIncludeCache(boolean includeCache) { this.includeCache = includeCache; } diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/InternalTestSuite.java index 35c3513c3ed..a50d51d74d4 100644 --- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/InternalTestSuite.java +++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/InternalTestSuite.java @@ -17,6 +17,7 @@ import org.eclipse.osee.orcs.rest.internal.search.predicate.ExistsTypePredicateH import org.eclipse.osee.orcs.rest.internal.search.predicate.GuidOrHridsPredicateHandlerTest; import org.eclipse.osee.orcs.rest.internal.search.predicate.IdsPredicateHandlerTest; import org.eclipse.osee.orcs.rest.internal.search.predicate.IsOfTypePredicateHandlerTest; +import org.eclipse.osee.orcs.rest.internal.search.predicate.TypeEqualsPredicateHandlerTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -31,7 +32,8 @@ import org.junit.runners.Suite; ExistsTypePredicateHandlerTest.class, IdsPredicateHandlerTest.class, GuidOrHridsPredicateHandlerTest.class, - IsOfTypePredicateHandlerTest.class,}) + IsOfTypePredicateHandlerTest.class, + TypeEqualsPredicateHandlerTest.class}) public class InternalTestSuite { // Test Suite } diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java index 140f482394d..e1ecea13032 100644 --- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java +++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java @@ -16,7 +16,6 @@ import static org.mockito.Mockito.when; import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.core.exception.OseeCoreException; @@ -28,6 +27,7 @@ import org.eclipse.osee.orcs.rest.model.search.SearchOp; import org.eclipse.osee.orcs.rest.model.search.SearchRequest; import org.eclipse.osee.orcs.search.QueryBuilder; import org.eclipse.osee.orcs.search.QueryFactory; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -68,8 +68,8 @@ public class SearchDslTest { new Predicate(SearchMethod.ATTRIBUTE_TYPE, Arrays.asList("1000000000000070"), SearchOp.EQUALS, null, Strings.EMPTY_STRING, Arrays.asList("AtsAdmin")); SearchRequest params = - new SearchRequest(BRANCH.getGuid(), Arrays.asList(predicate), Strings.EMPTY_STRING, Strings.EMPTY_STRING, - 0, false, false, false); + new SearchRequest(BRANCH.getGuid(), Arrays.asList(predicate), Strings.EMPTY_STRING, Strings.EMPTY_STRING, 0, + false, false); dsl.build(queryFactory, params); diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/TypeEqualsPredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/TypeEqualsPredicateHandlerTest.java new file mode 100644 index 00000000000..74505d50c84 --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/TypeEqualsPredicateHandlerTest.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2012 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.orcs.rest.internal.search.predicate; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.verify; +import static org.mockito.MockitoAnnotations.initMocks; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import org.eclipse.osee.framework.core.data.IArtifactType; +import org.eclipse.osee.framework.core.exception.OseeArgumentException; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.orcs.rest.internal.search.PredicateHandler; +import org.eclipse.osee.orcs.rest.model.search.Predicate; +import org.eclipse.osee.orcs.rest.model.search.SearchMethod; +import org.eclipse.osee.orcs.search.QueryBuilder; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; + +/** + * @author Roberto E. Escobar + */ +public class TypeEqualsPredicateHandlerTest { + + @Mock + private QueryBuilder builder; + + @Captor + private ArgumentCaptor<Collection<IArtifactType>> artifactTypesCaptor; + + private PredicateHandler handler; + + @Before + public void initialize() { + initMocks(this); + + handler = new TypeEqualsPredicateHandler(); + } + + @Test + public void testHandleSingle() throws OseeCoreException { + //no type params, op, or flags for ids - any passed are ignored + + String id1 = "12345"; + List<String> values = Collections.singletonList(id1); + Predicate testPredicate = new Predicate(SearchMethod.TYPE_EQUALS, null, null, null, null, values); + handler.handle(builder, testPredicate); + + verify(builder).andTypeEquals(artifactTypesCaptor.capture()); + + assertEquals(1, artifactTypesCaptor.getValue().size()); + assertTrue(artifactTypesCaptor.getValue().iterator().next().getGuid().toString().equals(id1)); + } + + @Test + public void testHandleMultiple() throws OseeCoreException { + String id1 = "12345"; + String id2 = "45678"; + List<String> values = Arrays.asList(id1, id2); + + Predicate testPredicate = new Predicate(SearchMethod.TYPE_EQUALS, null, null, null, null, values); + handler.handle(builder, testPredicate); + + verify(builder).andTypeEquals(artifactTypesCaptor.capture()); + + assertEquals(2, artifactTypesCaptor.getValue().size()); + + Iterator<IArtifactType> iterator = artifactTypesCaptor.getValue().iterator(); + + assertEquals(id2, iterator.next().getGuid().toString()); + assertEquals(id1, iterator.next().getGuid().toString()); + } + + @Test(expected = OseeArgumentException.class) + public void testHandleBadValues() throws OseeCoreException { + Predicate testPredicate = new Predicate(SearchMethod.TYPE_EQUALS, null, null, null, null, null); + handler.handle(builder, testPredicate); + } + + @Test(expected = OseeArgumentException.class) + public void testBadSearchMethod() throws OseeCoreException { + String id1 = "12345"; + List<String> values = Collections.singletonList(id1); + Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, null, null, null, values); + handler.handle(builder, testPredicate); + } +} diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java index 92bc4a54bf4..a28b2f1cf65 100644 --- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java +++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java @@ -64,8 +64,6 @@ public class ArtifactSearch_V1 extends ArtifactSearch { * @param fromTransaction (Optional) Transaction ID for a historical context. Use this parameter if you want the * search results to represent a specific point in time in the past. Without this parameter search results will * reflect the most current state of the data. - * @param includeTypeInheritance (Optional) Boolean parameter that configures the search to use hiearchical type - * inheritance if possible. * @param includeCache (Optional) Boolean parameter that configures the search to ??? * @param includeDeleted (Optional) Boolean parameter that configures the search to include deleted artifacts in its * result set and analysis. @@ -76,7 +74,7 @@ public class ArtifactSearch_V1 extends ArtifactSearch { * <b>rawQuery Syntax</b><br> * The query syntax is composed of one or more predicates - atomic search instructions - that can be appended * together as compound AND or OR query statements. Each predicate is surrounded by square brackets '[' and ']' which - * makes writing a formal definitoin of the syntax a little confusing since the square bracket traditionally + * makes writing a formal definition of the syntax a little confusing since the square bracket traditionally * surrounds optional items in a syntax. Because of this please note in the formal definition below literal square * brackets - those which belong as actual characters in the syntax - are escaped with a back slash character '\'.<br> * <b>Example Request String</b><br> @@ -99,11 +97,11 @@ public class ArtifactSearch_V1 extends ArtifactSearch { */ @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public SearchResponse getSearchWithQueryParams(@QueryParam("alt") String alt, @QueryParam("fields") String fields, @QueryParam("q") String rawQuery, @QueryParam("fromTx") int fromTransaction, @QueryParam("inherits") boolean includeTypeInheritance, @QueryParam("cached") boolean includeCache, @QueryParam("includeDeleted") boolean includeDeleted) throws OseeCoreException { + public SearchResponse getSearchWithQueryParams(@QueryParam("alt") String alt, @QueryParam("fields") String fields, @QueryParam("q") String rawQuery, @QueryParam("fromTx") int fromTransaction, @QueryParam("cached") boolean includeCache, @QueryParam("includeDeleted") boolean includeDeleted) throws OseeCoreException { DslTranslator translator = DslFactory.createTranslator(); SearchRequest params = - new SearchRequest(getBranchUuid(), translator.translate(rawQuery), alt, fields, fromTransaction, - includeTypeInheritance, includeCache, includeDeleted); + new SearchRequest(getBranchUuid(), translator.translate(rawQuery), alt, fields, fromTransaction, includeCache, + includeDeleted); return search(params); } @@ -122,7 +120,6 @@ public class ArtifactSearch_V1 extends ArtifactSearch { QueryBuilder builder = searchQueryBuilder.build(qFactory, params); builder.includeCache(params.isIncludeCache()); - builder.includeTypeInheritance(params.isIncludeTypeInheritance()); builder.includeDeleted(params.isIncludeDeleted()); if (params.getFromTx() > 0) { diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslFactory.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslFactory.java index 3910685d70e..ab9724a888e 100644 --- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslFactory.java +++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslFactory.java @@ -18,6 +18,7 @@ import org.eclipse.osee.orcs.rest.internal.search.predicate.ExistsTypePredicateH import org.eclipse.osee.orcs.rest.internal.search.predicate.GuidOrHridsPredicateHandler; import org.eclipse.osee.orcs.rest.internal.search.predicate.IdsPredicateHandler; import org.eclipse.osee.orcs.rest.internal.search.predicate.IsOfTypePredicateHandler; +import org.eclipse.osee.orcs.rest.internal.search.predicate.TypeEqualsPredicateHandler; import org.eclipse.osee.orcs.rest.model.search.SearchMethod; /** @@ -45,6 +46,7 @@ public class DslFactory { handlers.put(SearchMethod.IDS, new IdsPredicateHandler()); handlers.put(SearchMethod.GUID_OR_HRIDS, new GuidOrHridsPredicateHandler()); handlers.put(SearchMethod.IS_OF_TYPE, new IsOfTypePredicateHandler()); + handlers.put(SearchMethod.TYPE_EQUALS, new TypeEqualsPredicateHandler()); handlers.put(SearchMethod.EXISTS_TYPE, new ExistsTypePredicateHandler()); handlers.put(SearchMethod.ATTRIBUTE_TYPE, new AttributeTypePredicateHandler()); return handlers; diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandler.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandler.java index 2d04869ed44..d36b24671c3 100644 --- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandler.java +++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandler.java @@ -40,8 +40,4 @@ public class IsOfTypePredicateHandler implements PredicateHandler { return builder; } - protected QueryBuilder andIsOfType(QueryBuilder builder, Collection<IArtifactType> artTypes) throws OseeCoreException { - return builder.andIsOfType(artTypes); - } - } diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/TypeEqualsPredicateHandler.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/TypeEqualsPredicateHandler.java new file mode 100644 index 00000000000..4de4d8f5061 --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/TypeEqualsPredicateHandler.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2012 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.orcs.rest.internal.search.predicate; + +import java.util.Collection; +import org.eclipse.osee.framework.core.data.IArtifactType; +import org.eclipse.osee.framework.core.exception.OseeArgumentException; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.util.Conditions; +import org.eclipse.osee.orcs.rest.internal.search.PredicateHandler; +import org.eclipse.osee.orcs.rest.model.search.Predicate; +import org.eclipse.osee.orcs.rest.model.search.SearchMethod; +import org.eclipse.osee.orcs.search.QueryBuilder; + +/** + * @author John R. Misinco + * @author Roberto E. Escobar + */ +public class TypeEqualsPredicateHandler implements PredicateHandler { + + @Override + public QueryBuilder handle(QueryBuilder builder, Predicate predicate) throws OseeCoreException { + if (predicate.getType() != SearchMethod.TYPE_EQUALS) { + throw new OseeArgumentException("This predicate handler only supports [%s]", SearchMethod.TYPE_EQUALS); + } + Collection<String> values = predicate.getValues(); + Conditions.checkNotNull(values, "values"); + Collection<IArtifactType> artTypes = PredicateHandlerUtil.getIArtifactTypes(values); + if (!artTypes.isEmpty()) { + builder.andTypeEquals(artTypes); + } + return builder; + } + +} diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsPortingTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsPortingTest.java index 48405f08693..30ae920f34f 100644 --- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsPortingTest.java +++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsPortingTest.java @@ -89,7 +89,7 @@ public class OrcsPortingTest { // the attribute for the SecondRequirement should not be named "test changed again" (on the branch after the copy from) // we should have a folder named "childBranch folder", but no folder named "folder after transaction" ResultSet<ArtifactReadable> artifacts = - query.fromBranch(finalTx.getBranch()).andIsOfType(CoreArtifactTypes.Artifact).getResults(); + query.fromBranch(finalTx.getBranch()).andTypeEquals(CoreArtifactTypes.Artifact).getResults(); for (ArtifactReadable art : artifacts) { if (art.isOfType(CoreArtifactTypes.SoftwareRequirement)) { Assert.assertEquals(2, art.getAttributes().size()); diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java index 4b2a19139f9..0e088782914 100644 --- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java +++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java @@ -113,15 +113,15 @@ public class OrcsQueryTest { @Test public void testQueryArtifactTypeInheritance() throws OseeCoreException { QueryBuilder builder = - factory.fromBranch(TestBranches.SAW_Bld_1).andIsOfType(CoreArtifactTypes.AbstractSoftwareRequirement);// + factory.fromBranch(TestBranches.SAW_Bld_1).andTypeEquals(CoreArtifactTypes.AbstractSoftwareRequirement); - builder.excludeTypeInheritance(); Assert.assertEquals(0, builder.getCount()); ArtifactReadable artifact = builder.getResults().getOneOrNull(); Assert.assertNull(artifact); - builder.includeTypeInheritance(); + builder = factory.fromBranch(TestBranches.SAW_Bld_1).andIsOfType(CoreArtifactTypes.AbstractSoftwareRequirement); + Assert.assertEquals(24, builder.getCount()); List<ArtifactReadable> artifacts = builder.getResults().getList(); @@ -131,10 +131,9 @@ public class OrcsQueryTest { } @Test - public void testQueryArtifactTypesNoInheritance() throws OseeCoreException { + public void testQueryArtifactTypesMatch() throws OseeCoreException { QueryBuilder builder = factory.fromBranch(CoreBranches.COMMON); - builder.excludeTypeInheritance(); - builder.andIsOfType(CoreArtifactTypes.OseeTypeDefinition, CoreArtifactTypes.Folder); + builder.andTypeEquals(CoreArtifactTypes.OseeTypeDefinition, CoreArtifactTypes.Folder); Assert.assertEquals(6, builder.getCount()); @@ -210,7 +209,7 @@ public class OrcsQueryTest { ////////////////////// QueryBuilder builder1 = factory.fromBranch(TestBranches.SAW_Bld_1); builder1.and(CoreAttributeTypes.Name, "Requirements", MatchTokenCountType.IGNORE_TOKEN_COUNT); - builder1.andIsOfType(CoreArtifactTypes.SubsystemRequirementMSWord); + builder1.andTypeEquals(CoreArtifactTypes.SubsystemRequirementMSWord); Assert.assertEquals(1, builder1.getCount()); List<ArtifactReadable> subSystemReqs = builder1.getResults().getList(); Assert.assertEquals(1, subSystemReqs.size()); @@ -220,7 +219,6 @@ public class OrcsQueryTest { ////////////////////// QueryBuilder builder2 = factory.fromBranch(TestBranches.SAW_Bld_1); builder2.and(CoreAttributeTypes.Name, "Requirements", MatchTokenCountType.IGNORE_TOKEN_COUNT); - builder2.includeTypeInheritance(); builder2.andIsOfType(CoreArtifactTypes.Requirement); Assert.assertEquals(3, builder2.getCount()); diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryBuilder.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryBuilder.java index 5eccaa56674..063d0485754 100644 --- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryBuilder.java +++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryBuilder.java @@ -47,12 +47,6 @@ public interface QueryBuilder { boolean areDeletedIncluded(); - QueryBuilder includeTypeInheritance(); - - QueryBuilder includeTypeInheritance(boolean enabled); - - boolean isTypeInheritanceIncluded(); - QueryBuilder fromTransaction(int transactionId); int getFromTransaction(); @@ -65,13 +59,6 @@ public interface QueryBuilder { QueryBuilder excludeDeleted(); - QueryBuilder excludeTypeInheritance(); - - /** - * Resets query builder to default settings. This also clear all criteria added to original query. - */ - QueryBuilder resetToDefaults(); - /** * Search criteria that finds a given artifact id */ @@ -103,16 +90,26 @@ public interface QueryBuilder { QueryBuilder andIds(Collection<? extends IArtifactToken> artifactTokens) throws OseeCoreException; /** - * Search criteria that finds a given artifact type + * Search criteria that finds a given artifact type using type inheritance */ QueryBuilder andIsOfType(IArtifactType... artifactType) throws OseeCoreException; /** - * Search criteria that finds a given artifact types + * Search criteria that finds a given artifact types using type inheritance */ QueryBuilder andIsOfType(Collection<? extends IArtifactType> artifactType) throws OseeCoreException; /** + * Search criteria that finds a given artifact types by matching type exactly + */ + QueryBuilder andTypeEquals(IArtifactType... artifactType) throws OseeCoreException; + + /** + * Search criteria that finds a given artifact types by matching type exactly + */ + QueryBuilder andTypeEquals(Collection<? extends IArtifactType> artifactType) throws OseeCoreException; + + /** * Search criteria that checks for the existence of an attribute type(s). */ QueryBuilder andExists(IAttributeType... attributeType) throws OseeCoreException; diff --git a/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java b/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java index 3aba3e95855..72e6da1606c 100644 --- a/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java +++ b/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java @@ -13,6 +13,8 @@ package org.eclipse.osee.x.server.integration.tests.performance; import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Folder; import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.GeneralData; import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.GeneralDocument; +import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Requirement; +import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.SoftwareRequirement; import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.AccessContextId; import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.Active; import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON; @@ -21,7 +23,6 @@ import org.databene.contiperf.PerfTest; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.Identity; import org.eclipse.osee.framework.core.enums.CaseType; -import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.MatchTokenCountType; import org.eclipse.osee.framework.core.enums.SystemUser; @@ -167,7 +168,7 @@ public class OseeClientQueryTest { @Test public void searchForArtifactType() throws OseeCoreException { final int EXPECTED_RESULTS = 7; - SearchResult results = createClient.createQueryBuilder(SAW_1).andIsOfType(Folder).getSearchResult(); + SearchResult results = createClient.createQueryBuilder(SAW_1).andTypeEquals(Folder).getSearchResult(); assertEquals(EXPECTED_RESULTS, results.getTotal()); } @@ -175,8 +176,7 @@ public class OseeClientQueryTest { public void searchForArtifactTypes() throws OseeCoreException { final int EXPECTED_RESULTS = 24; SearchResult results = - createClient.createQueryBuilder(SAW_1).andIsOfType(GeneralData, GeneralDocument, - CoreArtifactTypes.SoftwareRequirement).getSearchResult(); + createClient.createQueryBuilder(SAW_1).andTypeEquals(GeneralData, GeneralDocument, SoftwareRequirement).getSearchResult(); assertEquals(EXPECTED_RESULTS, results.getTotal()); } @@ -184,7 +184,7 @@ public class OseeClientQueryTest { public void searchForArtifactTypesIncludeTypeInheritance() throws OseeCoreException { final int EXPECTED_RESULTS = 150; SearchResult results = - createClient.createQueryBuilder(SAW_1).andIsOfType(GeneralData, GeneralDocument, CoreArtifactTypes.Requirement).includeTypeInheritance().getSearchResult(); + createClient.createQueryBuilder(SAW_1).andIsOfType(GeneralData, GeneralDocument, Requirement).getSearchResult(); assertEquals(EXPECTED_RESULTS, results.getTotal()); } |