Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-09-19 19:48:46 +0000
committerRoberto Escobar2014-10-07 17:06:23 +0000
commit073cd0c66ae6ffe0979f0478854d852da49064d8 (patch)
tree84646ad2603ee451633ea021e01bab701177c4c4
parentd5351f90510e8a839e660f4b95be111818bfb34b (diff)
downloadorg.eclipse.osee-073cd0c66ae6ffe0979f0478854d852da49064d8.tar.gz
org.eclipse.osee-073cd0c66ae6ffe0979f0478854d852da49064d8.tar.xz
org.eclipse.osee-073cd0c66ae6ffe0979f0478854d852da49064d8.zip
refactor: Separate query building from execution
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactQueryBuilderImpl.java353
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryBuilderImpl.java205
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryImpl.java180
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CriteriaFactory.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java313
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionQueryImpl.java219
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TxQueryBuilderImpl.java226
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ArtifactQueryBuilder.java211
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQuery.java43
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQueryBuilder.java61
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/Query.java26
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryBuilder.java191
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TransactionQuery.java67
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TxQueryBuilder.java73
14 files changed, 1184 insertions, 995 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactQueryBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactQueryBuilderImpl.java
new file mode 100644
index 00000000000..34a56188b93
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactQueryBuilderImpl.java
@@ -0,0 +1,353 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.core.internal.search;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+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.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.jdk.core.type.Identifiable;
+import org.eclipse.osee.framework.jdk.core.type.Identity;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.orcs.core.ds.Criteria;
+import org.eclipse.osee.orcs.core.ds.Options;
+import org.eclipse.osee.orcs.core.ds.OptionsUtil;
+import org.eclipse.osee.orcs.core.ds.QueryData;
+import org.eclipse.osee.orcs.core.ds.criteria.BranchCriteria;
+import org.eclipse.osee.orcs.core.ds.criteria.TxCriteria;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.HasLocalId;
+import org.eclipse.osee.orcs.search.ArtifactQueryBuilder;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactQueryBuilderImpl<T> implements ArtifactQueryBuilder<T> {
+
+ private final CriteriaFactory criteriaFactory;
+ private final QueryData queryData;
+
+ public ArtifactQueryBuilderImpl(CriteriaFactory criteriaFactory, QueryData queryData) {
+ this.criteriaFactory = criteriaFactory;
+ this.queryData = queryData;
+ }
+
+ private QueryData getQueryData() {
+ return queryData;
+ }
+
+ private Options getOptions() {
+ return queryData.getOptions();
+ }
+
+ @Override
+ public T includeDeletedAttributes() {
+ return includeDeletedAttributes(true);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T includeDeletedAttributes(boolean enabled) {
+ OptionsUtil.setIncludeDeletedAttributes(getOptions(), enabled);
+ return (T) this;
+ }
+
+ @Override
+ public boolean areDeletedAttributesIncluded() {
+ return OptionsUtil.areDeletedAttributesIncluded(getOptions());
+ }
+
+ @Override
+ public T includeDeletedRelations() {
+ return includeDeletedRelations(true);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T includeDeletedRelations(boolean enabled) {
+ OptionsUtil.setIncludeDeletedRelations(getOptions(), enabled);
+ return (T) this;
+ }
+
+ @Override
+ public boolean areDeletedRelationsIncluded() {
+ return OptionsUtil.areDeletedRelationsIncluded(getOptions());
+ }
+
+ @Override
+ public T includeDeletedArtifacts() {
+ return includeDeletedArtifacts(true);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T includeDeletedArtifacts(boolean enabled) {
+ OptionsUtil.setIncludeDeletedArtifacts(getOptions(), enabled);
+ return (T) this;
+ }
+
+ @Override
+ public boolean areDeletedArtifactsIncluded() {
+ return OptionsUtil.areDeletedArtifactsIncluded(getOptions());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T fromTransaction(int transactionId) {
+ OptionsUtil.setFromTransaction(getOptions(), transactionId);
+ return (T) this;
+ }
+
+ @Override
+ public int getFromTransaction() {
+ return OptionsUtil.getFromTransaction(getOptions());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T headTransaction() {
+ OptionsUtil.setHeadTransaction(getOptions());
+ return (T) this;
+ }
+
+ @Override
+ public boolean isHeadTransaction() {
+ return OptionsUtil.isHeadTransaction(getOptions());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T excludeDeleted() {
+ includeDeletedArtifacts(false);
+ return (T) this;
+ }
+
+ @Override
+ public T andLocalId(int... artifactIds) throws OseeCoreException {
+ Set<Integer> ids = new HashSet<Integer>();
+ for (Integer id : artifactIds) {
+ ids.add(id);
+ }
+ return andLocalIds(ids);
+ }
+
+ @Override
+ public T andLocalIds(Collection<Integer> artifactIds) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createArtifactIdCriteria(artifactIds);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andGuid(String id) throws OseeCoreException {
+ return andGuids(Collections.singleton(id));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T andGuids(Collection<String> ids) throws OseeCoreException {
+ Set<String> guids = new HashSet<String>();
+ Set<String> invalids = new HashSet<String>();
+ for (String id : ids) {
+ if (GUID.isValid(id)) {
+ guids.add(id);
+ } else {
+ invalids.add(id);
+ }
+ }
+
+ Conditions.checkExpressionFailOnTrue(!invalids.isEmpty(), "Invalid guids detected - %s", invalids);
+ if (!guids.isEmpty()) {
+ Criteria guidCriteria = criteriaFactory.createArtifactGuidCriteria(guids);
+ addAndCheck(getQueryData(), guidCriteria);
+ }
+ return (T) this;
+ }
+
+ @Override
+ public T andIsOfType(IArtifactType... artifactType) throws OseeCoreException {
+ return andIsOfType(Arrays.asList(artifactType));
+ }
+
+ @Override
+ public T andIsOfType(Collection<? extends IArtifactType> artifactType) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createArtifactTypeCriteriaWithInheritance(artifactType);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andTypeEquals(IArtifactType... artifactType) throws OseeCoreException {
+ return andTypeEquals(Arrays.asList(artifactType));
+ }
+
+ @Override
+ public T andTypeEquals(Collection<? extends IArtifactType> artifactType) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createArtifactTypeCriteria(artifactType);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andExists(IAttributeType... attributeType) throws OseeCoreException {
+ return andExists(Arrays.asList(attributeType));
+ }
+
+ @Override
+ public T andExists(Collection<? extends IAttributeType> attributeTypes) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createExistsCriteria(attributeTypes);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andExists(IRelationType relationType) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createExistsCriteria(relationType);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andNotExists(IRelationType relationType) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createNotExistsCriteria(relationType);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andNotExists(IRelationTypeSide relationTypeSide) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createNotExistsCriteria(relationTypeSide);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andExists(IRelationTypeSide relationTypeSide) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createExistsCriteria(relationTypeSide);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T and(IAttributeType attributeType, Collection<String> values, QueryOption... options) throws OseeCoreException {
+ return and(Collections.singleton(attributeType), values, options);
+ }
+
+ @Override
+ public T and(IAttributeType attributeType, String value, QueryOption... options) throws OseeCoreException {
+ return and(Collections.singleton(attributeType), Collections.singleton(value), options);
+ }
+
+ @Override
+ public T and(Collection<IAttributeType> attributeTypes, String value, QueryOption... options) throws OseeCoreException {
+ return and(attributeTypes, Collections.singleton(value), options);
+ }
+
+ @Override
+ public T and(Collection<IAttributeType> attributeTypes, Collection<String> value, QueryOption... options) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createAttributeCriteria(attributeTypes, value, options);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andNameEquals(String artifactName) throws OseeCoreException {
+ return and(CoreAttributeTypes.Name, artifactName);
+ }
+
+ @Override
+ public T andIds(Identifiable<String>... ids) throws OseeCoreException {
+ return andIds(Arrays.asList(ids));
+ }
+
+ @Override
+ public T andIds(Collection<? extends Identifiable<String>> ids) throws OseeCoreException {
+ Set<String> guids = new HashSet<String>();
+ for (Identity<String> id : ids) {
+ guids.add(id.getGuid());
+ }
+ return andGuids(guids);
+ }
+
+ @Override
+ public T andRelatedTo(IRelationTypeSide relationTypeSide, ArtifactReadable... artifacts) throws OseeCoreException {
+ return andRelatedTo(relationTypeSide, Arrays.asList(artifacts));
+ }
+
+ @Override
+ public T andRelatedTo(IRelationTypeSide relationTypeSide, Collection<? extends ArtifactReadable> artifacts) throws OseeCoreException {
+ Set<Integer> ids = new HashSet<Integer>();
+ for (HasLocalId<Integer> token : artifacts) {
+ ids.add(token.getLocalId());
+ }
+ return andRelatedToLocalIds(relationTypeSide, ids);
+ }
+
+ @Override
+ public T andRelatedToLocalIds(IRelationTypeSide relationTypeSide, int... artifactIds) throws OseeCoreException {
+ Set<Integer> ids = new HashSet<Integer>();
+ for (Integer id : artifactIds) {
+ ids.add(id);
+ }
+ return andRelatedToLocalIds(relationTypeSide, ids);
+ }
+
+ @Override
+ public T andRelatedToLocalIds(IRelationTypeSide relationTypeSide, Collection<Integer> artifactIds) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createRelatedToCriteria(relationTypeSide, artifactIds);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T followRelation(IRelationTypeSide relationTypeSide) {
+ Criteria criteria = criteriaFactory.createFollowRelationType(relationTypeSide);
+ addAndCheck(getQueryData(), criteria);
+ queryData.newCriteriaSet();
+ return (T) this;
+ }
+
+ @SuppressWarnings("unchecked")
+ private T addAndCheck(QueryData queryData, Criteria criteria) throws OseeCoreException {
+ criteria.checkValid(getOptions());
+ queryData.addCriteria(criteria);
+ return (T) this;
+ }
+
+ private boolean hasOnlyBranchOrTxCriterias(Collection<Criteria> criterias) {
+ boolean result = true;
+ for (Criteria criteria : criterias) {
+ if (!(criteria instanceof TxCriteria) && !(criteria instanceof BranchCriteria)) {
+ result = false;
+ break;
+ }
+ }
+ return result;
+ }
+
+ public QueryData buildAndCopy() {
+ return build(true);
+ }
+
+ public QueryData build() {
+ return build(false);
+ }
+
+ private QueryData build(boolean clone) {
+ QueryData queryData = clone ? getQueryData().clone() : getQueryData();
+ Collection<Criteria> criterias = queryData.getAllCriteria();
+ if (criterias.isEmpty() || hasOnlyBranchOrTxCriterias(criterias)) {
+ addAndCheck(queryData, criteriaFactory.createAllArtifactsCriteria());
+ }
+ return queryData;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryBuilderImpl.java
new file mode 100644
index 00000000000..da9ad4ad916
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryBuilderImpl.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.core.internal.search;
+
+import static org.eclipse.osee.framework.core.enums.BranchArchivedState.UNARCHIVED;
+import static org.eclipse.osee.framework.core.enums.BranchState.DELETED;
+import static org.eclipse.osee.framework.core.enums.BranchState.DELETE_IN_PROGRESS;
+import static org.eclipse.osee.framework.core.enums.BranchState.PURGED;
+import static org.eclipse.osee.framework.core.enums.BranchState.PURGE_IN_PROGRESS;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.BranchArchivedState;
+import org.eclipse.osee.framework.core.enums.BranchState;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.orcs.core.ds.Criteria;
+import org.eclipse.osee.orcs.core.ds.CriteriaSet;
+import org.eclipse.osee.orcs.core.ds.Options;
+import org.eclipse.osee.orcs.core.ds.OptionsUtil;
+import org.eclipse.osee.orcs.core.ds.QueryData;
+import org.eclipse.osee.orcs.search.BranchQueryBuilder;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class BranchQueryBuilderImpl<T> implements BranchQueryBuilder<T> {
+
+ private final BranchCriteriaFactory criteriaFactory;
+ private final QueryData queryData;
+ private boolean includeArchived;
+
+ public BranchQueryBuilderImpl(BranchCriteriaFactory criteriaFactory, QueryData queryData) {
+ this.criteriaFactory = criteriaFactory;
+ this.queryData = queryData;
+ includeDeleted();
+ includeArchived();
+ }
+
+ private QueryData getQueryData() {
+ return queryData;
+ }
+
+ private Options getOptions() {
+ return queryData.getOptions();
+ }
+
+ @Override
+ public T includeDeleted() {
+ return includeDeleted(true);
+ }
+
+ @Override
+ public T excludeDeleted() {
+ return includeDeleted(false);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T includeDeleted(boolean enabled) {
+ OptionsUtil.setIncludeDeletedArtifacts(getOptions(), enabled);
+ return (T) this;
+ }
+
+ @Override
+ public boolean areDeletedIncluded() {
+ return OptionsUtil.areDeletedArtifactsIncluded(getOptions());
+ }
+
+ @Override
+ public T includeArchived() {
+ return includeArchived(true);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T includeArchived(boolean enabled) {
+ includeArchived = enabled;
+ return (T) this;
+ }
+
+ @Override
+ public T excludeArchived() {
+ return includeArchived(false);
+ }
+
+ @Override
+ public boolean areArchivedIncluded() {
+ return includeArchived;
+ }
+
+ @Override
+ public T andUuids(long... uuids) throws OseeCoreException {
+ Set<Long> allUuids = new HashSet<Long>();
+ for (Long uuid : uuids) {
+ allUuids.add(uuid);
+ }
+ return andUuids(allUuids);
+ }
+
+ @Override
+ public T andUuids(Collection<Long> uuids) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createBranchUuidsCriteria(uuids);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andIds(IOseeBranch... ids) throws OseeCoreException {
+ return andIds(Arrays.asList(ids));
+ }
+
+ @Override
+ public T andIds(Collection<? extends IOseeBranch> ids) throws OseeCoreException {
+ Set<Long> allIds = new HashSet<Long>();
+ for (IOseeBranch token : ids) {
+ allIds.add(token.getUuid());
+ }
+ return andUuids(allIds);
+ }
+
+ @Override
+ public T andIsOfType(BranchType... branchType) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createBranchTypeCriteria(Arrays.asList(branchType));
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andStateIs(BranchState... branchState) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createBranchStateCriteria(Arrays.asList(branchState));
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andNameEquals(String value) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createBranchNameCriteria(value, false);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andNamePattern(String pattern) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createBranchNameCriteria(pattern, true);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andIsChildOf(IOseeBranch parent) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createBranchChildOfCriteria(parent);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @Override
+ public T andIsAncestorOf(IOseeBranch child) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.createBranchAncestorOfCriteria(child);
+ return addAndCheck(getQueryData(), criteria);
+ }
+
+ @SuppressWarnings("unchecked")
+ private T addAndCheck(QueryData queryData, Criteria criteria) throws OseeCoreException {
+ criteria.checkValid(getOptions());
+ queryData.addCriteria(criteria);
+ return (T) this;
+ }
+
+ public QueryData buildAndCopy() {
+ return build(true);
+ }
+
+ public QueryData build() {
+ return build(false);
+ }
+
+ private QueryData build(boolean clone) {
+ QueryData queryData = clone ? getQueryData().clone() : getQueryData();
+ CriteriaSet criteriaSet = queryData.getLastCriteriaSet();
+ if (criteriaSet.getCriterias().isEmpty()) {
+ addAndCheck(queryData, criteriaFactory.createAllBranchesCriteria());
+ }
+ if (!areArchivedIncluded()) {
+ Collection<BranchArchivedState> states = Arrays.asList(UNARCHIVED);
+ addAndCheck(queryData, criteriaFactory.createBranchArchivedCriteria(states));
+ }
+ if (!areDeletedIncluded()) {
+ Collection<BranchState> states = new ArrayList<BranchState>();
+ for (BranchState state : BranchState.values()) {
+ if (state != DELETE_IN_PROGRESS && state != DELETED && state != PURGE_IN_PROGRESS && state != PURGED) {
+ states.add(state);
+ }
+ }
+ addAndCheck(queryData, criteriaFactory.createBranchStateCriteria(states));
+ }
+ return queryData;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryImpl.java
index 99c686e9b99..7bcc821a108 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryImpl.java
@@ -10,29 +10,12 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.search;
-import static org.eclipse.osee.framework.core.enums.BranchArchivedState.UNARCHIVED;
-import static org.eclipse.osee.framework.core.enums.BranchState.DELETED;
-import static org.eclipse.osee.framework.core.enums.BranchState.DELETE_IN_PROGRESS;
-import static org.eclipse.osee.framework.core.enums.BranchState.PURGED;
-import static org.eclipse.osee.framework.core.enums.BranchState.PURGE_IN_PROGRESS;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
import org.eclipse.osee.executor.admin.CancellableCallable;
import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.enums.BranchArchivedState;
-import org.eclipse.osee.framework.core.enums.BranchState;
-import org.eclipse.osee.framework.core.enums.BranchType;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.Criteria;
-import org.eclipse.osee.orcs.core.ds.CriteriaSet;
-import org.eclipse.osee.orcs.core.ds.Options;
-import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.core.ds.QueryData;
import org.eclipse.osee.orcs.data.BranchReadable;
import org.eclipse.osee.orcs.search.BranchQuery;
@@ -40,140 +23,15 @@ import org.eclipse.osee.orcs.search.BranchQuery;
/**
* @author Roberto E. Escobar
*/
-public class BranchQueryImpl implements BranchQuery {
+public class BranchQueryImpl extends BranchQueryBuilderImpl<BranchQuery> implements BranchQuery {
private final BranchCallableQueryFactory queryFactory;
- private final BranchCriteriaFactory criteriaFactory;
private final OrcsSession session;
- private final QueryData queryData;
- private boolean includeArchived;
public BranchQueryImpl(BranchCallableQueryFactory queryFactory, BranchCriteriaFactory criteriaFactory, OrcsSession session, QueryData queryData) {
+ super(criteriaFactory, queryData);
this.queryFactory = queryFactory;
- this.criteriaFactory = criteriaFactory;
this.session = session;
- this.queryData = queryData;
- includeDeleted();
- includeArchived();
- }
-
- private QueryData getQueryData() {
- return queryData;
- }
-
- private Options getOptions() {
- return queryData.getOptions();
- }
-
- @Override
- public BranchQuery includeDeleted() {
- includeDeleted(true);
- return this;
- }
-
- @Override
- public BranchQuery excludeDeleted() {
- includeDeleted(false);
- return this;
- }
-
- @Override
- public BranchQuery includeDeleted(boolean enabled) {
- OptionsUtil.setIncludeDeletedArtifacts(getOptions(), enabled);
- return this;
- }
-
- @Override
- public boolean areDeletedIncluded() {
- return OptionsUtil.areDeletedArtifactsIncluded(getOptions());
- }
-
- @Override
- public BranchQuery includeArchived() {
- includeArchived(true);
- return this;
- }
-
- @Override
- public BranchQuery includeArchived(boolean enabled) {
- includeArchived = enabled;
- return this;
- }
-
- @Override
- public BranchQuery excludeArchived() {
- includeArchived(false);
- return this;
- }
-
- @Override
- public boolean areArchivedIncluded() {
- return includeArchived;
- }
-
- @Override
- public BranchQuery andUuids(long... uuids) throws OseeCoreException {
- Set<Long> allUuids = new HashSet<Long>();
- for (Long uuid : uuids) {
- allUuids.add(uuid);
- }
- return andUuids(allUuids);
- }
-
- @Override
- public BranchQuery andUuids(Collection<Long> uuids) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createBranchUuidsCriteria(uuids);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public BranchQuery andIds(IOseeBranch... ids) throws OseeCoreException {
- return andIds(Arrays.asList(ids));
- }
-
- @Override
- public BranchQuery andIds(Collection<? extends IOseeBranch> ids) throws OseeCoreException {
- Set<Long> allIds = new HashSet<Long>();
- for (IOseeBranch token : ids) {
- allIds.add(token.getUuid());
- }
- return andUuids(allIds);
- }
-
- @Override
- public BranchQuery andIsOfType(BranchType... branchType) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createBranchTypeCriteria(Arrays.asList(branchType));
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public BranchQuery andStateIs(BranchState... branchState) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createBranchStateCriteria(Arrays.asList(branchState));
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public BranchQuery andNameEquals(String value) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createBranchNameCriteria(value, false);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public BranchQuery andNamePattern(String pattern) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createBranchNameCriteria(pattern, true);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public BranchQuery andIsChildOf(IOseeBranch parent) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createBranchChildOfCriteria(parent);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public BranchQuery andIsAncestorOf(IOseeBranch child) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createBranchAncestorOfCriteria(child);
- return addAndCheck(getQueryData(), criteria);
}
@Override
@@ -211,45 +69,17 @@ public class BranchQueryImpl implements BranchQuery {
@Override
public CancellableCallable<Integer> createCount() throws OseeCoreException {
- return queryFactory.createBranchCount(session, checkAndCloneQueryData());
+ return queryFactory.createBranchCount(session, buildAndCopy());
}
@Override
public CancellableCallable<ResultSet<BranchReadable>> createSearch() throws OseeCoreException {
- return queryFactory.createBranchSearch(session, checkAndCloneQueryData());
+ return queryFactory.createBranchSearch(session, buildAndCopy());
}
@Override
public CancellableCallable<ResultSet<IOseeBranch>> createSearchResultsAsIds() throws OseeCoreException {
- return queryFactory.createBranchAsIdSearch(session, checkAndCloneQueryData());
- }
-
- private QueryData checkAndCloneQueryData() throws OseeCoreException {
- QueryData queryData = getQueryData().clone();
- CriteriaSet criteriaSet = queryData.getLastCriteriaSet();
- if (criteriaSet.getCriterias().isEmpty()) {
- addAndCheck(queryData, criteriaFactory.createAllBranchesCriteria());
- }
- if (!areArchivedIncluded()) {
- Collection<BranchArchivedState> states = Arrays.asList(UNARCHIVED);
- addAndCheck(queryData, criteriaFactory.createBranchArchivedCriteria(states));
- }
- if (!areDeletedIncluded()) {
- Collection<BranchState> states = new ArrayList<BranchState>();
- for (BranchState state : BranchState.values()) {
- if (state != DELETE_IN_PROGRESS && state != DELETED && state != PURGE_IN_PROGRESS && state != PURGED) {
- states.add(state);
- }
- }
- addAndCheck(queryData, criteriaFactory.createBranchStateCriteria(states));
- }
- return queryData;
- }
-
- private BranchQuery addAndCheck(QueryData queryData, Criteria criteria) throws OseeCoreException {
- criteria.checkValid(getOptions());
- queryData.addCriteria(criteria);
- return this;
+ return queryFactory.createBranchAsIdSearch(session, buildAndCopy());
}
}
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 7ef734a9eac..97907d115d5 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
@@ -11,7 +11,6 @@
package org.eclipse.osee.orcs.core.internal.search;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedList;
import java.util.Set;
import org.eclipse.osee.framework.core.data.IArtifactType;
@@ -35,7 +34,7 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeSideExists;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeSideNotExists;
import org.eclipse.osee.orcs.data.ArtifactTypes;
import org.eclipse.osee.orcs.data.AttributeTypes;
-import org.eclipse.osee.orcs.search.QueryBuilder;
+import org.eclipse.osee.orcs.search.ArtifactQueryBuilder;
/**
* @author Roberto E. Escobar
@@ -52,7 +51,7 @@ public class CriteriaFactory {
private Collection<? extends IAttributeType> checkForAnyType(Collection<? extends IAttributeType> attributeTypes) throws OseeCoreException {
Collection<? extends IAttributeType> toReturn;
- if (attributeTypes.contains(QueryBuilder.ANY_ATTRIBUTE_TYPE)) {
+ if (attributeTypes.contains(ArtifactQueryBuilder.ANY_ATTRIBUTE_TYPE)) {
Collection<IAttributeType> temp = new LinkedList<IAttributeType>();
temp.addAll(attributeTypeCache.getAll());
toReturn = temp;
@@ -82,13 +81,9 @@ public class CriteriaFactory {
return new CriteriaRelationTypeSideNotExists(relationTypeSide);
}
- public Criteria createAttributeCriteria(IAttributeType attributeType, Collection<String> values, QueryOption... options) throws OseeCoreException {
- return createAttributeCriteria(Collections.singleton(attributeType), values, options);
- }
-
public Criteria createAttributeCriteria(Collection<IAttributeType> attributeTypes, Collection<String> values, QueryOption... options) throws OseeCoreException {
Collection<? extends IAttributeType> types = checkForAnyType(attributeTypes);
- boolean isIncludeAllTypes = attributeTypes.contains(QueryBuilder.ANY_ATTRIBUTE_TYPE);
+ boolean isIncludeAllTypes = attributeTypes.contains(ArtifactQueryBuilder.ANY_ATTRIBUTE_TYPE);
return new CriteriaAttributeKeywords(isIncludeAllTypes, types, attributeTypeCache, values, options);
}
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 5f2788fd949..a74ab722d85 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
@@ -10,31 +10,12 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.search;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
import org.eclipse.osee.executor.admin.CancellableCallable;
-import org.eclipse.osee.framework.core.data.IArtifactType;
-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.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.jdk.core.type.Identifiable;
-import org.eclipse.osee.framework.jdk.core.type.Identity;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
-import org.eclipse.osee.framework.jdk.core.util.Conditions;
-import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.Criteria;
-import org.eclipse.osee.orcs.core.ds.Options;
-import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.core.ds.QueryData;
-import org.eclipse.osee.orcs.core.ds.criteria.CriteriaBranch;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.data.HasLocalId;
@@ -44,284 +25,15 @@ import org.eclipse.osee.orcs.search.QueryBuilder;
/**
* @author Roberto E. Escobar
*/
-public class QueryBuilderImpl implements QueryBuilder {
+public class QueryBuilderImpl extends ArtifactQueryBuilderImpl<QueryBuilder> implements QueryBuilder {
private final CallableQueryFactory queryFactory;
- private final CriteriaFactory criteriaFactory;
-
private final OrcsSession session;
- private final QueryData queryData;
public QueryBuilderImpl(CallableQueryFactory queryFactory, CriteriaFactory criteriaFactory, OrcsSession session, QueryData queryData) {
+ super(criteriaFactory, queryData);
this.queryFactory = queryFactory;
- this.criteriaFactory = criteriaFactory;
this.session = session;
- this.queryData = queryData;
- }
-
- private QueryData getQueryData() {
- return queryData;
- }
-
- private Options getOptions() {
- return queryData.getOptions();
- }
-
- @Override
- public QueryBuilder includeDeletedAttributes() {
- includeDeletedAttributes(true);
- return this;
- }
-
- @Override
- public QueryBuilder includeDeletedAttributes(boolean enabled) {
- OptionsUtil.setIncludeDeletedAttributes(getOptions(), enabled);
- return this;
- }
-
- @Override
- public boolean areDeletedAttributesIncluded() {
- return OptionsUtil.areDeletedAttributesIncluded(getOptions());
- }
-
- @Override
- public QueryBuilder includeDeletedRelations() {
- includeDeletedRelations(true);
- return this;
- }
-
- @Override
- public QueryBuilder includeDeletedRelations(boolean enabled) {
- OptionsUtil.setIncludeDeletedRelations(getOptions(), enabled);
- return this;
- }
-
- @Override
- public boolean areDeletedRelationsIncluded() {
- return OptionsUtil.areDeletedRelationsIncluded(getOptions());
- }
-
- @Override
- public QueryBuilder includeDeletedArtifacts() {
- includeDeletedArtifacts(true);
- return this;
- }
-
- @Override
- public QueryBuilder includeDeletedArtifacts(boolean enabled) {
- OptionsUtil.setIncludeDeletedArtifacts(getOptions(), enabled);
- return this;
- }
-
- @Override
- public boolean areDeletedArtifactsIncluded() {
- return OptionsUtil.areDeletedArtifactsIncluded(getOptions());
- }
-
- @Override
- public QueryBuilder fromTransaction(int transactionId) {
- OptionsUtil.setFromTransaction(getOptions(), transactionId);
- return this;
- }
-
- @Override
- public int getFromTransaction() {
- return OptionsUtil.getFromTransaction(getOptions());
- }
-
- @Override
- public QueryBuilder headTransaction() {
- OptionsUtil.setHeadTransaction(getOptions());
- return this;
- }
-
- @Override
- public boolean isHeadTransaction() {
- return OptionsUtil.isHeadTransaction(getOptions());
- }
-
- @Override
- public QueryBuilder excludeDeleted() {
- includeDeletedArtifacts(false);
- return this;
- }
-
- @Override
- public QueryBuilder andLocalId(int... artifactIds) throws OseeCoreException {
- Set<Integer> ids = new HashSet<Integer>();
- for (Integer id : artifactIds) {
- ids.add(id);
- }
- return andLocalIds(ids);
- }
-
- @Override
- public QueryBuilder andLocalIds(Collection<Integer> artifactIds) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createArtifactIdCriteria(artifactIds);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public QueryBuilder andGuid(String id) throws OseeCoreException {
- return andGuids(Collections.singleton(id));
- }
-
- @Override
- public QueryBuilder andGuids(Collection<String> ids) throws OseeCoreException {
- Set<String> guids = new HashSet<String>();
- Set<String> invalids = new HashSet<String>();
- for (String id : ids) {
- if (GUID.isValid(id)) {
- guids.add(id);
- } else {
- invalids.add(id);
- }
- }
-
- Conditions.checkExpressionFailOnTrue(!invalids.isEmpty(), "Invalid guids detected - %s", invalids);
- if (!guids.isEmpty()) {
- Criteria guidCriteria = criteriaFactory.createArtifactGuidCriteria(guids);
- addAndCheck(getQueryData(), guidCriteria);
- }
-
- return this;
- }
-
- @Override
- public QueryBuilder andIsOfType(IArtifactType... artifactType) throws OseeCoreException {
- return andIsOfType(Arrays.asList(artifactType));
- }
-
- @Override
- public QueryBuilder andIsOfType(Collection<? extends IArtifactType> artifactType) throws OseeCoreException {
- Criteria 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 criteria = criteriaFactory.createArtifactTypeCriteria(artifactType);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public QueryBuilder andExists(IAttributeType... attributeType) throws OseeCoreException {
- return andExists(Arrays.asList(attributeType));
- }
-
- @Override
- public QueryBuilder andExists(Collection<? extends IAttributeType> attributeTypes) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createExistsCriteria(attributeTypes);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public QueryBuilder andExists(IRelationType relationType) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createExistsCriteria(relationType);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public QueryBuilder andNotExists(IRelationType relationType) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createNotExistsCriteria(relationType);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public QueryBuilder andNotExists(IRelationTypeSide relationTypeSide) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createNotExistsCriteria(relationTypeSide);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public QueryBuilder andExists(IRelationTypeSide relationTypeSide) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createExistsCriteria(relationTypeSide);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public QueryBuilder and(IAttributeType attributeType, Collection<String> values, QueryOption... options) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createAttributeCriteria(attributeType, values, options);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public QueryBuilder and(IAttributeType attributeType, String value, QueryOption... options) throws OseeCoreException {
- return and(Collections.singleton(attributeType), value, options);
- }
-
- @Override
- public QueryBuilder and(Collection<IAttributeType> attributeTypes, String value, QueryOption... options) throws OseeCoreException {
- Criteria criteria =
- criteriaFactory.createAttributeCriteria(attributeTypes, Collections.singleton(value), options);
- return addAndCheck(getQueryData(), criteria);
- }
-
- private QueryBuilder addAndCheck(QueryData queryData, Criteria criteria) throws OseeCoreException {
- criteria.checkValid(getOptions());
- queryData.addCriteria(criteria);
- return this;
- }
-
- @Override
- public QueryBuilder andNameEquals(String artifactName) throws OseeCoreException {
- return and(CoreAttributeTypes.Name, artifactName);
- }
-
- @Override
- public QueryBuilder andIds(Identifiable<String>... ids) throws OseeCoreException {
- return andIds(Arrays.asList(ids));
- }
-
- @Override
- public QueryBuilder andIds(Collection<? extends Identifiable<String>> ids) throws OseeCoreException {
- Set<String> guids = new HashSet<String>();
- for (Identity<String> id : ids) {
- guids.add(id.getGuid());
- }
- return andGuids(guids);
- }
-
- @Override
- public QueryBuilder andRelatedTo(IRelationTypeSide relationTypeSide, ArtifactReadable... artifacts) throws OseeCoreException {
- return andRelatedTo(relationTypeSide, Arrays.asList(artifacts));
- }
-
- @Override
- public QueryBuilder andRelatedTo(IRelationTypeSide relationTypeSide, Collection<? extends ArtifactReadable> artifacts) throws OseeCoreException {
- Set<Integer> ids = new HashSet<Integer>();
- for (HasLocalId<Integer> token : artifacts) {
- ids.add(token.getLocalId());
- }
- return andRelatedToLocalIds(relationTypeSide, ids);
- }
-
- @Override
- public QueryBuilder andRelatedToLocalIds(IRelationTypeSide relationTypeSide, int... artifactIds) throws OseeCoreException {
- Set<Integer> ids = new HashSet<Integer>();
- for (Integer id : artifactIds) {
- ids.add(id);
- }
- return andRelatedToLocalIds(relationTypeSide, ids);
- }
-
- @Override
- public QueryBuilder andRelatedToLocalIds(IRelationTypeSide relationTypeSide, Collection<Integer> artifactIds) throws OseeCoreException {
- Criteria criteria = criteriaFactory.createRelatedToCriteria(relationTypeSide, artifactIds);
- return addAndCheck(getQueryData(), criteria);
- }
-
- @Override
- public QueryBuilder followRelation(IRelationTypeSide relationTypeSide) {
- Criteria criteria = criteriaFactory.createFollowRelationType(relationTypeSide);
- addAndCheck(getQueryData(), criteria);
- queryData.newCriteriaSet();
- return this;
}
@Override
@@ -370,35 +82,22 @@ public class QueryBuilderImpl implements QueryBuilder {
@Override
public CancellableCallable<ResultSet<ArtifactReadable>> createSearch() throws OseeCoreException {
- return queryFactory.createSearch(session, checkAndCloneQueryData());
+ return queryFactory.createSearch(session, buildAndCopy());
}
@Override
public CancellableCallable<ResultSet<Match<ArtifactReadable, AttributeReadable<?>>>> createSearchWithMatches() throws OseeCoreException {
- return queryFactory.createSearchWithMatches(session, checkAndCloneQueryData());
+ return queryFactory.createSearchWithMatches(session, buildAndCopy());
}
@Override
public CancellableCallable<ResultSet<HasLocalId<Integer>>> createSearchResultsAsLocalIds() throws OseeCoreException {
- return queryFactory.createLocalIdSearch(session, checkAndCloneQueryData());
- }
-
- private QueryData checkAndCloneQueryData() throws OseeCoreException {
- QueryData queryData = getQueryData().clone();
- Collection<Criteria> criterias = queryData.getAllCriteria();
- if (criterias.isEmpty() || hasOneBranchCriteria(criterias)) {
- addAndCheck(queryData, criteriaFactory.createAllArtifactsCriteria());
- }
- return queryData;
- }
-
- private boolean hasOneBranchCriteria(Collection<Criteria> criterias) {
- return criterias.size() == 1 && criterias.iterator().next() instanceof CriteriaBranch;
+ return queryFactory.createLocalIdSearch(session, buildAndCopy());
}
@Override
public CancellableCallable<Integer> createCount() throws OseeCoreException {
- return queryFactory.createCount(session, checkAndCloneQueryData());
+ return queryFactory.createCount(session, buildAndCopy());
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionQueryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionQueryImpl.java
index feeddc973a9..54b55f08303 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionQueryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionQueryImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Boeing.
+ * 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
@@ -10,139 +10,27 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.search;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.Set;
import org.eclipse.osee.executor.admin.CancellableCallable;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.Criteria;
-import org.eclipse.osee.orcs.core.ds.CriteriaSet;
-import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.QueryData;
-import org.eclipse.osee.orcs.data.ArtifactId;
import org.eclipse.osee.orcs.data.TransactionReadable;
-import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.TransactionQuery;
/**
* @author Roberto E. Escobar
*/
-public class TransactionQueryImpl implements TransactionQuery {
+public class TransactionQueryImpl extends TxQueryBuilderImpl<TransactionQuery> implements TransactionQuery {
private final TransactionCallableQueryFactory queryFactory;
- private final TransactionCriteriaFactory criteriaFactory;
private final OrcsSession session;
- private final QueryData queryData;
public TransactionQueryImpl(TransactionCallableQueryFactory queryFactory, TransactionCriteriaFactory criteriaFactory, OrcsSession session, QueryData queryData) {
+ super(criteriaFactory, queryData);
this.queryFactory = queryFactory;
- this.criteriaFactory = criteriaFactory;
this.session = session;
- this.queryData = queryData;
- }
-
- private QueryData getQueryData() {
- return queryData;
- }
-
- private Options getOptions() {
- return queryData.getOptions();
- }
-
- @Override
- public TransactionQuery andTxId(int... ids) throws OseeCoreException {
- Set<Integer> values = new LinkedHashSet<Integer>();
- for (int value : ids) {
- values.add(value);
- }
- return andTxIds(values);
- }
-
- @Override
- public TransactionQuery andTxIds(Collection<Integer> ids) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newByIdsCriteria(ids);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andTxId(Operator op, int id) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newByIdWithOperator(op, id);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andTxId(Operator op1, int id1, Operator op2, int id2) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newByIdWithTwoOperators(op1, id1, op2, id2);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andCommentEquals(String value) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newCommentCriteria(value, false);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andCommentPattern(String pattern) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newCommentCriteria(pattern, true);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andIs(TransactionDetailsType... types) throws OseeCoreException {
- return andIs(Arrays.asList(types));
- }
-
- @Override
- public TransactionQuery andIs(Collection<TransactionDetailsType> types) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newTxTypeCriteria(types);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andBranch(IOseeBranch... ids) throws OseeCoreException {
- return andBranch(Arrays.asList(ids));
- }
-
- @Override
- public TransactionQuery andBranch(Collection<? extends IOseeBranch> ids) throws OseeCoreException {
- Set<Long> values = new LinkedHashSet<Long>();
- for (IOseeBranch value : ids) {
- values.add(value.getUuid());
- }
- Criteria criteria = criteriaFactory.newTxBranchIdCriteria(values);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andBranchIds(long... ids) throws OseeCoreException {
- Set<Long> values = new LinkedHashSet<Long>();
- for (long value : ids) {
- values.add(value);
- }
- return andBranchIds(values);
- }
-
- @Override
- public TransactionQuery andBranchIds(Collection<Long> ids) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newTxBranchIdCriteria(ids);
- addAndCheck(queryData, criteria);
- return this;
}
@Override
@@ -180,112 +68,17 @@ public class TransactionQueryImpl implements TransactionQuery {
@Override
public CancellableCallable<Integer> createCount() throws OseeCoreException {
- return queryFactory.createTransactionCount(session, checkAndCloneQueryData());
+ return queryFactory.createTransactionCount(session, buildAndCopy());
}
@Override
public CancellableCallable<ResultSet<TransactionReadable>> createSearch() throws OseeCoreException {
- return queryFactory.createTransactionSearch(session, checkAndCloneQueryData());
+ return queryFactory.createTransactionSearch(session, buildAndCopy());
}
@Override
public CancellableCallable<ResultSet<Integer>> createSearchResultsAsIds() throws OseeCoreException {
- return queryFactory.createTransactionAsIdSearch(session, checkAndCloneQueryData());
- }
-
- @Override
- public TransactionQuery andDate(Operator op, Timestamp date) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newByDateWithOperator(op, date);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andDate(Timestamp from, Timestamp to) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newByDateRange(from, to);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andAuthorLocalIds(ArtifactId... id) throws OseeCoreException {
- return andAuthorLocalIds(Arrays.asList(id));
- }
-
- @Override
- public TransactionQuery andAuthorLocalIds(Collection<ArtifactId> ids) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newByArtifactId(ids);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andAuthorIds(int... id) throws OseeCoreException {
- ArrayList<Integer> theList = new ArrayList<Integer>();
- for (int i = 0; i < id.length; i++) {
- theList.add(new Integer(id[i]));
- }
- return andAuthorIds(theList);
- }
-
- @Override
- public TransactionQuery andAuthorIds(Collection<Integer> ids) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newByAuthorId(ids);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andCommitIds(Integer... id) throws OseeCoreException {
- return andCommitIds(Arrays.asList(id));
- }
-
- @Override
- public TransactionQuery andNullCommitId() throws OseeCoreException {
- Collection<Integer> aNull = new ArrayList<Integer>();
- aNull.add(null);
- return andCommitIds(aNull);
- }
-
- @Override
- public TransactionQuery andCommitIds(Collection<Integer> ids) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newByCommitId(ids);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andIsHead(IOseeBranch branch) throws OseeCoreException {
- return andIsHead(branch.getUuid());
- }
-
- @Override
- public TransactionQuery andIsHead(long branchUuid) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newGetHead(branchUuid);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- @Override
- public TransactionQuery andIsPriorTx(int txId) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newGetPriorTx(txId);
- addAndCheck(queryData, criteria);
- return this;
- }
-
- private QueryData checkAndCloneQueryData() throws OseeCoreException {
- QueryData queryData = getQueryData().clone();
- CriteriaSet criteriaSet = queryData.getLastCriteriaSet();
- if (criteriaSet.getCriterias().isEmpty()) {
- addAndCheck(queryData, criteriaFactory.createAllTransactionsCriteria());
- }
- return queryData;
- }
-
- private TransactionQuery addAndCheck(QueryData queryData, Criteria criteria) throws OseeCoreException {
- criteria.checkValid(getOptions());
- queryData.addCriteria(criteria);
- return this;
+ return queryFactory.createTransactionAsIdSearch(session, buildAndCopy());
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TxQueryBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TxQueryBuilderImpl.java
new file mode 100644
index 00000000000..477dbdaebb4
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TxQueryBuilderImpl.java
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.core.internal.search;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.orcs.core.ds.Criteria;
+import org.eclipse.osee.orcs.core.ds.Options;
+import org.eclipse.osee.orcs.core.ds.QueryData;
+import org.eclipse.osee.orcs.data.ArtifactId;
+import org.eclipse.osee.orcs.search.Operator;
+import org.eclipse.osee.orcs.search.TxQueryBuilder;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TxQueryBuilderImpl<T> implements TxQueryBuilder<T> {
+
+ private final TransactionCriteriaFactory criteriaFactory;
+ private final QueryData queryData;
+
+ public TxQueryBuilderImpl(TransactionCriteriaFactory criteriaFactory, QueryData queryData) {
+ this.criteriaFactory = criteriaFactory;
+ this.queryData = queryData;
+ }
+
+ private QueryData getQueryData() {
+ return queryData;
+ }
+
+ private Options getOptions() {
+ return queryData.getOptions();
+ }
+
+ @Override
+ public T andTxId(int... ids) throws OseeCoreException {
+ Set<Integer> values = new LinkedHashSet<Integer>();
+ for (int value : ids) {
+ values.add(value);
+ }
+ return andTxIds(values);
+ }
+
+ @Override
+ public T andTxIds(Collection<Integer> ids) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newByIdsCriteria(ids);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andTxId(Operator op, int id) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newByIdWithOperator(op, id);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andTxId(Operator op1, int id1, Operator op2, int id2) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newByIdWithTwoOperators(op1, id1, op2, id2);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andCommentEquals(String value) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newCommentCriteria(value, false);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andCommentPattern(String pattern) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newCommentCriteria(pattern, true);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andIs(TransactionDetailsType... types) throws OseeCoreException {
+ return andIs(Arrays.asList(types));
+ }
+
+ @Override
+ public T andIs(Collection<TransactionDetailsType> types) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newTxTypeCriteria(types);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andBranch(IOseeBranch... ids) throws OseeCoreException {
+ return andBranch(Arrays.asList(ids));
+ }
+
+ @Override
+ public T andBranch(Collection<? extends IOseeBranch> ids) throws OseeCoreException {
+ Set<Long> values = new LinkedHashSet<Long>();
+ for (IOseeBranch value : ids) {
+ values.add(value.getUuid());
+ }
+ Criteria criteria = criteriaFactory.newTxBranchIdCriteria(values);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andBranchIds(long... ids) throws OseeCoreException {
+ Set<Long> values = new LinkedHashSet<Long>();
+ for (long value : ids) {
+ values.add(value);
+ }
+ return andBranchIds(values);
+ }
+
+ @Override
+ public T andBranchIds(Collection<Long> ids) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newTxBranchIdCriteria(ids);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andDate(Operator op, Timestamp date) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newByDateWithOperator(op, date);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andDate(Timestamp from, Timestamp to) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newByDateRange(from, to);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andAuthorLocalIds(ArtifactId... id) throws OseeCoreException {
+ return andAuthorLocalIds(Arrays.asList(id));
+ }
+
+ @Override
+ public T andAuthorLocalIds(Collection<ArtifactId> ids) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newByArtifactId(ids);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andAuthorIds(int... id) throws OseeCoreException {
+ ArrayList<Integer> theList = new ArrayList<Integer>();
+ for (int i = 0; i < id.length; i++) {
+ theList.add(new Integer(id[i]));
+ }
+ return andAuthorIds(theList);
+ }
+
+ @Override
+ public T andAuthorIds(Collection<Integer> ids) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newByAuthorId(ids);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andCommitIds(Integer... id) throws OseeCoreException {
+ return andCommitIds(Arrays.asList(id));
+ }
+
+ @Override
+ public T andNullCommitId() throws OseeCoreException {
+ Collection<Integer> aNull = new ArrayList<Integer>();
+ aNull.add(null);
+ return andCommitIds(aNull);
+ }
+
+ @Override
+ public T andCommitIds(Collection<Integer> ids) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newByCommitId(ids);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andIsHead(IOseeBranch branch) throws OseeCoreException {
+ return andIsHead(branch.getUuid());
+ }
+
+ @Override
+ public T andIsHead(long branchUuid) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newGetHead(branchUuid);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @Override
+ public T andIsPriorTx(int txId) throws OseeCoreException {
+ Criteria criteria = criteriaFactory.newGetPriorTx(txId);
+ return addAndCheck(queryData, criteria);
+ }
+
+ @SuppressWarnings("unchecked")
+ private T addAndCheck(QueryData queryData, Criteria criteria) throws OseeCoreException {
+ criteria.checkValid(getOptions());
+ queryData.addCriteria(criteria);
+ return (T) this;
+ }
+
+ public QueryData buildAndCopy() {
+ return build(true);
+ }
+
+ public QueryData build() {
+ return build(false);
+ }
+
+ private QueryData build(boolean clone) {
+ QueryData queryData = clone ? getQueryData().clone() : getQueryData();
+ if (queryData.getAllCriteria().isEmpty()) {
+ addAndCheck(queryData, criteriaFactory.createAllTransactionsCriteria());
+ }
+ return queryData;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ArtifactQueryBuilder.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ArtifactQueryBuilder.java
new file mode 100644
index 00000000000..c1f71044fca
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ArtifactQueryBuilder.java
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.search;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+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.jdk.core.type.Identifiable;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+
+/**
+ * @author Ryan D. Brooks
+ * @author Roberto E. Escobar
+ */
+public interface ArtifactQueryBuilder<T> {
+
+ public static IAttributeType ANY_ATTRIBUTE_TYPE = TokenFactory.createAttributeType(Long.MIN_VALUE,
+ "Any Attribute Type");
+
+ T includeDeletedArtifacts();
+
+ T includeDeletedArtifacts(boolean enabled);
+
+ boolean areDeletedArtifactsIncluded();
+
+ T includeDeletedAttributes();
+
+ T includeDeletedAttributes(boolean enabled);
+
+ boolean areDeletedAttributesIncluded();
+
+ T includeDeletedRelations();
+
+ T includeDeletedRelations(boolean enabled);
+
+ boolean areDeletedRelationsIncluded();
+
+ T fromTransaction(int transactionId);
+
+ int getFromTransaction();
+
+ T headTransaction();
+
+ boolean isHeadTransaction();
+
+ T excludeDeleted();
+
+ /**
+ * Search criteria that finds a given artifact id
+ */
+ T andLocalId(int... artifactId) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact ids
+ */
+ T andLocalIds(Collection<Integer> artifactIds) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact with guid
+ */
+ T andGuid(String guid) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact with guids
+ */
+ T andGuids(Collection<String> ids) throws OseeCoreException;
+
+ /**
+ * Artifacts id(s)
+ */
+ T andIds(Identifiable<String>... ids) throws OseeCoreException;
+
+ /**
+ * Artifacts matching token id(s)
+ */
+ T andIds(Collection<? extends Identifiable<String>> ids) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact type using type inheritance
+ */
+ T andIsOfType(IArtifactType... artifactType) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact types using type inheritance
+ */
+ T andIsOfType(Collection<? extends IArtifactType> artifactType) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact types by matching type exactly
+ */
+ T andTypeEquals(IArtifactType... artifactType) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact types by matching type exactly
+ */
+ T andTypeEquals(Collection<? extends IArtifactType> artifactType) throws OseeCoreException;
+
+ /**
+ * Search criteria that checks for the existence of an attribute type(s).
+ */
+ T andExists(IAttributeType... attributeType) throws OseeCoreException;
+
+ /**
+ * Search criteria that checks for the existence of an attribute types.
+ */
+ T andExists(Collection<? extends IAttributeType> attributeTypes) throws OseeCoreException;
+
+ /**
+ * Search criteria that follows the relation link ending on the given side
+ *
+ * @param relationType the type to start following the link from
+ */
+ T andExists(IRelationType relationType) throws OseeCoreException;
+
+ /**
+ * Search criteria that checks for non-existence of a relation type
+ *
+ * @param relationTypeSide the type to check for non-existence
+ */
+ T andNotExists(IRelationTypeSide relationTypeSide) throws OseeCoreException;
+
+ /**
+ * Search criteria that follows the relation link ending on the given side
+ *
+ * @param relationTypeSide the type to start following the link from
+ */
+ T andExists(IRelationTypeSide relationTypeSide) throws OseeCoreException;
+
+ /**
+ * Search criteria that checks for non-existence of a relation type
+ *
+ * @param relationType the type to check for non-existence
+ */
+ T andNotExists(IRelationType relationType) throws OseeCoreException;
+
+ /**
+ * Artifact name equals value
+ */
+ T andNameEquals(String artifactName) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds an attribute of the given type with its current value exactly equal (or not equal) to
+ * any one of the given literal values. If the list only contains one value, then the search is conducted exactly as
+ * if the single value constructor was called. This search does not support the (* wildcard) for multiple values.
+ */
+ T and(IAttributeType attributeType, Collection<String> values, QueryOption... options) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds an attribute of the given type with its current value relative to the given value based
+ * on the operator provided.
+ */
+ T and(IAttributeType attributeType, String value, QueryOption... options) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds an attribute of the given type with its current value exactly equal (or not equal) to
+ * any one of the given literal values. If the list only contains one value, then the search is conducted exactly as
+ * if the single value constructor was called. This search does not support the (* wildcard) for multiple values.
+ */
+ T and(Collection<IAttributeType> attributeTypes, String value, QueryOption... options) throws OseeCoreException;
+
+ T and(Collection<IAttributeType> attributeTypes, Collection<String> value, QueryOption... options) throws OseeCoreException;
+
+ /**
+ * Search for related artifacts
+ *
+ * @param relationTypeSide the type-side to search on
+ */
+ T andRelatedTo(IRelationTypeSide relationTypeSide, ArtifactReadable... artifacts) throws OseeCoreException;
+
+ /**
+ * Search for related artifacts
+ *
+ * @param relationTypeSide the type-side to search on
+ */
+ T andRelatedTo(IRelationTypeSide relationTypeSide, Collection<? extends ArtifactReadable> artifacts) throws OseeCoreException;
+
+ /**
+ * Search for related artifacts
+ *
+ * @param relationTypeSide the type-side to search on
+ */
+ T andRelatedToLocalIds(IRelationTypeSide relationTypeSide, int... artifactIds) throws OseeCoreException;
+
+ /**
+ * Search for related artifacts
+ *
+ * @param relationTypeSide the type-side to search on
+ */
+ T andRelatedToLocalIds(IRelationTypeSide relationTypeSide, Collection<Integer> artifactIds) throws OseeCoreException;
+
+ /**
+ * Search related artifacts with specific criteria. Will only follow first level of relations
+ *
+ * @param relationTypeSide the type-side to search on
+ */
+ T followRelation(IRelationTypeSide relationTypeSide);
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQuery.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQuery.java
index 1aaa8c7641f..bec2ff4f81e 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQuery.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQuery.java
@@ -10,11 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.orcs.search;
-import java.util.Collection;
import org.eclipse.osee.executor.admin.CancellableCallable;
import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.enums.BranchState;
-import org.eclipse.osee.framework.core.enums.BranchType;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.orcs.data.BranchReadable;
@@ -23,50 +20,16 @@ import org.eclipse.osee.orcs.data.BranchReadable;
* @author Ryan D. Brooks
* @author Roberto E. Escobar
*/
-public interface BranchQuery {
-
- BranchQuery includeDeleted();
-
- BranchQuery excludeDeleted();
-
- BranchQuery includeDeleted(boolean enabled);
-
- boolean areDeletedIncluded();
-
- BranchQuery includeArchived();
-
- BranchQuery includeArchived(boolean enabled);
-
- BranchQuery excludeArchived();
-
- boolean areArchivedIncluded();
-
- BranchQuery andUuids(long... uuids) throws OseeCoreException;
-
- BranchQuery andUuids(Collection<Long> uuids) throws OseeCoreException;
-
- BranchQuery andIds(Collection<? extends IOseeBranch> ids) throws OseeCoreException;
-
- BranchQuery andIds(IOseeBranch... ids) throws OseeCoreException;
-
- BranchQuery andIsOfType(BranchType... branchType) throws OseeCoreException;
-
- BranchQuery andStateIs(BranchState... branchState) throws OseeCoreException;
-
- BranchQuery andNameEquals(String value) throws OseeCoreException;
-
- BranchQuery andNamePattern(String pattern) throws OseeCoreException;
-
- BranchQuery andIsChildOf(IOseeBranch branch) throws OseeCoreException;
-
- BranchQuery andIsAncestorOf(IOseeBranch branch) throws OseeCoreException;
+public interface BranchQuery extends BranchQueryBuilder<BranchQuery>, Query {
ResultSet<BranchReadable> getResults() throws OseeCoreException;
ResultSet<IOseeBranch> getResultsAsId() throws OseeCoreException;
+ @Override
int getCount() throws OseeCoreException;
+ @Override
CancellableCallable<Integer> createCount() throws OseeCoreException;
CancellableCallable<ResultSet<BranchReadable>> createSearch() throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQueryBuilder.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQueryBuilder.java
new file mode 100644
index 00000000000..5e4d44cfefc
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQueryBuilder.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.orcs.search;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.BranchState;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+
+/**
+ * @author Ryan D. Brooks
+ * @author Roberto E. Escobar
+ */
+public interface BranchQueryBuilder<T> {
+
+ T includeDeleted();
+
+ T excludeDeleted();
+
+ T includeDeleted(boolean enabled);
+
+ boolean areDeletedIncluded();
+
+ T includeArchived();
+
+ T includeArchived(boolean enabled);
+
+ T excludeArchived();
+
+ boolean areArchivedIncluded();
+
+ T andUuids(long... uuids) throws OseeCoreException;
+
+ T andUuids(Collection<Long> uuids) throws OseeCoreException;
+
+ T andIds(Collection<? extends IOseeBranch> ids) throws OseeCoreException;
+
+ T andIds(IOseeBranch... ids) throws OseeCoreException;
+
+ T andIsOfType(BranchType... branchType) throws OseeCoreException;
+
+ T andStateIs(BranchState... branchState) throws OseeCoreException;
+
+ T andNameEquals(String value) throws OseeCoreException;
+
+ T andNamePattern(String pattern) throws OseeCoreException;
+
+ T andIsChildOf(IOseeBranch branch) throws OseeCoreException;
+
+ T andIsAncestorOf(IOseeBranch branch) throws OseeCoreException;
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/Query.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/Query.java
new file mode 100644
index 00000000000..d9d1b5969e9
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/Query.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.orcs.search;
+
+import org.eclipse.osee.executor.admin.CancellableCallable;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+
+/**
+ * @author Ryan D. Brooks
+ * @author Roberto E. Escobar
+ */
+public interface Query {
+
+ int getCount() throws OseeCoreException;
+
+ CancellableCallable<Integer> createCount() throws OseeCoreException;
+
+}
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 41d0e295d2a..4dd39218c3d 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
@@ -10,15 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.search;
-import java.util.Collection;
import org.eclipse.osee.executor.admin.CancellableCallable;
-import org.eclipse.osee.framework.core.data.IArtifactType;
-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.jdk.core.type.Identifiable;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.orcs.data.ArtifactReadable;
@@ -29,186 +21,7 @@ import org.eclipse.osee.orcs.data.HasLocalId;
* @author Ryan D. Brooks
* @author Roberto E. Escobar
*/
-public interface QueryBuilder {
-
- public static IAttributeType ANY_ATTRIBUTE_TYPE = TokenFactory.createAttributeType(Long.MIN_VALUE,
- "Any Attribute Type");
-
- QueryBuilder includeDeletedArtifacts();
-
- QueryBuilder includeDeletedArtifacts(boolean enabled);
-
- boolean areDeletedArtifactsIncluded();
-
- QueryBuilder includeDeletedAttributes();
-
- QueryBuilder includeDeletedAttributes(boolean enabled);
-
- boolean areDeletedAttributesIncluded();
-
- QueryBuilder includeDeletedRelations();
-
- QueryBuilder includeDeletedRelations(boolean enabled);
-
- boolean areDeletedRelationsIncluded();
-
- QueryBuilder fromTransaction(int transactionId);
-
- int getFromTransaction();
-
- QueryBuilder headTransaction();
-
- boolean isHeadTransaction();
-
- QueryBuilder excludeDeleted();
-
- /**
- * Search criteria that finds a given artifact id
- */
- QueryBuilder andLocalId(int... artifactId) throws OseeCoreException;
-
- /**
- * Search criteria that finds a given artifact ids
- */
- QueryBuilder andLocalIds(Collection<Integer> artifactIds) throws OseeCoreException;
-
- /**
- * Search criteria that finds a given artifact with guid
- */
- QueryBuilder andGuid(String guid) throws OseeCoreException;
-
- /**
- * Search criteria that finds a given artifact with guids
- */
- QueryBuilder andGuids(Collection<String> ids) throws OseeCoreException;
-
- /**
- * Artifacts id(s)
- */
- QueryBuilder andIds(Identifiable<String>... ids) throws OseeCoreException;
-
- /**
- * Artifacts matching token id(s)
- */
- QueryBuilder andIds(Collection<? extends Identifiable<String>> ids) throws OseeCoreException;
-
- /**
- * 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 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;
-
- /**
- * Search criteria that checks for the existence of an attribute types.
- */
- QueryBuilder andExists(Collection<? extends IAttributeType> attributeTypes) throws OseeCoreException;
-
- /**
- * Search criteria that follows the relation link ending on the given side
- *
- * @param relationType the type to start following the link from
- */
- QueryBuilder andExists(IRelationType relationType) throws OseeCoreException;
-
- /**
- * Search criteria that checks for non-existence of a relation type
- *
- * @param relationTypeSide the type to check for non-existence
- */
- QueryBuilder andNotExists(IRelationTypeSide relationTypeSide) throws OseeCoreException;
-
- /**
- * Search criteria that follows the relation link ending on the given side
- *
- * @param relationTypeSide the type to start following the link from
- */
- QueryBuilder andExists(IRelationTypeSide relationTypeSide) throws OseeCoreException;
-
- /**
- * Search criteria that checks for non-existence of a relation type
- *
- * @param relationType the type to check for non-existence
- */
- QueryBuilder andNotExists(IRelationType relationType) throws OseeCoreException;
-
- /**
- * Artifact name equals value
- */
- QueryBuilder andNameEquals(String artifactName) throws OseeCoreException;
-
- /**
- * Search criteria that finds an attribute of the given type with its current value exactly equal (or not equal) to
- * any one of the given literal values. If the list only contains one value, then the search is conducted exactly as
- * if the single value constructor was called. This search does not support the (* wildcard) for multiple values.
- */
- QueryBuilder and(IAttributeType attributeType, Collection<String> values, QueryOption... options) throws OseeCoreException;
-
- /**
- * Search criteria that finds an attribute of the given type with its current value relative to the given value based
- * on the operator provided.
- */
- QueryBuilder and(IAttributeType attributeType, String value, QueryOption... options) throws OseeCoreException;
-
- /**
- * Search criteria that finds an attribute of the given type with its current value exactly equal (or not equal) to
- * any one of the given literal values. If the list only contains one value, then the search is conducted exactly as
- * if the single value constructor was called. This search does not support the (* wildcard) for multiple values.
- */
- QueryBuilder and(Collection<IAttributeType> attributeTypes, String value, QueryOption... options) throws OseeCoreException;
-
- /**
- * Search for related artifacts
- *
- * @param relationTypeSide the type-side to search on
- */
- QueryBuilder andRelatedTo(IRelationTypeSide relationTypeSide, ArtifactReadable... artifacts) throws OseeCoreException;
-
- /**
- * Search for related artifacts
- *
- * @param relationTypeSide the type-side to search on
- */
- QueryBuilder andRelatedTo(IRelationTypeSide relationTypeSide, Collection<? extends ArtifactReadable> artifacts) throws OseeCoreException;
-
- /**
- * Search for related artifacts
- *
- * @param relationTypeSide the type-side to search on
- */
- QueryBuilder andRelatedToLocalIds(IRelationTypeSide relationTypeSide, int... artifactIds) throws OseeCoreException;
-
- /**
- * Search for related artifacts
- *
- * @param relationTypeSide the type-side to search on
- */
- QueryBuilder andRelatedToLocalIds(IRelationTypeSide relationTypeSide, Collection<Integer> artifactIds) throws OseeCoreException;
-
- /**
- * Search related artifacts with specific criteria. Will only follow first level of relations
- *
- * @param relationTypeSide the type-side to search on
- */
- QueryBuilder followRelation(IRelationTypeSide relationTypeSide);
+public interface QueryBuilder extends ArtifactQueryBuilder<QueryBuilder>, Query {
/**
* Executes query
@@ -234,11 +47,13 @@ public interface QueryBuilder {
/**
* Count search results
*/
+ @Override
int getCount() throws OseeCoreException;
/**
* Schedule a count search results
*/
+ @Override
CancellableCallable<Integer> createCount() throws OseeCoreException;
/**
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TransactionQuery.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TransactionQuery.java
index fa3d063212c..856e917de78 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TransactionQuery.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TransactionQuery.java
@@ -10,86 +10,25 @@
*******************************************************************************/
package org.eclipse.osee.orcs.search;
-import java.sql.Timestamp;
-import java.util.Collection;
import org.eclipse.osee.executor.admin.CancellableCallable;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
-import org.eclipse.osee.orcs.data.ArtifactId;
import org.eclipse.osee.orcs.data.TransactionReadable;
/**
* @author Ryan D. Brooks
* @author Roberto E. Escobar
*/
-public interface TransactionQuery {
-
- TransactionQuery andTxId(int... id) throws OseeCoreException;
-
- TransactionQuery andTxIds(Collection<Integer> ids) throws OseeCoreException;
-
- TransactionQuery andTxId(Operator op, int id) throws OseeCoreException;
-
- /***********************************************************************
- * Use for complex queries such as ranges. Translates to transaction_id op1 id1 and transaction_id op2 id2
- *
- * @param op1 operator for first term
- * @param id1 id for first term
- * @param op2 operator for second term
- * @param id2 id for second term
- * @return the transaction query
- * @throws OseeCoreException
- */
- TransactionQuery andTxId(Operator op1, int id1, Operator op2, int id2) throws OseeCoreException;
-
- TransactionQuery andCommentEquals(String value) throws OseeCoreException;
-
- TransactionQuery andCommentPattern(String pattern) throws OseeCoreException;
-
- TransactionQuery andIs(TransactionDetailsType... types) throws OseeCoreException;
-
- TransactionQuery andIs(Collection<TransactionDetailsType> types) throws OseeCoreException;
-
- TransactionQuery andBranch(IOseeBranch... ids) throws OseeCoreException;
-
- TransactionQuery andBranch(Collection<? extends IOseeBranch> ids) throws OseeCoreException;
-
- TransactionQuery andBranchIds(long... id) throws OseeCoreException;
-
- TransactionQuery andBranchIds(Collection<Long> ids) throws OseeCoreException;
-
- TransactionQuery andDate(Operator op, Timestamp date) throws OseeCoreException;
-
- TransactionQuery andDate(Timestamp from, Timestamp to) throws OseeCoreException;
-
- TransactionQuery andAuthorLocalIds(ArtifactId... id) throws OseeCoreException;
-
- TransactionQuery andAuthorLocalIds(Collection<ArtifactId> ids) throws OseeCoreException;
-
- TransactionQuery andAuthorIds(int... id) throws OseeCoreException;
-
- TransactionQuery andAuthorIds(Collection<Integer> ids) throws OseeCoreException;
-
- TransactionQuery andCommitIds(Integer... id) throws OseeCoreException;
-
- TransactionQuery andCommitIds(Collection<Integer> ids) throws OseeCoreException;
-
- TransactionQuery andNullCommitId() throws OseeCoreException;
-
- TransactionQuery andIsHead(long branchUuid) throws OseeCoreException;
-
- TransactionQuery andIsHead(IOseeBranch branch) throws OseeCoreException;
-
- TransactionQuery andIsPriorTx(int txId) throws OseeCoreException;
+public interface TransactionQuery extends TxQueryBuilder<TransactionQuery>, Query {
ResultSet<TransactionReadable> getResults() throws OseeCoreException;
ResultSet<Integer> getResultsAsIds() throws OseeCoreException;
+ @Override
int getCount() throws OseeCoreException;
+ @Override
CancellableCallable<Integer> createCount() throws OseeCoreException;
CancellableCallable<ResultSet<TransactionReadable>> createSearch() throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TxQueryBuilder.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TxQueryBuilder.java
new file mode 100644
index 00000000000..dfd35aa6091
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TxQueryBuilder.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.orcs.search;
+
+import java.sql.Timestamp;
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.orcs.data.ArtifactId;
+
+/**
+ * @author Ryan D. Brooks
+ * @author Roberto E. Escobar
+ */
+public interface TxQueryBuilder<T> {
+
+ T andTxId(int... id) throws OseeCoreException;
+
+ T andTxIds(Collection<Integer> ids) throws OseeCoreException;
+
+ T andTxId(Operator op, int id) throws OseeCoreException;
+
+ T andTxId(Operator op1, int id1, Operator op2, int id2) throws OseeCoreException;
+
+ T andCommentEquals(String value) throws OseeCoreException;
+
+ T andCommentPattern(String pattern) throws OseeCoreException;
+
+ T andIs(TransactionDetailsType... types) throws OseeCoreException;
+
+ T andIs(Collection<TransactionDetailsType> types) throws OseeCoreException;
+
+ T andBranch(IOseeBranch... ids) throws OseeCoreException;
+
+ T andBranch(Collection<? extends IOseeBranch> ids) throws OseeCoreException;
+
+ T andBranchIds(long... id) throws OseeCoreException;
+
+ T andBranchIds(Collection<Long> ids) throws OseeCoreException;
+
+ T andDate(Operator op, Timestamp date) throws OseeCoreException;
+
+ T andDate(Timestamp from, Timestamp to) throws OseeCoreException;
+
+ T andAuthorLocalIds(ArtifactId... id) throws OseeCoreException;
+
+ T andAuthorLocalIds(Collection<ArtifactId> ids) throws OseeCoreException;
+
+ T andAuthorIds(int... id) throws OseeCoreException;
+
+ T andAuthorIds(Collection<Integer> ids) throws OseeCoreException;
+
+ T andCommitIds(Integer... id) throws OseeCoreException;
+
+ T andCommitIds(Collection<Integer> ids) throws OseeCoreException;
+
+ T andNullCommitId() throws OseeCoreException;
+
+ T andIsHead(long branchUuid) throws OseeCoreException;
+
+ T andIsHead(IOseeBranch branch) throws OseeCoreException;
+
+ T andIsPriorTx(int txId) throws OseeCoreException;
+}

Back to the top