Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2017-01-20 19:11:59 +0000
committerDavid W. Miller2017-01-20 19:11:59 +0000
commit616bfff13fd3f0cc5fc2c8da147843e1b962209c (patch)
tree3cd8097beb4163e53be61068e3f409c86d74dab8 /plugins/org.eclipse.osee.orcs.db
parentd9b8a6add8dc50a17527df4a5ad19b02667fe499 (diff)
downloadorg.eclipse.osee-616bfff13fd3f0cc5fc2c8da147843e1b962209c.tar.gz
org.eclipse.osee-616bfff13fd3f0cc5fc2c8da147843e1b962209c.tar.xz
org.eclipse.osee-616bfff13fd3f0cc5fc2c8da147843e1b962209c.zip
refactor: Use AttributeId in purge attribute
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.db')
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/PurgeAttributesDatabaseTxCallable.java14
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/console/PurgeAttributeCommand.java5
2 files changed, 9 insertions, 10 deletions
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/PurgeAttributesDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/PurgeAttributesDatabaseTxCallable.java
index 75b84103046..ff1958c3e08 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/PurgeAttributesDatabaseTxCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/PurgeAttributesDatabaseTxCallable.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.db.internal.callable;
import java.util.Collection;
import org.eclipse.osee.console.admin.Console;
+import org.eclipse.osee.framework.core.data.AttributeId;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.jdbc.JdbcConnection;
@@ -27,10 +28,10 @@ public final class PurgeAttributesDatabaseTxCallable extends AbstractDatastoreTx
"select gamma_id from osee_attribute, osee_join_id where attr_id = id and query_id = ?";
private final SqlJoinFactory joinFactory;
- private final Collection<Long> idsToPurge;
+ private final Collection<AttributeId> idsToPurge;
private final Console console;
- public PurgeAttributesDatabaseTxCallable(Log logger, OrcsSession session, JdbcClient jdbcClient, SqlJoinFactory joinFactory, Collection<Long> idsToPurge, Console console) {
+ public PurgeAttributesDatabaseTxCallable(Log logger, OrcsSession session, JdbcClient jdbcClient, SqlJoinFactory joinFactory, Collection<AttributeId> idsToPurge, Console console) {
super(logger, session, jdbcClient);
this.joinFactory = joinFactory;
this.idsToPurge = idsToPurge;
@@ -40,14 +41,13 @@ public final class PurgeAttributesDatabaseTxCallable extends AbstractDatastoreTx
@Override
protected Void handleTxWork(JdbcConnection connection) throws OseeCoreException {
IdJoinQuery idJoin = joinFactory.createIdJoinQuery();
- JdbcStatement chStmt = getJdbcClient().getStatement(connection);
- try {
+ try (JdbcStatement chStmt = getJdbcClient().getStatement(connection)) {
OseePreparedStatement attrBatch =
getJdbcClient().getBatchStatement(connection, "delete from osee_attribute where attr_id = ?");
OseePreparedStatement txBatch =
getJdbcClient().getBatchStatement(connection, "delete from osee_txs where gamma_id = ?");
- for (Long id : idsToPurge) {
+ for (AttributeId id : idsToPurge) {
idJoin.add(id);
attrBatch.addToBatch(id);
}
@@ -68,7 +68,6 @@ public final class PurgeAttributesDatabaseTxCallable extends AbstractDatastoreTx
writeToConsole(deleted + " rows deleted.");
writeToConsole("Operation Finished");
} finally {
- chStmt.close();
idJoin.delete(connection);
}
return null;
@@ -79,5 +78,4 @@ public final class PurgeAttributesDatabaseTxCallable extends AbstractDatastoreTx
console.writeln(s);
}
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/console/PurgeAttributeCommand.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/console/PurgeAttributeCommand.java
index c55e5e2eaee..d517a62168e 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/console/PurgeAttributeCommand.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/console/PurgeAttributeCommand.java
@@ -15,6 +15,7 @@ import java.util.Set;
import java.util.concurrent.Callable;
import org.eclipse.osee.console.admin.Console;
import org.eclipse.osee.console.admin.ConsoleParameters;
+import org.eclipse.osee.framework.core.data.AttributeId;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.orcs.db.internal.callable.PurgeAttributesDatabaseTxCallable;
@@ -49,9 +50,9 @@ public class PurgeAttributeCommand extends AbstractDatastoreConsoleCommand {
@Override
public Callable<Void> createCallable(final Console console, final ConsoleParameters params) {
String[] attrIds = params.getArray("attr_id");
- Set<Long> longIds = new HashSet<>();
+ Set<AttributeId> longIds = new HashSet<>();
for (String id : attrIds) {
- longIds.add(Long.parseLong(id));
+ longIds.add(AttributeId.valueOf(id));
}
boolean force = params.getBoolean("force");

Back to the top