Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2011-09-02 18:46:17 +0000
committerRyan D. Brooks2011-09-02 18:46:17 +0000
commit7fd396480adc65a36e6ad3ace2e1e42446f891d8 (patch)
tree3f587d90fdc8c01dce1b6321a003fc107621e4bf /plugins
parent77d3dd21d27a2c698f58492af706c790c78d6c05 (diff)
downloadorg.eclipse.osee-7fd396480adc65a36e6ad3ace2e1e42446f891d8.tar.gz
org.eclipse.osee-7fd396480adc65a36e6ad3ace2e1e42446f891d8.tar.xz
org.eclipse.osee-7fd396480adc65a36e6ad3ace2e1e42446f891d8.zip
refactor: Update PurgeArtifacts for schema change
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/AtsPurgeTest.java9
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml1
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java39
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/menu/GlobalMenu.java18
4 files changed, 30 insertions, 37 deletions
diff --git a/plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/AtsPurgeTest.java b/plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/AtsPurgeTest.java
index 0cadd9c5f6c..0560bf1c25e 100644
--- a/plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/AtsPurgeTest.java
+++ b/plugins/org.eclipse.osee.ats.test/src/org/eclipse/osee/ats/util/AtsPurgeTest.java
@@ -23,7 +23,10 @@ import org.eclipse.osee.ats.core.config.ActionableItemArtifact;
import org.eclipse.osee.ats.core.task.TaskArtifact;
import org.eclipse.osee.ats.core.type.AtsArtifactTypes;
import org.eclipse.osee.ats.core.workflow.ChangeType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.operation.NullOperationLogger;
import org.eclipse.osee.framework.core.operation.Operations;
+import org.eclipse.osee.framework.database.operation.PurgeUnusedBackingDataAndTransactions;
import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.PurgeArtifacts;
@@ -57,6 +60,7 @@ public class AtsPurgeTest {
@org.junit.Test
public void testPurgeArtifacts() throws Exception {
// Count rows in tables prior to purge
+ txPrune();
DbTestUtil.getTableRowCounts(preCreateActionCount, tables);
Set<Artifact> artsToPurge = new HashSet<Artifact>();
@@ -98,8 +102,13 @@ public class AtsPurgeTest {
Operations.executeWorkAndCheckStatus(new PurgeArtifacts(artsToPurge));
// Count rows and check that same as when began
+ txPrune();
DbTestUtil.getTableRowCounts(postPurgeCount, tables);
TestUtil.checkThatEqual(preCreateActionCount, postPurgeCount);
}
+ private void txPrune() throws OseeCoreException {
+ Operations.executeWorkAndCheckStatus(new PurgeUnusedBackingDataAndTransactions(NullOperationLogger.getSingleton()));
+ }
+
}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml b/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml
index 92af25d6d43..1a159300cc4 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml
+++ b/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml
@@ -638,6 +638,7 @@
<Column id="TRANSACTION_ID" defaultValue="not null" type="INTEGER" />
<Column id="GAMMA_ID" defaultValue="not null" type="BIGINT" />
<Column id="INSERT_TIME" defaultValue="not null" type="TIMESTAMP" />
+ <Column id="BRANCH_ID" type="INTEGER" />
<Index id="OSEE_JOIN_TRANSACTION_Q_IDX" tablespace="osee_index">
<AppliesTo id="QUERY_ID"/>
</Index>
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java
index 0b2a83fb78f..1a30476f594 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java
@@ -16,7 +16,6 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.logging.Level;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -28,7 +27,6 @@ import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.database.core.SQL3DataType;
import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
-import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent;
import org.eclipse.osee.framework.skynet.core.event.model.EventBasicGuidArtifact;
@@ -42,19 +40,13 @@ import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
public class PurgeArtifacts extends AbstractDbTxOperation {
private static final String INSERT_SELECT_ITEM =
- "INSERT INTO osee_join_transaction (query_id, insert_time, gamma_id, transaction_id) SELECT /*+ ordered FIRST_ROWS */ ?, ?, txs.gamma_id, txs.transaction_id FROM osee_join_artifact aj, %s item, osee_txs txs WHERE aj.query_id = ? AND %s AND item.gamma_id = txs.gamma_id AND aj.branch_id = txs.branch_id";
+ "INSERT INTO osee_join_transaction (query_id, insert_time, gamma_id, transaction_id, branch_id) SELECT /*+ ordered */ ?, ?, txs.gamma_id, txs.transaction_id, aj.branch_id FROM osee_join_artifact aj, %s item, osee_txs txs WHERE aj.query_id = ? AND %s AND item.gamma_id = txs.gamma_id AND aj.branch_id = txs.branch_id";
private static final String COUNT_ARTIFACT_VIOLATIONS =
"SELECT art.art_id, txs.branch_id FROM osee_join_artifact aj, osee_artifact art, osee_txs txs WHERE aj.query_id = ? AND aj.art_id = art.art_id AND art.gamma_id = txs.gamma_id AND txs.branch_id = aj.branch_id";
private static final String DELETE_FROM_TXS_USING_JOIN_TRANSACTION =
- "DELETE FROM osee_txs txs1 WHERE EXISTS ( select 1 from osee_join_transaction jt1 WHERE jt1.query_id = ? AND jt1.transaction_id = txs1.transaction_id AND jt1.gamma_id = txs1.gamma_id)";
+ "DELETE FROM osee_txs txs WHERE EXISTS (select 1 from osee_join_transaction jt WHERE jt.query_id = ? AND jt.branch_id = txs.branch_id AND jt.gamma_id = txs.gamma_id AND jt.transaction_id = txs.transaction_id)";
private static final String DELETE_FROM_TX_DETAILS_USING_JOIN_TRANSACTION =
- "DELETE FROM osee_tx_details txd1 WHERE EXISTS ( select 1 from osee_join_transaction jt1 WHERE jt1.query_id = ? AND jt1.transaction_id = txd1.transaction_id AND not exists ( select * from osee_txs txs1 where txs1.transaction_id = jt1.transaction_id))";
- private static final String DELETE_FROM_RELATION_VERSIONS =
- "DELETE FROM osee_relation_link rel1 WHERE EXISTS ( select * from osee_join_transaction jt1 WHERE jt1.query_id = ? AND jt1.gamma_id = rel1.gamma_id AND not exists ( select * from osee_txs txs1 where txs1.gamma_id = jt1.gamma_id))";
- private static final String DELETE_FROM_ATTRIBUTE_VERSIONS =
- "DELETE FROM osee_attribute attr1 WHERE EXISTS ( select * from osee_join_transaction jt1 WHERE jt1.query_id = ? AND jt1.gamma_id = attr1.gamma_id AND not exists ( select * from osee_txs txs1 where txs1.gamma_id = jt1.gamma_id))";
- private static final String DELETE_FROM_ARTIFACT_VERSIONS =
- "DELETE FROM osee_artifact art WHERE EXISTS ( select * from osee_join_transaction jt1 WHERE jt1.query_id = ? AND jt1.gamma_id = art.gamma_id AND not exists ( select * from osee_txs txs1 where txs1.gamma_id = jt1.gamma_id))";
+ "DELETE FROM osee_tx_details txd WHERE EXISTS (select 1 from osee_join_transaction jt WHERE jt.query_id = ? AND jt.branch_id = txd.branch_id AND jt.transaction_id = txd.transaction_id AND not exists (select * from osee_txs txs where jt.branch_id = txs.branch_id and jt.transaction_id = txs.transaction_id))";
private final Collection<? extends Artifact> artifactsToPurge;
private boolean success;
@@ -138,27 +130,10 @@ public class PurgeArtifacts extends AbstractDbTxOperation {
insertSelectItems(connection, "osee_artifact", "aj.art_id = item.art_id", transactionJoinId, insertTime,
queryId);
- int txsDeletes =
- ConnectionHandler.runPreparedUpdate(connection, DELETE_FROM_TXS_USING_JOIN_TRANSACTION, transactionJoinId);
-
- int txDetails =
- ConnectionHandler.runPreparedUpdate(connection, DELETE_FROM_TX_DETAILS_USING_JOIN_TRANSACTION,
- transactionJoinId);
-
- int relationVersions =
- ConnectionHandler.runPreparedUpdate(connection, DELETE_FROM_RELATION_VERSIONS, transactionJoinId);
- int attributeVersions =
- ConnectionHandler.runPreparedUpdate(connection, DELETE_FROM_ATTRIBUTE_VERSIONS, transactionJoinId);
- int artifactVersions =
- ConnectionHandler.runPreparedUpdate(connection, DELETE_FROM_ARTIFACT_VERSIONS, transactionJoinId);
-
- OseeLog.logf(
- Activator.class,
- Level.FINE,
-
- "Purge Row Deletes: txs rows [%d], rel ver rows [%d], attr ver rows [%d] art ver rows [%d]. txs vs. total versions [%d vs %d]",
- txsDeletes, relationVersions, attributeVersions, artifactVersions, txDetails,
- (relationVersions + attributeVersions + artifactVersions));
+ ConnectionHandler.runPreparedUpdate(connection, DELETE_FROM_TXS_USING_JOIN_TRANSACTION, transactionJoinId);
+
+ ConnectionHandler.runPreparedUpdate(connection, DELETE_FROM_TX_DETAILS_USING_JOIN_TRANSACTION,
+ transactionJoinId);
ConnectionHandler.runPreparedUpdate(connection, "DELETE FROM osee_join_transaction where query_id = ?",
transactionJoinId);
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/menu/GlobalMenu.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/menu/GlobalMenu.java
index 171cf5a002e..a3392f683a8 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/menu/GlobalMenu.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/menu/GlobalMenu.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.framework.ui.skynet.menu;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.LinkedHashSet;
import java.util.logging.Level;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -24,12 +25,14 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.window.Window;
import org.eclipse.osee.framework.access.AccessControlManager;
+import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.plugin.core.util.Jobs;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactPersistenceManager;
+import org.eclipse.osee.framework.skynet.core.artifact.PurgeArtifacts;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
@@ -196,8 +199,7 @@ public class GlobalMenu {
for (GlobalMenuListener listener : listeners) {
Result result = listener.actioning(GlobalMenuItem.PurgeArtifacts, artifactsToBePurged);
if (result.isFalse()) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.OK, result.getText(),
- null);
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.OK, result.getText(), null);
}
}
} catch (Exception ex) {
@@ -206,13 +208,19 @@ public class GlobalMenu {
monitor.beginTask("Purge artifact", artifactsToBePurged.size());
try {
+ boolean recurseChildren = dialog.getToggleState();
+ Collection<Artifact> toPurge = new LinkedHashSet<Artifact>();
for (Artifact artifactToPurge : artifactsToBePurged) {
if (!artifactToPurge.isDeleted()) {
- monitor.setTaskName("Purge: " + artifactToPurge.getName());
- artifactToPurge.purgeFromBranch(dialog.getToggleState());
+ toPurge.add(artifactToPurge);
+ if (recurseChildren) {
+ toPurge.addAll(artifactToPurge.getDescendants());
+ }
}
- monitor.worked(1);
}
+ monitor.setTaskName("Purging " + toPurge.size() + " artifacts");
+ Operations.executeWorkAndCheckStatus(new PurgeArtifacts(toPurge));
+ monitor.worked(toPurge.size());
toReturn = Status.OK_STATUS;
} catch (Exception ex) {
OseeLog.log(Activator.class, Level.SEVERE, ex);

Back to the top