Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2014-11-07 09:41:48 -0500
committerAngel Avila2014-11-07 09:41:48 -0500
commitb834c68fa609516ebbe1838e9151431b6850b308 (patch)
tree444fb34495d6f9f28db20edead35c6c58c5cd6a1
parent115b49907244749c3f73a23aa2f783d36b7a911b (diff)
downloadorg.eclipse.osee-b834c68fa609516ebbe1838e9151431b6850b308.tar.gz
org.eclipse.osee-b834c68fa609516ebbe1838e9151431b6850b308.tar.xz
org.eclipse.osee-b834c68fa609516ebbe1838e9151431b6850b308.zip
refactor[ats_ATS119464]: Remove existance from QueryOptions
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/QueryOption.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/artifact/SearchMethod.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/InternalTestSuite.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistenceTypePredicateHandlerTest.java (renamed from plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java)18
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/dsl/DslFactory.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/predicate/ExistenceTypePredicateHandler.java (renamed from plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/predicate/ExistsTypePredicateHandler.java)42
8 files changed, 48 insertions, 46 deletions
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/QueryOption.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/QueryOption.java
index e6c4c0bde6..318b2c2278 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/QueryOption.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/QueryOption.java
@@ -17,10 +17,6 @@ public enum QueryOption {
CASE__MATCH,
CASE__IGNORE,
- // these are used for attribute and relation existence
- EXISTANCE__EXISTS,
- EXISTANCE__NOT_EXISTS,
-
TOKEN_COUNT__MATCH,
TOKEN_COUNT__IGNORE,
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java
index 5e24238559..eb6cde9263 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java
@@ -32,7 +32,6 @@ public class CheckedOptions {
caseType = QueryOption.CASE__IGNORE;
countType = QueryOption.TOKEN_COUNT__IGNORE;
delimiter = QueryOption.TOKEN_DELIMITER__ANY;
- exists = QueryOption.EXISTANCE__EXISTS;
for (QueryOption option : options) {
switch (option) {
@@ -40,10 +39,6 @@ public class CheckedOptions {
case CASE__IGNORE:
caseType = option;
break;
- case EXISTANCE__EXISTS:
- case EXISTANCE__NOT_EXISTS:
- exists = option;
- break;
case TOKEN_COUNT__MATCH:
case TOKEN_COUNT__IGNORE:
countType = option;
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 1c63c42e01..edea37d61f 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
@@ -110,14 +110,14 @@ public class PredicateFactoryImpl implements PredicateFactory {
@Override
public Predicate createRelationTypeSideNotExistsSearch(IRelationTypeSide relationTypeSide) {
String side = relationTypeSide.getSide().isSideA() ? "A" : "B";
- return new Predicate(SearchMethod.EXISTS_TYPE, Arrays.asList("relTypeSide", side), getLongIds(relationTypeSide),
- QueryOption.EXISTANCE__NOT_EXISTS);
+ return new Predicate(SearchMethod.NOT_EXISTS_TYPE, Arrays.asList("relTypeSide", side),
+ getLongIds(relationTypeSide));
}
@Override
public Predicate createRelationNotExistsSearch(Collection<? extends IRelationType> relationTypes) {
List<String> typeIds = getLongIds(relationTypes);
- return new Predicate(SearchMethod.EXISTS_TYPE, Arrays.asList("relType"), typeIds, QueryOption.EXISTANCE__NOT_EXISTS);
+ return new Predicate(SearchMethod.NOT_EXISTS_TYPE, Arrays.asList("relType"), typeIds);
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/artifact/SearchMethod.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/artifact/SearchMethod.java
index df75dc7b02..0793c608f5 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/artifact/SearchMethod.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/artifact/SearchMethod.java
@@ -23,6 +23,7 @@ public enum SearchMethod {
IS_OF_TYPE("isOfType"),
TYPE_EQUALS("typeEquals"),
EXISTS_TYPE("exists"),
+ NOT_EXISTS_TYPE("notExists"),
ATTRIBUTE_TYPE("attrType"),
RELATED_TO("related");
@@ -46,4 +47,13 @@ public enum SearchMethod {
Conditions.checkNotNull(toReturn, "SearchMethod", "Invalid type [%s]", value);
return toReturn;
}
+
+ public boolean isOfType(SearchMethod... methods) {
+ for (SearchMethod method : methods) {
+ if (this == method) {
+ return true;
+ }
+ }
+ return false;
+ }
} \ No newline at end of file
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 35475df7f3..524baca39a 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
@@ -13,7 +13,7 @@ package org.eclipse.osee.orcs.rest.internal;
import org.eclipse.osee.orcs.rest.internal.search.ArtifactSearch_V1Test;
import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchDslTest;
import org.eclipse.osee.orcs.rest.internal.search.predicate.AttributeTypePredicateHandlerTest;
-import org.eclipse.osee.orcs.rest.internal.search.predicate.ExistsTypePredicateHandlerTest;
+import org.eclipse.osee.orcs.rest.internal.search.predicate.ExistenceTypePredicateHandlerTest;
import org.eclipse.osee.orcs.rest.internal.search.predicate.GuidsPredicateHandlerTest;
import org.eclipse.osee.orcs.rest.internal.search.predicate.IdsPredicateHandlerTest;
import org.eclipse.osee.orcs.rest.internal.search.predicate.IsOfTypePredicateHandlerTest;
@@ -28,7 +28,7 @@ import org.junit.runners.Suite;
@Suite.SuiteClasses({
SearchDslTest.class,
AttributeTypePredicateHandlerTest.class,
- ExistsTypePredicateHandlerTest.class,
+ ExistenceTypePredicateHandlerTest.class,
IdsPredicateHandlerTest.class,
GuidsPredicateHandlerTest.class,
IsOfTypePredicateHandlerTest.class,
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistenceTypePredicateHandlerTest.java
index 271155c749..5b3675a2c5 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistenceTypePredicateHandlerTest.java
@@ -26,7 +26,7 @@ import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.ExistsTypePredicateHandler;
+import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.ExistenceTypePredicateHandler;
import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
import org.eclipse.osee.orcs.rest.model.search.artifact.SearchMethod;
import org.eclipse.osee.orcs.search.QueryBuilder;
@@ -41,7 +41,7 @@ import org.mockito.MockitoAnnotations;
/**
* @author John R. Misinco
*/
-public class ExistsTypePredicateHandlerTest {
+public class ExistenceTypePredicateHandlerTest {
@Mock
private QueryBuilder builder;
@@ -58,7 +58,7 @@ public class ExistsTypePredicateHandlerTest {
@Test
public void testHandleRelationTypeSideA() throws OseeCoreException {
- ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
+ ExistenceTypePredicateHandler handler = new ExistenceTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("relType");
//for relation type sides, first char must be A or B denoting side, followed by relation type uuid
String relationValue = "12345";
@@ -72,7 +72,7 @@ public class ExistsTypePredicateHandlerTest {
@Test
public void testHandleRelationTypeSideB() throws OseeCoreException {
- ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
+ ExistenceTypePredicateHandler handler = new ExistenceTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("relType");
//no flags for exists type
String relationValue = "12345";
@@ -87,7 +87,7 @@ public class ExistsTypePredicateHandlerTest {
@Test
public void testHandleRelationTypeSideMultiples() throws OseeCoreException {
- ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
+ ExistenceTypePredicateHandler handler = new ExistenceTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("relType");
//test multiples
String relationValue1 = "12345";
@@ -108,7 +108,7 @@ public class ExistsTypePredicateHandlerTest {
@Test
public void testHandleAttrTypeSingle() throws OseeCoreException {
- ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
+ ExistenceTypePredicateHandler handler = new ExistenceTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("attrType");
//for relation type sides, first char must be A or B denoting side, followed by relation type uuid
String attrUuid = "12345";
@@ -123,7 +123,7 @@ public class ExistsTypePredicateHandlerTest {
@Test
public void testHandleAttrTypeMultiple() throws OseeCoreException {
- ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
+ ExistenceTypePredicateHandler handler = new ExistenceTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("attrType");
String attrType1 = "12345";
String attrType2 = "34567";
@@ -141,7 +141,7 @@ public class ExistsTypePredicateHandlerTest {
@Test
public void testHandleBadValues() throws OseeCoreException {
- ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
+ ExistenceTypePredicateHandler handler = new ExistenceTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("attrType");
String value = "12A4G";
List<String> values = Collections.singletonList(value);
@@ -160,7 +160,7 @@ public class ExistsTypePredicateHandlerTest {
@Test(expected = OseeCoreException.class)
public void testBadValuesThrowException() throws OseeCoreException {
- ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
+ ExistenceTypePredicateHandler handler = new ExistenceTypePredicateHandler();
Predicate testPredicate =
new Predicate(SearchMethod.ATTRIBUTE_TYPE, Collections.singletonList("relType"),
Collections.singletonList("A12A4G"), QueryOption.TOKEN_DELIMITER__ANY);
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/dsl/DslFactory.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/dsl/DslFactory.java
index f6c7dc0491..f9cc207248 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/dsl/DslFactory.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/dsl/DslFactory.java
@@ -14,7 +14,7 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.osee.orcs.rest.internal.search.artifact.PredicateHandler;
import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.AttributeTypePredicateHandler;
-import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.ExistsTypePredicateHandler;
+import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.ExistenceTypePredicateHandler;
import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.GuidsPredicateHandler;
import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.IdsPredicateHandler;
import org.eclipse.osee.orcs.rest.internal.search.artifact.predicate.IsOfTypePredicateHandler;
@@ -43,7 +43,8 @@ public class DslFactory {
handlers.put(SearchMethod.GUIDS, new GuidsPredicateHandler());
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.EXISTS_TYPE, new ExistenceTypePredicateHandler());
+ handlers.put(SearchMethod.NOT_EXISTS_TYPE, new ExistenceTypePredicateHandler());
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/artifact/predicate/ExistsTypePredicateHandler.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/predicate/ExistenceTypePredicateHandler.java
index d56186e60f..2fff4b6648 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/predicate/ExistsTypePredicateHandler.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/predicate/ExistenceTypePredicateHandler.java
@@ -16,7 +16,6 @@ import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.data.TokenFactory;
-import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -30,12 +29,13 @@ import org.eclipse.osee.orcs.search.QueryBuilder;
* @author John R. Misinco
* @author Roberto E. Escobar
*/
-public class ExistsTypePredicateHandler implements PredicateHandler {
+public class ExistenceTypePredicateHandler implements PredicateHandler {
@Override
public QueryBuilder handle(QueryBuilder builder, Predicate predicate) throws OseeCoreException {
- if (predicate.getType() != SearchMethod.EXISTS_TYPE) {
- throw new OseeArgumentException("This predicate handler only supports [%s]", SearchMethod.EXISTS_TYPE);
+ if (!predicate.getType().isOfType(SearchMethod.EXISTS_TYPE, SearchMethod.NOT_EXISTS_TYPE)) {
+ throw new OseeArgumentException("This predicate handler only supports [%s] and [%s]",
+ SearchMethod.EXISTS_TYPE, SearchMethod.NOT_EXISTS_TYPE);
}
List<String> typeParameters = predicate.getTypeParameters();
Collection<String> values = predicate.getValues();
@@ -48,26 +48,31 @@ public class ExistsTypePredicateHandler implements PredicateHandler {
if ("attrType".equals(existsType)) {
Collection<IAttributeType> attributeTypes = PredicateHandlerUtil.getIAttributeTypes(values);
if (!attributeTypes.isEmpty()) {
- builder.andExists(attributeTypes);
+ if (checkExists(predicate.getType())) {
+ builder.andExists(attributeTypes);
+ } else {
+ for (IAttributeType type : attributeTypes) {
+ builder.andNotExists(type);
+ }
+ }
}
} else if ("relType".equals(existsType)) {
- QueryOption[] options = predicate.getOptions();
- for (IRelationType rt : PredicateHandlerUtil.getIRelationTypes(values)) {
- if (searchNotExists(options)) {
- builder.andNotExists(rt);
- } else {
+ Collection<IRelationType> iRelationTypes = PredicateHandlerUtil.getIRelationTypes(values);
+ for (IRelationType rt : iRelationTypes) {
+ if (checkExists(predicate.getType())) {
builder.andExists(rt);
+ } else {
+ builder.andNotExists(rt);
}
}
} else if ("relTypeSide".equals(existsType)) {
- QueryOption[] options = predicate.getOptions();
RelationSide side = typeParameters.get(1).equals("A") ? RelationSide.SIDE_A : RelationSide.SIDE_B;
for (IRelationType rt : PredicateHandlerUtil.getIRelationTypes(values)) {
IRelationTypeSide rts = TokenFactory.createRelationTypeSide(side, rt.getGuid(), "SearchRelTypeSide");
- if (searchNotExists(options)) {
- builder.andNotExists(rts);
- } else {
+ if (checkExists(predicate.getType())) {
builder.andExists(rts);
+ } else {
+ builder.andNotExists(rts);
}
}
}
@@ -76,13 +81,8 @@ public class ExistsTypePredicateHandler implements PredicateHandler {
return builder;
}
- private boolean searchNotExists(QueryOption[] options) {
- for (QueryOption option : options) {
- if (option == QueryOption.EXISTANCE__NOT_EXISTS) {
- return true;
- }
- }
- return false;
+ private boolean checkExists(SearchMethod method) {
+ return method == SearchMethod.EXISTS_TYPE;
}
}

Back to the top