Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2017-05-25 01:03:02 +0000
committerRyan D. Brooks2017-05-30 21:55:35 +0000
commitb2a34da3d53dd7bac7b9d63c559b86cc6b927832 (patch)
tree43ecadb619bd4b305164363df261bb7441d3c0b9
parent70a785902590615e552032e77f10f493416b9010 (diff)
downloadorg.eclipse.osee-b2a34da3d53dd7bac7b9d63c559b86cc6b927832.tar.gz
org.eclipse.osee-b2a34da3d53dd7bac7b9d63c559b86cc6b927832.tar.xz
org.eclipse.osee-b2a34da3d53dd7bac7b9d63c559b86cc6b927832.zip
refactor: Improve memory efficiency of TxQueryBuilder
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseId.java5
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Id.java20
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java23
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaTxIds.java16
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeTransactionCommand.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptInterpreterImpl.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionCriteriaFactory.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TxQueryBuilderImpl.java17
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java17
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/TxIdsSqlHandler.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributeTypeResource.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java20
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchTest.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java164
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TxQueryBuilder.java4
17 files changed, 173 insertions, 161 deletions
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseId.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseId.java
index 40483959cc1..999e57487eb 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseId.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseId.java
@@ -67,9 +67,10 @@ public class BaseId implements Id, Cloneable {
* Use this method to construct an instance of an Id that is of the same type as the object this is called on (likely
* a subclass of BaseId). It will set the numeric id to the given value.
*/
- public BaseId clone(Long id) {
+ @Override
+ public <T extends Id> T clone(Long id) {
BaseId newId = clone();
newId.id = id;
- return newId;
+ return (T) newId;
}
}
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Id.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Id.java
index 2604d5df458..1ba73286d67 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Id.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/Id.java
@@ -65,4 +65,24 @@ public interface Id {
default boolean isInvalid() {
return !isValid();
}
+
+ default <T extends Id> T minus(T id) {
+ return clone(getId() - id.getId());
+ }
+
+ default <T extends Id> T plus(T id) {
+ return clone(getId() + id.getId());
+ }
+
+ default <T extends Id> T clone(Long id) {
+ throw new UnsupportedOperationException();
+ }
+
+ default boolean isLessThan(Id other) {
+ return getId() < other.getId();
+ }
+
+ default boolean isGreaterThan(Id other) {
+ return getId() > other.getId();
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java
index 5b5832e4e2c..f27fc250de8 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java
@@ -21,8 +21,8 @@ import java.util.List;
import java.util.Set;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.AttributeId;
-import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.AttributeTypeId;
+import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.data.TransactionToken;
@@ -94,7 +94,7 @@ public final class TransactionManager {
"select * from osee_relation_link rel, osee_txs txs where txs.branch_id = ? and (rel.a_art_id = ? or rel.b_art_id = ?) and txs.TRANSACTION_ID = ? and rel.gamma_id = txs.GAMMA_ID";
private static final String SELECT_ART_TRANSACTION_IDS =
- "select distinct txs.transaction_id from osee_attribute attr, osee_txs txs where txs.branch_id = ? and art_id = ? and attr.GAMMA_ID = txs.gamma_id order by txs.transaction_id desc";
+ "select max(transaction_id) as prevTx from osee_attribute atr, osee_txs txs where branch_id = ? and art_id = ? and atr.gamma_id = txs.gamma_id and transaction_id < ?";
private static final TxMonitorImpl<BranchId> txMonitor = new TxMonitorImpl<>(new TxMonitorCache<>());
private static final HashCollection<ArtifactId, TransactionRecord> commitArtifactIdMap =
@@ -340,23 +340,8 @@ public final class TransactionManager {
}
public static TransactionId getPreviousTransactionId(Artifact art, TransactionId trans) {
- boolean found = false;
- JdbcStatement chStmt = ConnectionHandler.getStatement();
- try {
- chStmt.runPreparedQuery(SELECT_ART_TRANSACTION_IDS, art.getBranch().getId(), art.getArtId());
- while (chStmt.next()) {
- Integer transId = chStmt.getInt("transaction_id");
- if (transId.equals(trans.getId().intValue())) {
- found = true;
- }
- if (found && !transId.equals(trans.getId().intValue())) {
- return TransactionId.valueOf(transId);
- }
- }
- } finally {
- chStmt.close();
- }
- return null;
+ return ConnectionHandler.getJdbcClient().fetch(TransactionId.SENTINEL, SELECT_ART_TRANSACTION_IDS,
+ art.getBranch(), art, trans);
}
public static List<RelationRow> getRelationsFromArtifactAndTransaction(Artifact art, TransactionId trans) {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaTxIds.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaTxIds.java
index c761e5cc0e2..033bead6e65 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaTxIds.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaTxIds.java
@@ -10,7 +10,10 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds.criteria;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.orcs.core.ds.Criteria;
@@ -21,10 +24,15 @@ import org.eclipse.osee.orcs.core.ds.Options;
*/
public class CriteriaTxIds extends Criteria implements TxCriteria {
- private final Collection<Long> ids;
+ private final Collection<TransactionId> ids;
- public CriteriaTxIds(Collection<Long> ids) {
- super();
+ public CriteriaTxIds(Collection<TransactionId> ids) {
+ this.ids = ids;
+ }
+
+ public CriteriaTxIds(TransactionId txId) {
+ List<TransactionId> ids = new ArrayList<>(1);
+ ids.add(txId);
this.ids = ids;
}
@@ -33,7 +41,7 @@ public class CriteriaTxIds extends Criteria implements TxCriteria {
Conditions.checkNotNullOrEmpty(ids, "tx ids");
}
- public Collection<Long> getIds() {
+ public Collection<TransactionId> getIds() {
return ids;
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeTransactionCommand.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeTransactionCommand.java
index 6562cc1d75c..9c6f678683d 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeTransactionCommand.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeTransactionCommand.java
@@ -18,7 +18,6 @@ import org.eclipse.osee.console.admin.Console;
import org.eclipse.osee.console.admin.ConsoleCommand;
import org.eclipse.osee.console.admin.ConsoleParameters;
import org.eclipse.osee.framework.core.data.TransactionId;
-import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.transaction.TransactionFactory;
@@ -62,7 +61,7 @@ public class PurgeTransactionCommand implements ConsoleCommand {
String[] stringIds = params.getArray("txIds");
final List<TransactionId> transactions = new ArrayList<>();
for (String arg : stringIds) {
- TransactionId tx = TransactionId.valueOf(Integer.parseInt(arg));
+ TransactionId tx = TransactionId.valueOf(arg);
transactions.add(tx);
}
console.writeln();
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptInterpreterImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptInterpreterImpl.java
index 3412b3d55f8..56c33f459e1 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptInterpreterImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptInterpreterImpl.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.orcs.core.internal.script.impl;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,6 +30,7 @@ import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.RelationTypeSide;
import org.eclipse.osee.framework.core.data.RelationTypeToken;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.enums.BranchType;
import org.eclipse.osee.framework.core.enums.QueryOption;
@@ -322,7 +324,7 @@ public class OrcsScriptInterpreterImpl implements OrcsScriptInterpreter {
@Override
public Void caseOsTxQueryById(OsTxQueryById object) {
int id = resolver.resolveSingle(Integer.class, object.getName());
- newTxQuery().andTxId(id);
+ newTxQuery().andTxId(TransactionId.valueOf(id));
return null;
}
@@ -340,8 +342,8 @@ public class OrcsScriptInterpreterImpl implements OrcsScriptInterpreter {
@Override
public Void caseOsTxIdEqualsClause(OsTxIdEqualsClause object) {
- Collection<Long> ids = resolver.resolve(Long.class, object.getIds());
- getTxQuery().andTxIds(ids);
+ List<Long> ids = resolver.resolve(Long.class, object.getIds());
+ getTxQuery().andTxIds(Lists.transform(ids, TransactionId::valueOf));
return null;
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionCriteriaFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionCriteriaFactory.java
index b0073141ed8..0d541171bf6 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionCriteriaFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionCriteriaFactory.java
@@ -12,8 +12,8 @@ package org.eclipse.osee.orcs.core.internal.search;
import java.sql.Timestamp;
import java.util.Collection;
-import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.data.BranchId;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.orcs.core.ds.Criteria;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAllTxs;
@@ -27,7 +27,6 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxGetHead;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxGetPrior;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxIdWithOperator;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxIdWithTwoOperators;
-import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxIds;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxType;
import org.eclipse.osee.orcs.search.Operator;
@@ -40,10 +39,6 @@ public class TransactionCriteriaFactory {
return new CriteriaAllTxs();
}
- public Criteria newByIdsCriteria(Collection<Long> ids) {
- return new CriteriaTxIds(ids);
- }
-
public Criteria newCommentCriteria(String value, boolean isPattern) {
return new CriteriaTxComment(value, isPattern);
}
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
index 130caeac377..949dd580078 100644
--- 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
@@ -25,6 +25,7 @@ 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.core.ds.criteria.CriteriaTxArtifactIds;
+import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxIds;
import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.TxQueryBuilder;
@@ -50,18 +51,8 @@ public class TxQueryBuilderImpl<T> implements TxQueryBuilder<T> {
}
@Override
- public T andTxId(long... ids) throws OseeCoreException {
- Set<Long> values = new LinkedHashSet<>();
- for (long value : ids) {
- values.add(value);
- }
- return andTxIds(values);
- }
-
- @Override
- public T andTxIds(Collection<Long> ids) throws OseeCoreException {
- Criteria criteria = criteriaFactory.newByIdsCriteria(ids);
- return addAndCheck(queryData, criteria);
+ public T andTxIds(Collection<TransactionId> ids) throws OseeCoreException {
+ return addAndCheck(queryData, new CriteriaTxIds(ids));
}
@Override
@@ -221,6 +212,6 @@ public class TxQueryBuilderImpl<T> implements TxQueryBuilder<T> {
@Override
public T andTxId(TransactionId id) {
- return andTxIds(Arrays.asList(id.getId()));
+ return addAndCheck(queryData, new CriteriaTxIds(id));
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java
index 4b4a2e42435..ce4657f0c6a 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java
@@ -11,12 +11,8 @@
package org.eclipse.osee.orcs.core.internal.transaction;
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.collect.Sets.SetView;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.Callable;
import org.eclipse.osee.executor.admin.CancellableCallable;
import org.eclipse.osee.framework.core.data.ArtifactId;
@@ -24,6 +20,7 @@ import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.data.TransactionToken;
import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.exception.OseeNotFoundException;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
import org.eclipse.osee.framework.core.model.change.CompareResults;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -132,7 +129,7 @@ public class TransactionFactoryImpl implements TransactionFactory {
@Override
public boolean purgeTxs(String txIds) {
boolean modified = false;
- List<Long> txsToDelete = Collections.fromString(txIds, Long::parseLong);
+ List<TransactionId> txsToDelete = Collections.fromString(txIds, TransactionId::valueOf);
if (!txsToDelete.isEmpty()) {
ResultSet<? extends TransactionId> results =
@@ -175,15 +172,11 @@ public class TransactionFactoryImpl implements TransactionFactory {
return queryFactory.transactionQuery().andTxId(tx).getResults().getExactlyOne();
}
- private void checkAllTxsFound(String opName, List<Long> txIds, ResultSet<? extends TransactionId> result) {
+ private void checkAllTxsFound(String opName, List<TransactionId> txIds, ResultSet<? extends TransactionId> result) {
if (txIds.size() != result.size()) {
- Set<Long> found = new HashSet<>();
- for (TransactionId tx : result) {
- found.add(tx.getId());
- }
- SetView<Long> difference = Sets.difference(Sets.newHashSet(txIds), found);
+ List<TransactionId> difference = Collections.setComplement(txIds, result.getList());
if (!difference.isEmpty()) {
- throw new OseeCoreException(
+ throw new OseeNotFoundException(
"%s Error - The following transactions from %s were not found - txs %s - Please remove them from the request and try again.",
opName, txIds, difference);
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java
index ec62f627126..e34633be89a 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.db.internal.search.engines;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
+import com.google.common.collect.Lists;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Collection;
@@ -60,7 +61,8 @@ import org.mockito.stubbing.Answer;
*/
public class TxQuerySqlContextFactoryImplTest {
- private static final Criteria IDS = id(1L, 2L, 3L, 4l, 5L);
+ private static final Criteria IDS =
+ new CriteriaTxIds(Lists.transform(Arrays.asList(1L, 2L, 3L, 4l, 5L), TransactionId::valueOf));
private static final Criteria COMMENT = comment("SimpleTemplateProviderTask", false);
private static final Criteria TYPES =
type(Arrays.asList(TransactionDetailsType.Baselined, TransactionDetailsType.NonBaselined));
@@ -299,10 +301,6 @@ public class TxQuerySqlContextFactoryImplTest {
assertEquals(tx, iterator.next());
}
- private static Criteria id(Long... values) {
- return new CriteriaTxIds(Arrays.asList(values));
- }
-
private static Criteria comment(String value, boolean isPattern) {
return new CriteriaTxComment(value, isPattern);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/TxIdsSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/TxIdsSqlHandler.java
index 1f463b84fdc..3a3deffd1d8 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/TxIdsSqlHandler.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/TxIdsSqlHandler.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.db.internal.search.handlers;
import java.util.Collection;
import java.util.List;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxIds;
import org.eclipse.osee.orcs.db.internal.sql.AbstractSqlWriter;
@@ -49,9 +50,9 @@ public class TxIdsSqlHandler extends SqlHandler<CriteriaTxIds> {
@Override
public boolean addPredicates(AbstractSqlWriter writer) throws OseeCoreException {
- Collection<Long> ids = criteria.getIds();
+ Collection<TransactionId> ids = criteria.getIds();
if (ids.size() > 1) {
- AbstractJoinQuery joinQuery = writer.writeIdJoin(ids);
+ AbstractJoinQuery joinQuery = writer.writeJoin(ids);
writer.write(txdAlias);
writer.write(".transaction_id = ");
writer.write(jIdAlias);
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java
index 632aa658002..e24eaf45aff 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java
@@ -25,6 +25,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.enums.BranchType;
import org.eclipse.osee.framework.core.model.change.CompareResults;
@@ -91,7 +92,7 @@ public interface BranchEndpoint {
@GET
@Path("{branch}/txs/{tx-id}")
@Produces({MediaType.APPLICATION_JSON})
- Transaction getBranchTx(@PathParam("branch") BranchId branch, @PathParam("tx-id") int txId);
+ Transaction getBranchTx(@PathParam("branch") BranchId branch, @PathParam("tx-id") TransactionId txId);
@POST
@Consumes(MediaType.APPLICATION_JSON)
@@ -161,7 +162,7 @@ public interface BranchEndpoint {
@PUT
@Path("{branch}/txs/{tx-id}/comment")
- Response setTxComment(@PathParam("branchd") BranchId branch, @PathParam("tx-id") int txId, String comment);
+ Response setTxComment(@PathParam("branchd") BranchId branch, @PathParam("tx-id") TransactionId txId, String comment);
@DELETE
@Path("{branch}")
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributeTypeResource.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributeTypeResource.java
index f1c5c5c8b97..e6c052b2b9d 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributeTypeResource.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributeTypeResource.java
@@ -55,11 +55,11 @@ public class AttributeTypeResource {
private final TransactionId transactionId;
public AttributeTypeResource(UriInfo uriInfo, Request request, BranchId branchId, Long artifactUuid) {
- this(uriInfo, request, branchId, artifactUuid, -1L, TransactionId.valueOf(-1));
+ this(uriInfo, request, branchId, artifactUuid, -1L, TransactionId.SENTINEL);
}
public AttributeTypeResource(UriInfo uriInfo, Request request, BranchId branchId, Long artifactUuid, Long attributeTypeId) {
- this(uriInfo, request, branchId, artifactUuid, attributeTypeId, TransactionId.valueOf(-1));
+ this(uriInfo, request, branchId, artifactUuid, attributeTypeId, TransactionId.SENTINEL);
}
public AttributeTypeResource(UriInfo uriInfo, Request request, BranchId branchId, Long artifactUuid, Long attributeTypeId, TransactionId transactionId) {
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java
index c67d11d95e8..840efec7f1c 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java
@@ -18,14 +18,10 @@ import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.asTransaction;
import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.asTransactions;
import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.executeCallable;
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.collect.Sets.SetView;
import java.net.URI;
import java.util.Collection;
-import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.Callable;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
@@ -144,7 +140,7 @@ public class BranchEndpointImpl implements BranchEndpoint {
return results.getExactlyOne();
}
- private TransactionReadable getTxByBranchAndId(BranchId branch, int txId) {
+ private TransactionReadable getTxByBranchAndId(BranchId branch, TransactionId txId) {
return newTxQuery().andBranch(branch).andTxId(txId).getResults().getExactlyOne();
}
@@ -240,7 +236,7 @@ public class BranchEndpointImpl implements BranchEndpoint {
}
@Override
- public Transaction getBranchTx(BranchId branchUuid, int txId) {
+ public Transaction getBranchTx(BranchId branchUuid, TransactionId txId) {
return asTransaction(getTxByBranchAndId(branchUuid, txId));
}
@@ -655,7 +651,7 @@ public class BranchEndpointImpl implements BranchEndpoint {
}
@Override
- public Response setTxComment(BranchId branch, int txId, String comment) {
+ public Response setTxComment(BranchId branch, TransactionId txId, String comment) {
TransactionReadable tx = getTxByBranchAndId(branch, txId);
boolean modified = false;
if (Compare.isDifferent(tx.getComment(), comment)) {
@@ -747,7 +743,7 @@ public class BranchEndpointImpl implements BranchEndpoint {
@Override
public Response purgeTxs(BranchId branch, String txIds) {
boolean modified = false;
- List<Long> txsToDelete = Collections.fromString(txIds, Long::parseLong);
+ List<TransactionId> txsToDelete = Collections.fromString(txIds, TransactionId::valueOf);
if (!txsToDelete.isEmpty()) {
ResultSet<? extends TransactionId> results = newTxQuery().andBranch(branch).andTxIds(txsToDelete).getResults();
if (!results.isEmpty()) {
@@ -771,13 +767,9 @@ public class BranchEndpointImpl implements BranchEndpoint {
return asResponse(modified);
}
- private void checkAllTxFoundAreOnBranch(String opName, BranchId branch, List<Long> txIds, ResultSet<? extends TransactionId> result) {
+ private void checkAllTxFoundAreOnBranch(String opName, BranchId branch, List<TransactionId> txIds, ResultSet<? extends TransactionId> result) {
if (txIds.size() != result.size()) {
- Set<Long> found = new HashSet<>();
- for (TransactionId tx : result) {
- found.add(tx.getId());
- }
- SetView<Long> difference = Sets.difference(Sets.newHashSet(txIds), found);
+ List<TransactionId> difference = Collections.setComplement(txIds, result.getList());
if (!difference.isEmpty()) {
throw new OseeWebApplicationException(Status.BAD_REQUEST,
"%s Error - The following transactions from %s were not found on branch [%s] - txs %s - Please remove them from the request and try again.",
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchTest.java
index e736a62448b..32dc3e8684c 100644
--- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchTest.java
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchTest.java
@@ -121,8 +121,8 @@ public class OrcsBranchTest {
public void testCreateBranchCopyFromTx() throws Exception {
// this test shows that the change report for a transaction for the newly copied branch is
// the same as the change report on the branch the transaction is copied from
- int PRIOR_TX_ID = 15;
- int SOURCE_TX_ID = 16;
+ TransactionId PRIOR_TX_ID = TransactionId.valueOf(15);
+ TransactionId SOURCE_TX_ID = TransactionId.valueOf(16);
// get the list of changes from the original branch
TransactionToken priorTx = query.transactionQuery().andTxId(PRIOR_TX_ID).getResults().getExactlyOne();
@@ -135,8 +135,8 @@ public class OrcsBranchTest {
ArtifactId author = SystemUser.OseeSystem;
- TransactionId tx = TransactionId.valueOf(SOURCE_TX_ID);
- Callable<BranchReadable> callableBranch = branchOps.createCopyTxBranch(branch, author, tx, ArtifactId.SENTINEL);
+ Callable<BranchReadable> callableBranch =
+ branchOps.createCopyTxBranch(branch, author, SOURCE_TX_ID, ArtifactId.SENTINEL);
// the new branch will contain two transactions - these should have the same change report as the original branch
BranchReadable postBranch = callableBranch.call();
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java
index b003edcc94c..0468798a8fa 100644
--- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java
@@ -27,6 +27,7 @@ import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.osee.framework.core.data.ArtifactId;
@@ -68,10 +69,32 @@ public class OrcsTxQueryTest {
private final static DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
private QueryFactory factory;
- private final Long CommonBranchHeadTransaction = 178L;
private final String CommonBranchTransComment = "Cleanup PopulateDemoActionsTest";
private final int NumberCommonTransactions = 132;
+ private final TransactionId CommonBranchHeadTransaction = TransactionId.valueOf(178);
+ private final TransactionId tx1 = TransactionId.valueOf(1);
+ private final TransactionId tx2 = TransactionId.valueOf(2);
+ private final TransactionId tx3 = TransactionId.valueOf(3);
+ private final TransactionId tx4 = TransactionId.valueOf(4);
+ private final TransactionId tx5 = TransactionId.valueOf(5);
+
+ private final TransactionId tx21 = TransactionId.valueOf(21);
+ private final TransactionId tx22 = TransactionId.valueOf(22);
+ private final TransactionId tx23 = TransactionId.valueOf(23);
+
+ private final TransactionId tx30 = TransactionId.valueOf(30);
+ private final TransactionId tx31 = TransactionId.valueOf(31);
+ private final TransactionId tx32 = TransactionId.valueOf(32);
+ private final TransactionId tx33 = TransactionId.valueOf(33);
+ private final TransactionId tx34 = TransactionId.valueOf(34);
+ private final TransactionId tx65 = TransactionId.valueOf(65);
+ private final TransactionId tx69 = TransactionId.valueOf(69);
+ private final TransactionId tx70 = TransactionId.valueOf(70);
+ private final TransactionId tx71 = TransactionId.valueOf(71);
+ private final TransactionId tx72 = TransactionId.valueOf(72);
+ private final TransactionId tx73 = TransactionId.valueOf(73);
+
@Before
public void setup() {
factory = orcsApi.getQueryFactory();
@@ -85,25 +108,25 @@ public class OrcsTxQueryTest {
assertEquals(CommonBranchHeadTransaction, Long.valueOf(results.size()));
List<TransactionReadable> transactions = results.getList();
- assertTx(transactions, Long.valueOf(4), Baselined, "New Branch from System Root Branch (3)", COMMON, OseeSystem);
- assertTx(transactions, Long.valueOf(5), NonBaselined, "Add Types to Common Branch", COMMON, OseeSystem);
+ assertTx(transactions, tx4, Baselined, "New Branch from System Root Branch (3)", COMMON, OseeSystem);
+ assertTx(transactions, tx5, NonBaselined, "Add Types to Common Branch", COMMON, OseeSystem);
}
@Test
public void testGetByTxId() throws OseeCoreException {
TransactionQuery query = factory.transactionQuery();
- query.andTxId(3, 23);
+ query.andTxIds(Arrays.asList(TransactionId.valueOf(3), TransactionId.valueOf(23)));
ResultSet<TransactionReadable> results = query.getResults();
assertEquals(2, results.size());
List<TransactionReadable> transactions = results.getList();
- assertTxExists(transactions, Long.valueOf(3));
- assertTxExists(transactions, Long.valueOf(23));
+ assertTxExists(transactions, tx3);
+ assertTxExists(transactions, tx23);
Iterator<Long> ids = query.getResultsAsIds().iterator();
- assertEquals(Long.valueOf(3), ids.next());
- assertEquals(Long.valueOf(23), ids.next());
+ assertEquals(tx3, ids.next());
+ assertEquals(tx23, ids.next());
}
@Test
@@ -114,7 +137,7 @@ public class OrcsTxQueryTest {
List<TransactionReadable> actual = query.getResults().getList();
assertEquals(3, query.getCount());
- assertTx(actual, Long.valueOf(30), Baselined, "New Branch from System Root Branch (3)", SAW_Bld_1, OseeSystem);
+ assertTx(actual, tx30, Baselined, "New Branch from System Root Branch (3)", SAW_Bld_1, OseeSystem);
}
@Test
@@ -139,15 +162,15 @@ public class OrcsTxQueryTest {
assertEquals(8, query.getCount());
List<TransactionReadable> transactions = results.getList();
- assertTx(transactions, Long.valueOf(1), Baselined, "System Root Branch Creation", SYSTEM_ROOT,
+ assertTx(transactions, tx1, Baselined, "System Root Branch Creation", SYSTEM_ROOT,
ArtifactId.valueOf(OseeSystem.getId()));
- assertTx(transactions, Long.valueOf(4), Baselined, "New Branch from System Root Branch (3)", COMMON,
+ assertTx(transactions, tx4, Baselined, "New Branch from System Root Branch (3)", COMMON,
ArtifactId.valueOf(OseeSystem.getId()));
- assertTx(transactions, Long.valueOf(30), Baselined, "New Branch from System Root Branch (3)", SAW_Bld_1,
+ assertTx(transactions, tx30, Baselined, "New Branch from System Root Branch (3)", SAW_Bld_1,
ArtifactId.valueOf(OseeSystem.getId()));
- assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1,
+ assertTx(transactions, tx33, Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1,
ArtifactId.valueOf(OseeSystem.getId()));
- assertTx(transactions, Long.valueOf(73), Baselined, "New Branch from SAW_Bld_1 (72)", SAW_Bld_2, Joe_Smith);
+ assertTx(transactions, tx73, Baselined, "New Branch from SAW_Bld_1 (72)", SAW_Bld_2, Joe_Smith);
}
@Test
@@ -160,9 +183,9 @@ public class OrcsTxQueryTest {
assertEquals(4, query.getCount());
List<TransactionReadable> transactions = results.getList();
- assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1,
+ assertTx(transactions, tx33, Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1,
ArtifactId.valueOf(OseeSystem.getId()));
- assertTx(transactions, Long.valueOf(73), Baselined, "New Branch from SAW_Bld_1 (72)", SAW_Bld_2, Joe_Smith);
+ assertTx(transactions, tx73, Baselined, "New Branch from SAW_Bld_1 (72)", SAW_Bld_2, Joe_Smith);
}
@Test
@@ -176,16 +199,16 @@ public class OrcsTxQueryTest {
List<TransactionReadable> transactions = results.getList();
//@formatter:off
- assertTx(transactions, Long.valueOf(30), Baselined, "New Branch from System Root Branch (3)", SAW_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
- assertTx(transactions, Long.valueOf(31), NonBaselined, "DemoDatabaseConfig", SAW_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
- assertTx(transactions, Long.valueOf(32), NonBaselined, "Create Demo Applicability", SAW_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
- assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
- assertTx(transactions, Long.valueOf(34), NonBaselined, "DemoDatabaseConfig", CIS_Bld_1,ArtifactId.valueOf(OseeSystem.getId()));
-
- assertTx(transactions, Long.valueOf(69), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, Joe_Smith);
- assertTx(transactions, Long.valueOf(70), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, Joe_Smith);
- assertTx(transactions, Long.valueOf(71), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, Joe_Smith);
- assertTx(transactions, Long.valueOf(72), NonBaselined, "Populate Demo DB - Create Traceability", SAW_Bld_1, Joe_Smith);
+ assertTx(transactions, tx30, Baselined, "New Branch from System Root Branch (3)", SAW_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
+ assertTx(transactions, tx31, NonBaselined, "DemoDatabaseConfig", SAW_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
+ assertTx(transactions, tx32, NonBaselined, "Create Demo Applicability", SAW_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
+ assertTx(transactions, tx33, Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
+ assertTx(transactions, tx34, NonBaselined, "DemoDatabaseConfig", CIS_Bld_1,ArtifactId.valueOf(OseeSystem.getId()));
+
+ assertTx(transactions, tx69, NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, Joe_Smith);
+ assertTx(transactions, tx70, NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, Joe_Smith);
+ assertTx(transactions, tx71, NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, Joe_Smith);
+ assertTx(transactions, tx72, NonBaselined, "Populate Demo DB - Create Traceability", SAW_Bld_1, Joe_Smith);
//@formatter:on
}
@@ -199,8 +222,8 @@ public class OrcsTxQueryTest {
assertEquals(2, query.getCount());
List<TransactionReadable> transactions = results.getList();
- assertTxExists(transactions, Long.valueOf(1));
- assertTxExists(transactions, Long.valueOf(2));
+ assertTxExists(transactions, tx1);
+ assertTxExists(transactions, tx2);
query = factory.transactionQuery();
query.andTxId(Operator.LESS_THAN, 2);
@@ -209,7 +232,7 @@ public class OrcsTxQueryTest {
assertEquals(1, query.getCount());
transactions = results.getList();
- assertTxExists(transactions, Long.valueOf(1));
+ assertTxExists(transactions, tx1);
}
@Test
@@ -217,21 +240,21 @@ public class OrcsTxQueryTest {
TransactionQuery query = factory.transactionQuery();
query.andTxId(Operator.GREATER_THAN_EQ, 21);
ResultSet<TransactionReadable> results = query.getResults();
- assertEquals(CommonBranchHeadTransaction - 21 + 1, results.size());
+ assertEquals(CommonBranchHeadTransaction.getId() - 21 + 1, results.size());
List<TransactionReadable> transactions = results.getList();
- for (Long x = Long.valueOf(21); x <= CommonBranchHeadTransaction; x++) {
+ for (Long x = tx21.getId(); x <= CommonBranchHeadTransaction.getId(); x++) {
assertNotNull(getTransaction(transactions, x));
}
query = factory.transactionQuery();
query.andTxId(Operator.GREATER_THAN, 21);
results = query.getResults();
- assertEquals(CommonBranchHeadTransaction - 21, results.size());
+ assertEquals(CommonBranchHeadTransaction.getId() - 21, results.size());
transactions = results.getList();
- Assert.assertNull(getTransaction(transactions, Long.valueOf(21)));
- for (Long x = Long.valueOf(22); x <= CommonBranchHeadTransaction; x++) {
+ Assert.assertNull(getTransaction(transactions, tx21));
+ for (Long x = tx22.getId(); x <= CommonBranchHeadTransaction.getId(); x++) {
assertNotNull(getTransaction(transactions, x));
}
@@ -246,7 +269,7 @@ public class OrcsTxQueryTest {
assertEquals(1, results.size());
List<TransactionReadable> transactions = results.getList();
- assertTxExists(transactions, Long.valueOf(21));
+ assertTxExists(transactions, tx21);
query = factory.transactionQuery();
query.andTxId(Operator.NOT_EQUAL, 10);
@@ -266,7 +289,7 @@ public class OrcsTxQueryTest {
assertEquals(1, query.getCount());
List<TransactionReadable> transactions = results.getList();
- assertTxExists(transactions, Long.valueOf(22));
+ assertTxExists(transactions, tx22);
query = factory.transactionQuery();
query.andTxId(Operator.GREATER_THAN_EQ, 21, Operator.LESS_THAN_EQ, 23);
@@ -275,22 +298,22 @@ public class OrcsTxQueryTest {
assertEquals(3, query.getCount());
transactions = results.getList();
- assertTxExists(transactions, Long.valueOf(21));
- assertTxExists(transactions, Long.valueOf(22));
- assertTxExists(transactions, Long.valueOf(23));
+ assertTxExists(transactions, tx21);
+ assertTxExists(transactions, tx22);
+ assertTxExists(transactions, tx23);
}
@Test
public void testGetDateOperator() throws Exception {
TransactionQuery query = factory.transactionQuery();
- query.andTxId(65);
+ query.andTxId(tx65);
Timestamp date = new Timestamp(query.getResults().getAtMostOneOrNull().getDate().getTime());
query = factory.transactionQuery();
query.andDate(Operator.GREATER_THAN, date);
ResultSet<TransactionReadable> results = query.getResults();
- assertEquals(CommonBranchHeadTransaction - 65, results.size());
+ assertEquals(CommonBranchHeadTransaction.getId() - tx65.getId(), results.size());
query = factory.transactionQuery();
query.andDate(Operator.LESS_THAN, date);
@@ -302,11 +325,11 @@ public class OrcsTxQueryTest {
@Test
public void testGetDateRange() throws Exception {
TransactionQuery query = factory.transactionQuery();
- query.andTxId(1);
+ query.andTxId(TransactionId.valueOf(1));
Timestamp date1 = new Timestamp(query.getResults().getAtMostOneOrNull().getDate().getTime());
query = factory.transactionQuery();
- query.andTxId(65);
+ query.andTxId(tx65);
Timestamp date2 = new Timestamp(query.getResults().getAtMostOneOrNull().getDate().getTime());
query = factory.transactionQuery();
@@ -324,8 +347,7 @@ public class OrcsTxQueryTest {
assertEquals(128, query.getCount());
List<TransactionReadable> transactions = results.getList();
- assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1,
- OseeSystem);
+ assertTx(transactions, tx33, Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, OseeSystem);
query = factory.transactionQuery();
query.andAuthorLocalIds(OseeSystem, Joe_Smith);
@@ -335,8 +357,8 @@ public class OrcsTxQueryTest {
transactions = results.getList();
//@formatter:off
- assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
- assertTx(transactions, Long.valueOf(69), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, Joe_Smith);
+ assertTx(transactions, tx33, Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
+ assertTx(transactions, tx69, NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, Joe_Smith);
assertTx(transactions, CommonBranchHeadTransaction, NonBaselined, CommonBranchTransComment, COMMON, Joe_Smith);
//@formatter:on
@@ -351,8 +373,8 @@ public class OrcsTxQueryTest {
transactions = results.getList();
//@formatter:off
- assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
- assertTx(transactions, Long.valueOf(69), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, Joe_Smith);
+ assertTx(transactions, tx33, Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId()));
+ assertTx(transactions, tx69, NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, Joe_Smith);
assertTx(transactions, CommonBranchHeadTransaction, NonBaselined, CommonBranchTransComment, COMMON, Joe_Smith);
//@formatter:on
@@ -366,11 +388,11 @@ public class OrcsTxQueryTest {
assertEquals(177, query.getCount());
List<TransactionReadable> transactions = results.getList();
- assertTxExists(transactions, Long.valueOf(1));
- assertTxExists(transactions, Long.valueOf(2));
- assertTxExists(transactions, Long.valueOf(3));
- assertTxExists(transactions, Long.valueOf(4));
- assertTxExists(transactions, Long.valueOf(5));
+ assertTxExists(transactions, tx1);
+ assertTxExists(transactions, tx2);
+ assertTxExists(transactions, tx3);
+ assertTxExists(transactions, tx4);
+ assertTxExists(transactions, tx5);
query = factory.transactionQuery();
query.andCommitIds(OseeSystem.getId().intValue(), 1);
@@ -404,7 +426,7 @@ public class OrcsTxQueryTest {
assertEquals(1, query.getCount());
List<TransactionReadable> transactions = results.getList();
- assertTxExists(transactions, Long.valueOf(3));
+ assertTxExists(transactions, tx3);
}
@Test
@@ -463,22 +485,22 @@ public class OrcsTxQueryTest {
@Test
public void testGetPriorTx() throws OseeCoreException {
TransactionQuery query = factory.transactionQuery();
- query.andIsPriorTx(TransactionId.valueOf(CommonBranchHeadTransaction));
+ query.andIsPriorTx(CommonBranchHeadTransaction);
ResultSet<TransactionReadable> results = query.getResults();
assertEquals(1, results.size());
assertEquals(1, query.getCount());
List<TransactionReadable> transactions = results.getList();
- assertTxExists(transactions, Long.valueOf(CommonBranchHeadTransaction - 1));
+ assertTxExists(transactions, Long.valueOf(CommonBranchHeadTransaction.getId() - 1));
Iterator<Long> ids = query.getResultsAsIds().iterator();
- assertEquals(Long.valueOf(CommonBranchHeadTransaction - 1), ids.next());
+ assertEquals(Long.valueOf(CommonBranchHeadTransaction.getId() - 1), ids.next());
}
- private static void assertTx(List<TransactionReadable> transactions, Long localId, TransactionDetailsType type, String comment, BranchId branch, ArtifactId author) {
+ private static void assertTx(List<TransactionReadable> transactions, TransactionId localId, TransactionDetailsType type, String comment, BranchId branch, ArtifactId author) {
TransactionReadable transaction = getTransaction(transactions, localId);
- assertEquals(localId, transaction.getId());
+ assertEquals(localId, transaction);
assertEquals(type, transaction.getTxType());
assertNotNull(DATE_FORMATTER.format(transaction.getDate()));
assertEquals(comment, transaction.getComment());
@@ -488,18 +510,24 @@ public class OrcsTxQueryTest {
assertTrue(transaction.getCommitArt().isInvalid());
}
- private void assertTxExists(List<TransactionReadable> transactions, Long localId) {
- assertTrue(getTransaction(transactions, localId) != null);
+ private void assertTxExists(List<TransactionReadable> transactions, Long txId) {
+ assertTrue(getTransaction(transactions, txId) != null);
+ }
+
+ private void assertTxExists(List<TransactionReadable> transactions, TransactionId txId) {
+ assertTxExists(transactions, txId.getId());
}
- private static TransactionReadable getTransaction(List<TransactionReadable> transactions, Long localId) {
- TransactionReadable transaction = null;
+ private static TransactionReadable getTransaction(List<TransactionReadable> transactions, Long txId) {
for (TransactionReadable tx : transactions) {
- if (tx.getId().equals(localId)) {
- transaction = tx;
- break;
+ if (tx.getId().equals(txId)) {
+ return tx;
}
}
- return transaction;
+ return null;
+ }
+
+ private static TransactionReadable getTransaction(List<TransactionReadable> transactions, TransactionId txId) {
+ return getTransaction(transactions, txId.getId());
}
}
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
index 6f277d027cd..aea00abacd3 100644
--- 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
@@ -26,9 +26,7 @@ public interface TxQueryBuilder<T> {
T andTxId(TransactionId id);
- T andTxId(long... id) throws OseeCoreException;
-
- T andTxIds(Collection<Long> ids) throws OseeCoreException;
+ T andTxIds(Collection<TransactionId> ids);
T andTxId(Operator op, int id) throws OseeCoreException;

Back to the top