Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjphillips2011-06-02 18:28:50 +0000
committerRyan D. Brooks2011-06-02 18:28:50 +0000
commitb8963787d44b6164900308c18dd507fb1a940042 (patch)
treea6288659f977f8bd76ea7861202e86b58ab8a179 /plugins
parent8b7d51e5cabfc70416464b8cb894a6c8f9d24221 (diff)
downloadorg.eclipse.osee-b8963787d44b6164900308c18dd507fb1a940042.tar.gz
org.eclipse.osee-b8963787d44b6164900308c18dd507fb1a940042.tar.xz
org.eclipse.osee-b8963787d44b6164900308c18dd507fb1a940042.zip
refactor[ats_LKP2X]: Make change to support attribute purge
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AbstractPurgeTest.java98
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AttributePurgeTest.java79
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactPurgeTest.java68
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java49
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeAttribute.java102
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeAttributesBlam.java31
7 files changed, 363 insertions, 66 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java
index 73279e8956c..37b2f27721a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/FrameworkCore_Demo_Suite.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.framework.skynet.core.test;
import static org.junit.Assert.assertTrue;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
+import org.eclipse.osee.framework.skynet.core.test.artifact.AttributePurgeTest;
import org.eclipse.osee.framework.skynet.core.test.branch.BranchTestSuite;
import org.eclipse.osee.framework.skynet.core.test.cases.ArtifactLoaderTest;
import org.eclipse.osee.framework.skynet.core.test.cases.ArtifactPurgeTest;
@@ -56,6 +57,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
ReplaceWithAttributeTest.class,
+ AttributePurgeTest.class,
CrossBranchLinkTest.class,
UpdateBookmarkIdTest.class,
ArtifactEventFiltersTest.class,
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AbstractPurgeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AbstractPurgeTest.java
new file mode 100644
index 00000000000..da5fadb3bc0
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AbstractPurgeTest.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.framework.skynet.core.test.artifact;
+
+import static org.junit.Assert.assertFalse;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.logging.SevereLoggingMonitor;
+import org.eclipse.osee.framework.skynet.core.utility.DbUtil;
+import org.eclipse.osee.support.test.util.TestUtil;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+/**
+ * This test is intended to be run against a demo database. It tests the purge logic by counting the rows of the version
+ * and txs tables, creating artifacts, changing them and then purging them. If it works properly, all rows should be
+ * equal.
+ *
+ * @author Jeff C. Phillips
+ * @author Donald G. Dunne
+ */
+public abstract class AbstractPurgeTest {
+
+ private static SevereLoggingMonitor monitorLog;
+ protected Map<String, Integer> preCreateArtifactsCount;
+ protected Map<String, Integer> postCreateArtifactsCount;
+ protected Map<String, Integer> postPurgeCount;
+
+ @BeforeClass
+ public static void testInitialize() throws Exception {
+ monitorLog = TestUtil.severeLoggingStart();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ // This test should only be run on test db
+ assertFalse(TestUtil.isProductionDb());
+ preCreateArtifactsCount = new HashMap<String, Integer>();
+ postCreateArtifactsCount = new HashMap<String, Integer>();
+ postPurgeCount = new HashMap<String, Integer>();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (preCreateArtifactsCount != null) {
+ preCreateArtifactsCount.clear();
+ preCreateArtifactsCount = null;
+ }
+ if (postCreateArtifactsCount != null) {
+ postCreateArtifactsCount.clear();
+ postCreateArtifactsCount = null;
+ }
+ if (postPurgeCount != null) {
+ postPurgeCount.clear();
+ postPurgeCount = null;
+ }
+ }
+
+ @AfterClass
+ public static void testCleanup() throws Exception {
+ TestUtil.severeLoggingEnd(monitorLog);
+ }
+
+ @org.junit.Test
+ public void testPurge() throws Exception {
+ runPurgeOperation();
+
+ // TODO Looks like attributes created after initial artifact creation are not getting purged. Needs Fix.
+ TestUtil.checkThatEqual(preCreateArtifactsCount, postPurgeCount);
+ }
+
+ protected void getPreTableCount() throws OseeCoreException {
+ // Count rows in tables prior to purge
+ DbUtil.getTableRowCounts(preCreateArtifactsCount, getTables());
+ }
+
+ protected void getPostTableCount() throws OseeCoreException {
+ // Count rows and check that same as when began
+ DbUtil.getTableRowCounts(postPurgeCount, getTables());
+ }
+
+ public abstract void runPurgeOperation() throws OseeCoreException;
+
+ public abstract List<String> getTables();
+
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AttributePurgeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AttributePurgeTest.java
new file mode 100644
index 00000000000..74f7774a817
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/artifact/AttributePurgeTest.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.framework.skynet.core.test.artifact;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.framework.skynet.core.artifact.PurgeAttribute;
+import org.eclipse.osee.framework.skynet.core.test.util.FrameworkTestUtil;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.utility.DbUtil;
+import org.eclipse.osee.support.test.util.DemoSawBuilds;
+import org.eclipse.osee.support.test.util.TestUtil;
+
+/**
+ * This test is intended to be run against a demo database. It tests the purge logic by counting the rows of the version
+ * and txs tables, creating artifacts, changing them and then purging them. If it works properly, all rows should be
+ * equal.
+ *
+ * @author Jeff C. Phillips
+ */
+public class AttributePurgeTest extends AbstractPurgeTest {
+ private static final List<String> tables = Arrays.asList("osee_attribute", "osee_txs");
+
+ @Override
+ public void runPurgeOperation() throws OseeCoreException {
+ // Create some software artifacts
+ Branch branch = BranchManager.getBranch(DemoSawBuilds.SAW_Bld_2.getName());
+ SkynetTransaction transaction = new SkynetTransaction(branch, "Test purge artifacts");
+ Collection<Artifact> softArts =
+ FrameworkTestUtil.createSimpleArtifacts(CoreArtifactTypes.SoftwareRequirement, 10, getClass().getSimpleName(),
+ branch);
+ for (Artifact softArt : softArts) {
+ softArt.persist(transaction);
+ }
+ transaction.execute();
+
+ getPreTableCount();
+ // make more changes to artifacts
+ for (Artifact softArt : softArts) {
+ softArt.addAttribute(CoreAttributeTypes.StaticId, getClass().getSimpleName());
+ softArt.persist();
+ }
+
+ // Count rows and check that increased
+ DbUtil.getTableRowCounts(postCreateArtifactsCount, tables);
+ TestUtil.checkThatIncreased(preCreateArtifactsCount, postCreateArtifactsCount);
+
+ Set<Attribute<?>> attributesToPurge = new HashSet<Attribute<?>>();
+ for (Artifact softArt : softArts) {
+ attributesToPurge.addAll(softArt.getAttributes(CoreAttributeTypes.StaticId));
+ }
+ new PurgeAttribute(attributesToPurge).execute();
+
+ getPostTableCount();
+ }
+
+ @Override
+ public List<String> getTables() {
+ return tables;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactPurgeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactPurgeTest.java
index 1b7a5a4f8fa..751619e8085 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactPurgeTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactPurgeTest.java
@@ -10,28 +10,22 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.test.cases;
-import static org.junit.Assert.assertFalse;
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.logging.SevereLoggingMonitor;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.PurgeArtifacts;
+import org.eclipse.osee.framework.skynet.core.test.artifact.AbstractPurgeTest;
import org.eclipse.osee.framework.skynet.core.test.util.FrameworkTestUtil;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.utility.DbUtil;
import org.eclipse.osee.support.test.util.DemoSawBuilds;
import org.eclipse.osee.support.test.util.TestUtil;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
/**
* This test is intended to be run against a demo database. It tests the purge logic by counting the rows of the version
@@ -40,55 +34,14 @@ import org.junit.BeforeClass;
*
* @author Donald G. Dunne
*/
-public class ArtifactPurgeTest {
-
- private static SevereLoggingMonitor monitorLog;
- private Map<String, Integer> preCreateArtifactsCount;
- private Map<String, Integer> postCreateArtifactsCount;
- private Map<String, Integer> postPurgeCount;
-
+public class ArtifactPurgeTest extends AbstractPurgeTest {
private static final List<String> tables = Arrays.asList("osee_attribute", "osee_artifact", "osee_relation_link",
"osee_tx_details", "osee_txs");
- @BeforeClass
- public static void testInitialize() throws Exception {
- monitorLog = TestUtil.severeLoggingStart();
- }
-
- @Before
- public void setUp() throws Exception {
- // This test should only be run on test db
- assertFalse(TestUtil.isProductionDb());
- preCreateArtifactsCount = new HashMap<String, Integer>();
- postCreateArtifactsCount = new HashMap<String, Integer>();
- postPurgeCount = new HashMap<String, Integer>();
- }
-
- @After
- public void tearDown() throws Exception {
- if (preCreateArtifactsCount != null) {
- preCreateArtifactsCount.clear();
- preCreateArtifactsCount = null;
- }
- if (postCreateArtifactsCount != null) {
- postCreateArtifactsCount.clear();
- postCreateArtifactsCount = null;
- }
- if (postPurgeCount != null) {
- postPurgeCount.clear();
- postPurgeCount = null;
- }
- }
-
- @AfterClass
- public static void testCleanup() throws Exception {
- TestUtil.severeLoggingEnd(monitorLog);
- }
-
- @org.junit.Test
- public void testPurgeArtifacts() throws Exception {
+ @Override
+ public void runPurgeOperation() throws OseeCoreException {
// Count rows in tables prior to purge
- DbUtil.getTableRowCounts(preCreateArtifactsCount, tables);
+ getPostTableCount();
// Create some software artifacts
Branch branch = BranchManager.getBranch(DemoSawBuilds.SAW_Bld_2.getName());
@@ -108,16 +61,21 @@ public class ArtifactPurgeTest {
}
// Count rows and check that increased
- DbUtil.getTableRowCounts(postCreateArtifactsCount, tables);
+ DbUtil.getTableRowCounts(postCreateArtifactsCount, getTables());
TestUtil.checkThatIncreased(preCreateArtifactsCount, postCreateArtifactsCount);
new PurgeArtifacts(softArts).execute();
// Count rows and check that same as when began
- DbUtil.getTableRowCounts(postPurgeCount, tables);
+ getPostTableCount();
// TODO Looks like attributes created after initial artifact creation are not getting purged. Needs Fix.
TestUtil.checkThatEqual(preCreateArtifactsCount, postPurgeCount);
}
+ @Override
+ public List<String> getTables() {
+ return tables;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java
index 47e26d3fb07..e8114157590 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java
@@ -28,6 +28,9 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.IdJoinQuery;
+import org.eclipse.osee.framework.database.core.JoinUtility;
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;
@@ -182,6 +185,8 @@ public class ChangeArtifactType {
for (Attribute<?> attribute : attributesToPurge) {
attribute.purge();
}
+ purgeAttributes();
+
for (RelationLink relation : relationsToDelete) {
relation.delete(true);
}
@@ -202,4 +207,48 @@ public class ChangeArtifactType {
}
return true;
}
+
+ private static void purgeAttributes() throws OseeCoreException {
+ IdJoinQuery txsJoin = populateTxsJoinTable();
+
+ try {
+ String delete_txs =
+ "DELETE FROM osee_txs txs1 WHERE EXISTS (select 1 from osee_join_id jt1 WHERE jt1.query_id = ? AND jt1.id = txs1.gamma_id)";
+ String delete_attr =
+ "DELETE FROM osee_attribute attr1 WHERE EXISTS (select 1 from osee_join_id jt1 WHERE jt1.query_id = ? AND jt1.id = attr1.gamma_id)";
+ ConnectionHandler.runPreparedUpdate(delete_txs, txsJoin.getQueryId());
+ ConnectionHandler.runPreparedUpdate(delete_attr, txsJoin.getQueryId());
+ } finally {
+ txsJoin.delete();
+ }
+ }
+
+ private static IdJoinQuery populateTxsJoinTable() throws OseeDataStoreException, OseeCoreException {
+ IdJoinQuery attributeJoin = JoinUtility.createIdJoinQuery();
+
+ for (Attribute<?> attribute : attributesToPurge) {
+ attributeJoin.add(attribute.getId());
+ }
+
+ IdJoinQuery txsJoin = JoinUtility.createIdJoinQuery();
+ try {
+ attributeJoin.store();
+ IOseeStatement chStmt = ConnectionHandler.getStatement();
+ String selectAttrGammas =
+ "select gamma_id from osee_attribute t1, osee_join_id t2 where t1.attr_id = t2.id and t2.query_id = ?";
+
+ try {
+ chStmt.runPreparedQuery(10000, selectAttrGammas, attributeJoin.getQueryId());
+ while (chStmt.next()) {
+ txsJoin.add(chStmt.getInt("gamma_id"));
+ }
+ txsJoin.store();
+ } finally {
+ chStmt.close();
+ }
+ } finally {
+ attributeJoin.delete();
+ }
+ return txsJoin;
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeAttribute.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeAttribute.java
new file mode 100644
index 00000000000..d5f03501abd
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeAttribute.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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.framework.skynet.core.artifact;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.DbTransaction;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.IdJoinQuery;
+import org.eclipse.osee.framework.database.core.JoinUtility;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+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;
+import org.eclipse.osee.framework.skynet.core.event.model.EventModType;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class PurgeAttribute extends DbTransaction {
+ private static final String DELETE_TXS =
+ "DELETE FROM osee_txs txs1 WHERE EXISTS (select 1 from osee_join_id jt1 WHERE jt1.query_id = ? AND jt1.id = txs1.gamma_id)";
+ private static final String DELETE_ATTR =
+ "DELETE FROM osee_attribute attr1 WHERE EXISTS (select 1 from osee_join_id jt1 WHERE jt1.query_id = ? AND jt1.id = attr1.gamma_id)";
+ private static final String SELECT_ATTR_GAMMAS =
+ "select gamma_id from osee_attribute t1, osee_join_id t2 where t1.attr_id = t2.id and t2.query_id = ?";
+
+ private final Collection<Attribute<?>> attributesToPurge;
+ private boolean success;
+
+ public PurgeAttribute(Collection<Attribute<?>> attributesToPurge) {
+ this.attributesToPurge = attributesToPurge;
+ }
+
+ @Override
+ protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
+ IdJoinQuery txsJoin = populateTxsJoinTable();
+
+ try {
+ ConnectionHandler.runPreparedUpdate(connection, DELETE_TXS, txsJoin.getQueryId());
+ ConnectionHandler.runPreparedUpdate(connection, DELETE_ATTR, txsJoin.getQueryId());
+ success = true;
+ } finally {
+ txsJoin.delete();
+ }
+ }
+
+ private IdJoinQuery populateTxsJoinTable() throws OseeDataStoreException, OseeCoreException {
+ IdJoinQuery attributeJoin = JoinUtility.createIdJoinQuery();
+
+ for (Attribute<?> attribute : attributesToPurge) {
+ attributeJoin.add(attribute.getId());
+ }
+
+ IdJoinQuery txsJoin = JoinUtility.createIdJoinQuery();
+ try {
+ attributeJoin.store();
+ IOseeStatement chStmt = ConnectionHandler.getStatement();
+
+ try {
+ chStmt.runPreparedQuery(10000, SELECT_ATTR_GAMMAS, attributeJoin.getQueryId());
+ while (chStmt.next()) {
+ txsJoin.add(chStmt.getInt("gamma_id"));
+ }
+ txsJoin.store();
+ } finally {
+ chStmt.close();
+ }
+ } finally {
+ attributeJoin.delete();
+ }
+ return txsJoin;
+ }
+
+ @Override
+ protected void handleTxFinally() throws OseeCoreException {
+ if (success) {
+ Set<EventBasicGuidArtifact> artifactChanges = new HashSet<EventBasicGuidArtifact>();
+ for (Attribute<?> attribute : attributesToPurge) {
+ artifactChanges.add(new EventBasicGuidArtifact(EventModType.Purged, attribute.getArtifact()));
+ }
+ // Kick Local and Remote Events
+ ArtifactEvent artifactEvent = new ArtifactEvent(attributesToPurge.iterator().next().getArtifact().getBranch());
+ for (EventBasicGuidArtifact guidArt : artifactChanges) {
+ artifactEvent.getArtifacts().add(guidArt);
+ }
+ OseeEventManager.kickPersistEvent(PurgeAttribute.class, artifactEvent);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeAttributesBlam.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeAttributesBlam.java
index 17790d433d8..59f972c3016 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeAttributesBlam.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeAttributesBlam.java
@@ -10,23 +10,26 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.blam.operation;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.plugin.core.util.AIFile;
import org.eclipse.osee.framework.plugin.core.util.OseeData;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
+import org.eclipse.osee.framework.skynet.core.artifact.PurgeAttribute;
import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
import org.eclipse.swt.program.Program;
/**
- * @author Jeff C> Phillips
+ * @author Jeff C. Phillips
*/
public class PurgeAttributesBlam extends AbstractBlam {
@Override
@@ -42,21 +45,27 @@ public class PurgeAttributesBlam extends AbstractBlam {
List<Artifact> artifacts = variableMap.getArtifacts("artifacts");
StringBuilder strB = new StringBuilder();
+ List<Attribute<?>> attributesToPurge = new ArrayList<Attribute<?>>();
for (Artifact artifact : artifacts) {
- for (AttributeType attributeType : purgeAttributeTypes) {
- for (Attribute<?> attribute : artifact.getAllAttributesIncludingHardDeleted(attributeType)) {
-
- strB.append(attribute.getAttributeType());
- strB.append(";");
- strB.append(artifact.getArtId());
- strB.append(";");
- strB.append(attribute.getDisplayableString());
- strB.append("\n");
- attribute.purge();
+ for (IAttributeType attributeType : purgeAttributeTypes) {
+ //if attribute type is invalid purge them
+ if (!artifact.isAttributeTypeValid(attributeType)) {
+ for (Attribute<?> attribute : artifact.getAllAttributesIncludingHardDeleted(attributeType)) {
+ strB.append(attribute.getAttributeType());
+ strB.append(";");
+ strB.append(artifact.getArtId());
+ strB.append(";");
+ strB.append(attribute.getDisplayableString());
+ strB.append("\n");
+ attribute.purge();
+ attributesToPurge.add(attribute);
+ }
}
}
+ artifact.persist();
+ new PurgeAttribute(attributesToPurge).execute();
}
IFile iFile = OseeData.getIFile("Purge Attributes" + Lib.getDateTimeString() + ".txt");

Back to the top