Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2015-03-18 19:38:36 +0000
committerjmisinco2015-03-23 16:30:46 +0000
commit5ea082ba70716a15ae7b8ea1b375765b89a0e9bc (patch)
tree1c0fbb8141a7418495b23eab8b3dc61b290efd2c /plugins
parentaa7d9317121cce7140027448a95952e995657e89 (diff)
downloadorg.eclipse.osee-5ea082ba70716a15ae7b8ea1b375765b89a0e9bc.tar.gz
org.eclipse.osee-5ea082ba70716a15ae7b8ea1b375765b89a0e9bc.tar.xz
org.eclipse.osee-5ea082ba70716a15ae7b8ea1b375765b89a0e9bc.zip
feature: Add attribute not exists search to client
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeNotExistsSearch.java53
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java1
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AttributeNotExistsFilter.java52
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTypeNotExistsSqlHandler.java47
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerPriority.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactory.java2
-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.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java7
11 files changed, 152 insertions, 34 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeNotExistsSearch.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeNotExistsSearch.java
new file mode 100644
index 00000000000..5784f2eb6ea
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeNotExistsSearch.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.framework.skynet.core.artifact.search;
+
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.TokenFactory;
+import org.eclipse.osee.framework.jdk.core.util.Conditions;
+
+/**
+ * @author John Misinco
+ */
+public class AttributeNotExistsSearch implements ISearchPrimitive {
+ private static final String TOKEN = ";";
+ private final IAttributeType attributeType;
+
+ public AttributeNotExistsSearch(IAttributeType attributeType) {
+ Conditions.checkNotNull(attributeType, "attributeType");
+ this.attributeType = attributeType;
+ }
+
+ @Override
+ public String toString() {
+ return "Attribute Not Exists type: \"" + attributeType + "\"";
+ }
+
+ @Override
+ public String getStorageString() {
+ return "DNE" + TOKEN + attributeType.getGuid().toString();
+ }
+
+ public static AttributeNotExistsSearch getPrimitive(String storageString) {
+ String[] values = storageString.split(TOKEN);
+ if (values.length < 2) {
+ throw new IllegalStateException("Value for " + InRelationSearch.class.getSimpleName() + " not parsable");
+ }
+ IAttributeType type = TokenFactory.createAttributeType(Long.valueOf(values[1]), "SearchAttrType");
+ return new AttributeNotExistsSearch(type);
+ }
+
+ @Override
+ public void addToQuery(QueryBuilderArtifact builder) {
+ builder.andNotExists(attributeType);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java
index dd3fe9231d9..e673acf5e99 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java
@@ -330,6 +330,7 @@ public class ArtifactSearchPage extends DialogPage implements ISearchPage, IRepl
});
addToSearchTypeList(new AttributeExistsFilter(attributeControls, attributeTypeList));
+ addToSearchTypeList(new AttributeNotExistsFilter(attributeControls, attributeTypeList));
}
private void addFilterControls(Composite mainComposite) {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AttributeNotExistsFilter.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AttributeNotExistsFilter.java
new file mode 100644
index 00000000000..2edda427c86
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AttributeNotExistsFilter.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.framework.ui.skynet.search;
+
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.skynet.core.artifact.search.AttributeNotExistsSearch;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ISearchPrimitive;
+import org.eclipse.osee.framework.ui.skynet.search.filter.FilterTableViewer;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author John Misinco
+ */
+public class AttributeNotExistsFilter extends SearchFilter {
+ private final ComboViewer attributeTypeList;
+
+ public AttributeNotExistsFilter(Control optionsControl, ComboViewer attributeTypeList) {
+ super("Attribute Not Exists", optionsControl);
+ this.attributeTypeList = attributeTypeList;
+ }
+
+ @Override
+ public void addFilterTo(FilterTableViewer filterViewer) {
+ String typeName = attributeTypeList.getCombo().getText();
+
+ IAttributeType attributeType = (IAttributeType) attributeTypeList.getData(typeName);
+ ISearchPrimitive primitive = new AttributeNotExistsSearch(attributeType);
+ filterViewer.addItem(primitive, getFilterName(), typeName, Strings.EMPTY_STRING);
+ }
+
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+
+ @Override
+ public void loadFromStorageString(FilterTableViewer filterViewer, String type, String value, String storageString, boolean isNotEnabled) {
+ ISearchPrimitive primitive = AttributeNotExistsSearch.getPrimitive(storageString);
+ filterViewer.addItem(primitive, getFilterName(), type, value);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java
index a823971c847..03ffdef98ac 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java
@@ -27,6 +27,7 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaArtifactType;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeOther;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeTypeExists;
+import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeTypeNotExists;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelatedTo;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeExists;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeFollow;
@@ -71,6 +72,7 @@ public class SqlHandlerFactoryUtilTest {
criteria.add(new CriteriaArtifactType(null, null, true));
criteria.add(new CriteriaRelationTypeExists(null));
criteria.add(new CriteriaAttributeTypeExists(null));
+ criteria.add(new CriteriaAttributeTypeNotExists(null));
criteria.add(new CriteriaAttributeOther(null, null));
criteria.add(new CriteriaAttributeKeywords(false, null, null, Collections.<String> emptyList(), null, null, null));
criteria.add(new CriteriaRelatedTo(null, null));
@@ -81,7 +83,7 @@ public class SqlHandlerFactoryUtilTest {
CriteriaSet criteriaSet = createCriteria(criteria);
List<SqlHandler<?>> handlers = factory.createHandlers(criteriaSet);
- Assert.assertEquals(10, handlers.size());
+ Assert.assertEquals(11, handlers.size());
Iterator<SqlHandler<?>> iterator = handlers.iterator();
assertHandler(iterator.next(), ArtifactIdsSqlHandler.class, SqlHandlerPriority.ARTIFACT_ID);
@@ -92,6 +94,8 @@ public class SqlHandlerFactoryUtilTest {
tagProcessor);
assertHandler(iterator.next(), ArtifactTypeSqlHandler.class, SqlHandlerPriority.ARTIFACT_TYPE);
assertHandler(iterator.next(), AttributeTypeExistsSqlHandler.class, SqlHandlerPriority.ATTRIBUTE_TYPE_EXISTS);
+ assertHandler(iterator.next(), AttributeTypeNotExistsSqlHandler.class,
+ SqlHandlerPriority.ATTRIBUTE_TYPE_NOT_EXISTS);
assertHandler(iterator.next(), RelationTypeExistsSqlHandler.class, SqlHandlerPriority.RELATION_TYPE_EXISTS);
assertHandler(iterator.next(), RelatedToSqlHandler.class, SqlHandlerPriority.RELATED_TO_ART_IDS);
assertHandler(iterator.next(), AllArtifactsSqlHandler.class, SqlHandlerPriority.ALL_ARTIFACTS);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTypeNotExistsSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTypeNotExistsSqlHandler.java
index ffeca699aea..66d0c04461a 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTypeNotExistsSqlHandler.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTypeNotExistsSqlHandler.java
@@ -15,6 +15,7 @@ import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeTypeNotExists;
import org.eclipse.osee.orcs.db.internal.sql.AbstractSqlWriter;
+import org.eclipse.osee.orcs.db.internal.sql.ObjectType;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandler;
import org.eclipse.osee.orcs.db.internal.sql.TableEnum;
@@ -25,6 +26,7 @@ public class AttributeTypeNotExistsSqlHandler extends SqlHandler<CriteriaAttribu
private CriteriaAttributeTypeNotExists criteria;
+ private String artAlias;
private String txsAlias;
@Override
@@ -36,62 +38,41 @@ public class AttributeTypeNotExistsSqlHandler extends SqlHandler<CriteriaAttribu
public void addTables(AbstractSqlWriter writer) {
List<String> artAliases = writer.getAliases(TableEnum.ARTIFACT_TABLE);
if (artAliases.isEmpty()) {
- writer.addTable(TableEnum.ARTIFACT_TABLE);
+ artAlias = writer.addTable(TableEnum.ARTIFACT_TABLE);
}
- txsAlias = writer.addTable(TableEnum.TXS_TABLE);
+ txsAlias = writer.addTable(TableEnum.TXS_TABLE, ObjectType.ARTIFACT);
}
@Override
public boolean addPredicates(AbstractSqlWriter writer) throws OseeCoreException {
IAttributeType type = criteria.getType();
+ writer.writeEquals(artAlias, txsAlias, "gamma_id");
+ writer.writeAndLn();
+ writer.write(writer.getTxBranchFilter(txsAlias));
+ writer.writeAndLn();
+
writer.write("NOT EXISTS (SELECT 1 FROM ");
writer.write(TableEnum.ATTRIBUTE_TABLE.getName());
writer.write(" attr, ");
writer.write(TableEnum.TXS_TABLE.getName());
- writer.write(" txs WHERE attr.attr_type_id = ?");
+ writer.write(" txs WHERE attr.attr_type_id = ? ");
writer.addParameter(type.getGuid());
-
- List<String> aliases = writer.getAliases(TableEnum.ARTIFACT_TABLE);
writer.writeAndLn();
- int aSize = aliases.size();
- for (int index = 0; index < aSize; index++) {
- String artAlias = aliases.get(index);
-
- writer.write("attr.art_id = ");
- writer.write(artAlias);
- writer.write(".art_id");
- if (index + 1 < aSize) {
- writer.writeAndLn();
- }
- }
- writer.writeAndLn();
- writer.write("attr.gamma_id = txs.gamma_id");
+ writer.writeEquals("attr", "txs", "gamma_id");
writer.writeAndLn();
writer.write(writer.getTxBranchFilter("txs"));
- writer.write(")");
writer.writeAndLn();
-
- for (int index = 0; index < aSize; index++) {
- String artAlias = aliases.get(index);
- writer.write(artAlias);
- writer.write(".gamma_id = ");
- writer.write(txsAlias);
- writer.write(".gamma_id");
- if (index + 1 < aSize) {
- writer.writeAndLn();
- }
- }
- writer.writeAndLn();
- writer.write(writer.getTxBranchFilter(txsAlias));
+ writer.writeEquals("attr", artAlias, "art_id");
+ writer.write(")");
return true;
}
@Override
public int getPriority() {
- return SqlHandlerPriority.ATTRIBUTE_TYPE_EXISTS.ordinal();
+ return SqlHandlerPriority.ATTRIBUTE_TYPE_NOT_EXISTS.ordinal();
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerPriority.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerPriority.java
index 05a7ae974dc..b85994cfcb5 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerPriority.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerPriority.java
@@ -40,6 +40,7 @@ public enum SqlHandlerPriority {
ARTIFACT_TYPE,
ATTRIBUTE_TYPE_EXISTS,
+ ATTRIBUTE_TYPE_NOT_EXISTS,
ATTRIBUTE_DATA_XTRA,
ATTRIBUTE_TX_DATA_XTRA,
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 65201026307..58403204cba 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
@@ -109,6 +109,11 @@ public interface QueryBuilder {
QueryBuilder andExists(Collection<? extends IAttributeType> attributeTypes) throws OseeCoreException;
/**
+ * Search criteria that checks for the non-existence of an attribute type(s).
+ */
+ QueryBuilder andNotExists(IAttributeType attributeType) throws OseeCoreException;
+
+ /**
* Search criteria that follows the relation link ending on the given side
*
* @param relationType the type to start following the link from
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 e73754469b9..35731a14c07 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
@@ -40,6 +40,8 @@ public interface PredicateFactory {
Predicate createAttributeExistsSearch(Collection<? extends IAttributeType> attributeTypes);
+ Predicate createAttributeNotExistsSearch(Collection<? extends IAttributeType> attributeTypes);
+
Predicate createRelationExistsSearch(Collection<? extends IRelationType> relationTypes);
Predicate createRelationNotExistsSearch(Collection<? extends IRelationType> relationTypes);
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 edea37d61f4..d426106d831 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
@@ -96,6 +96,12 @@ public class PredicateFactoryImpl implements PredicateFactory {
}
@Override
+ public Predicate createAttributeNotExistsSearch(Collection<? extends IAttributeType> attributeTypes) {
+ List<String> typeIds = getLongIds(attributeTypes);
+ return new Predicate(SearchMethod.NOT_EXISTS_TYPE, Arrays.asList("attrType"), typeIds);
+ }
+
+ @Override
public Predicate createRelationExistsSearch(Collection<? extends IRelationType> relationTypes) {
List<String> typeIds = getLongIds(relationTypes);
return new Predicate(SearchMethod.EXISTS_TYPE, Arrays.asList("relType"), typeIds);
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 9d623af4f40..f460d697765 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
@@ -162,6 +162,12 @@ public class QueryBuilderImpl implements QueryBuilder {
}
@Override
+ public QueryBuilder andNotExists(IAttributeType attributeType) {
+ predicates.add(predicateFactory.createAttributeNotExistsSearch(Collections.singleton(attributeType)));
+ return this;
+ }
+
+ @Override
public QueryBuilder andExists(IRelationType relationType) {
predicates.add(predicateFactory.createRelationExistsSearch(Collections.singleton(relationType)));
return this;
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 b2247e24301..d88992162e7 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
@@ -100,6 +100,13 @@ public class OrcsQueryTest {
}
@Test
+ public void testAttributeNotExists() {
+ QueryBuilder builder = factory.fromBranch(CoreBranches.COMMON);
+ builder.andNotExists(CoreAttributeTypes.Afha);
+ assertEquals(26, builder.getCount());
+ }
+
+ @Test
public void testQueryByIds() throws OseeCoreException {
QueryBuilder builder = factory.fromBranch(CoreBranches.COMMON).andGuid("AkA2AmNuEDDL4VolM9AA");
assertEquals(1, builder.getCount());

Back to the top