summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2011-04-18 17:34:21 (EDT)
committer Ryan D. Brooks2011-04-18 17:34:21 (EDT)
commitf43c310d2216926f40dfc034fc9f242017dd3361 (patch)
tree4ba4a9672c097d69e0209fde11b8892f36535d20
parentee8cc6fe11b451b56cf4ac181ddc2418be38db8d (diff)
downloadorg.eclipse.osee-f43c310d2216926f40dfc034fc9f242017dd3361.zip
org.eclipse.osee-f43c310d2216926f40dfc034fc9f242017dd3361.tar.gz
org.eclipse.osee-f43c310d2216926f40dfc034fc9f242017dd3361.tar.bz2
refactor[ats_PRNVV]: Fix with test database relation integrity health checks
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/internal/OseeBranchService.java1
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/SecureOseeHttpServlet.java1
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ConflictManagerInternal.java2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteConfigurationTest.java12
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/dbHealth/RelationIntegrityCheckTest.java148
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/DatabaseHealth.java10
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dbHealth/RelationIntegrityCheck.java135
7 files changed, 259 insertions, 50 deletions
diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/internal/OseeBranchService.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/internal/OseeBranchService.java
index 2381775..36f2eb0 100644
--- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/internal/OseeBranchService.java
+++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/internal/OseeBranchService.java
@@ -66,7 +66,6 @@ public class OseeBranchService implements IOseeBranchService {
private final IOseeModelFactoryServiceProvider modelFactory;
public OseeBranchService(IOseeDatabaseServiceProvider oseeDatabaseProvider, IOseeCachingServiceProvider cachingService, IOseeModelFactoryServiceProvider modelFactory) {
- super();
this.oseeDatabaseProvider = oseeDatabaseProvider;
this.cachingService = cachingService;
this.modelFactory = modelFactory;
diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/SecureOseeHttpServlet.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/SecureOseeHttpServlet.java
index 52e0647..26f5daa 100644
--- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/SecureOseeHttpServlet.java
+++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/SecureOseeHttpServlet.java
@@ -23,7 +23,6 @@ public class SecureOseeHttpServlet extends OseeHttpServlet {
private final ISessionManager sessionManager;
public SecureOseeHttpServlet(ISessionManager sessionManager) {
- super();
this.sessionManager = sessionManager;
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ConflictManagerInternal.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ConflictManagerInternal.java
index 0253813..5c0e01a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ConflictManagerInternal.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ConflictManagerInternal.java
@@ -392,7 +392,7 @@ public class ConflictManagerInternal {
}
}
for (Branch branch : sourceBranches) {
- if (branch.getParentBranch().equals(commonBranch)) {
+ if (commonBranch.equals(branch.getParentBranch())) {
sourceTransaction = branch.getBaseTransaction();
break;
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteConfigurationTest.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteConfigurationTest.java
index f2ea705..319f739 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteConfigurationTest.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteConfigurationTest.java
@@ -24,27 +24,27 @@ public class ArtifactPasteConfigurationTest {
@Test
public void testConstruction() {
ArtifactPasteConfiguration config = new ArtifactPasteConfiguration();
- Assert.assertEquals(false, config.isIncludeChildrenOfCopiedElements());
- Assert.assertEquals(true, config.isKeepRelationOrderSettings());
+ Assert.assertFalse(config.isIncludeChildrenOfCopiedElements());
+ Assert.assertTrue(config.isKeepRelationOrderSettings());
}
@Test
public void testSetIncludeChildren() {
ArtifactPasteConfiguration config = new ArtifactPasteConfiguration();
config.setIncludeChildrenOfCopiedElements(true);
- Assert.assertEquals(true, config.isIncludeChildrenOfCopiedElements());
+ Assert.assertTrue(config.isIncludeChildrenOfCopiedElements());
config.setIncludeChildrenOfCopiedElements(false);
- Assert.assertEquals(false, config.isIncludeChildrenOfCopiedElements());
+ Assert.assertFalse(config.isIncludeChildrenOfCopiedElements());
}
@Test
public void testSetKeepRelationOrder() {
ArtifactPasteConfiguration config = new ArtifactPasteConfiguration();
config.setKeepRelationOrderSettings(true);
- Assert.assertEquals(true, config.isKeepRelationOrderSettings());
+ Assert.assertTrue(config.isKeepRelationOrderSettings());
config.setKeepRelationOrderSettings(false);
- Assert.assertEquals(false, config.isKeepRelationOrderSettings());
+ Assert.assertFalse(config.isKeepRelationOrderSettings());
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/dbHealth/RelationIntegrityCheckTest.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/dbHealth/RelationIntegrityCheckTest.java
new file mode 100644
index 0000000..7fb7977
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/dbHealth/RelationIntegrityCheckTest.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.ui.skynet.test.dbHealth;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.data.SystemUser;
+import org.eclipse.osee.framework.core.data.TokenFactory;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.jdk.core.type.DoubleKeyHashMap;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+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.ArtifactTypeManager;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.conflict.ConflictManagerExternal;
+import org.eclipse.osee.framework.ui.skynet.dbHealth.RelationIntegrityCheck;
+import org.eclipse.osee.framework.ui.skynet.dbHealth.RelationIntegrityCheck.LocalRelationLink;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * {@link RelationIntegrityCheck}
+ * <p>
+ * Tests data integrity case where a new relation is persisted on a deleted artifact. Checks that if the situation
+ * exists, applyFix can resolve the issue.
+ * </p>
+ *
+ * @author Karol M. Wilk
+ */
+public class RelationIntegrityCheckTest {
+
+ private final DoubleKeyHashMap<Integer, Integer, LocalRelationLink> map =
+ new DoubleKeyHashMap<Integer, Integer, LocalRelationLink>();
+ private Branch parentBranch;
+ private Branch workingBranch;
+
+ @Test
+ public void testNewRelationOnDeletedArtifact() throws Exception {
+ runQuery(RelationIntegrityCheck.DELETED_A_ARTIFACTS);
+ runQuery(RelationIntegrityCheck.DELETED_B_ARTIFACTS);
+
+ applyFix();
+
+ Assert.assertTrue(checkIfAllFixed());
+ }
+
+ private boolean checkIfAllFixed() throws OseeCoreException {
+ map.clear();
+ runQuery(RelationIntegrityCheck.DELETED_A_ARTIFACTS);
+ runQuery(RelationIntegrityCheck.DELETED_B_ARTIFACTS);
+ return map.isEmpty();
+ }
+
+ private void applyFix() throws OseeCoreException {
+ List<Object[]> rowsToDelete = new LinkedList<Object[]>();
+ for (LocalRelationLink relLink : map.allValues()) {
+ rowsToDelete.add(new Object[] {relLink.gammaId, relLink.relTransId, relLink.branchId});
+ }
+
+ if (!rowsToDelete.isEmpty()) {
+ ConnectionHandler.runBatchUpdate(RelationIntegrityCheck.DEL_FROM_TXS_W_SPEC_BRANCH_ID, rowsToDelete);
+ }
+ }
+
+ private void runQuery(String sqlQuery) throws OseeDataStoreException, OseeCoreException {
+ IOseeStatement chStmt = ConnectionHandler.getStatement();
+ try {
+ chStmt.runPreparedQuery(sqlQuery);
+ while (chStmt.next()) {
+ //@formatter:off
+ int gammaId = chStmt.getInt("gamma_id");
+ int transactionId = chStmt.getInt("transaction_id");
+ int relationId = chStmt.getInt("rel_link_id");
+ int branchId = chStmt.getInt("branch_id");
+ int a_sideArtifactId = chStmt.getInt("a_art_id");
+ int b_sideArtifactId = chStmt.getInt("b_art_id");
+ int deletedTransaction = chStmt.getInt("deleted_tran");
+
+ int commitTransId = chStmt.getInt("commit_trans_art_id");
+ int modType = chStmt.getInt("creating_trans_mod_type");
+ //@formatter:on
+
+ if (!map.containsKey(gammaId, transactionId)) {
+ if (commitTransId > 0 && modType == 1) {
+ map.put(gammaId, transactionId, new LocalRelationLink(relationId, gammaId, transactionId, branchId,
+ a_sideArtifactId, b_sideArtifactId, deletedTransaction, commitTransId, modType));
+ }
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+
+ parentBranch = BranchManager.createTopLevelBranch("1");
+
+ Artifact art_A = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, parentBranch, "A");
+ art_A.persist();
+ BranchManager.persist(parentBranch);
+
+ workingBranch =
+ BranchManager.createWorkingBranch(parentBranch, TokenFactory.createBranch(GUID.create(), "2"),
+ UserManager.getUser(SystemUser.OseeSystem));
+
+ art_A.deleteAndPersist();
+
+ Artifact art_A_prime = ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.Folder, "A", workingBranch);
+ //Sample artifact to create a relation to...
+ Artifact child = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, workingBranch, "Child");
+
+ //cause a change on the branch
+ art_A_prime.persist();
+
+ //create a new relation on A' to child
+ art_A_prime.addChild(child);
+ art_A_prime.persist();
+
+ //commit branch 2 into 1
+ ConflictManagerExternal conflictManager = new ConflictManagerExternal(parentBranch, workingBranch);
+ BranchManager.commitBranch(null, conflictManager, false, true);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ BranchManager.purgeBranch(Arrays.asList(workingBranch, parentBranch));
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/DatabaseHealth.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/DatabaseHealth.java
index f9ba776..2ba4e434 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/DatabaseHealth.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/DatabaseHealth.java
@@ -77,24 +77,24 @@ public class DatabaseHealth extends AbstractBlam {
builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\" \"/>");
builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Select Verification Operations to Run:\"/>");
for (DatabaseHealthOperation healthOp : DatabaseHealthOpsExtensionManager.getVerifyOperations()) {
- builder.append(getOperationsCheckBoxes(healthOp, false));
+ builder.append(getOperationsCheckBoxes(healthOp.getVerifyTaskName(), healthOp.getCheckDescription()));
}
builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\" \"/>");
builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Select Clean Up Operations to Run:\"/>");
for (DatabaseHealthOperation fixOp : DatabaseHealthOpsExtensionManager.getFixOperations()) {
- builder.append(getOperationsCheckBoxes(fixOp, true));
+ builder.append(getOperationsCheckBoxes(fixOp.getFixTaskName(), fixOp.getFixDescription()));
}
builder.append("</xWidgets>");
return builder.toString();
}
- private String getOperationsCheckBoxes(DatabaseHealthOperation fixOp, boolean fix) {
+ private String getOperationsCheckBoxes(String taskName, String description) {
StringBuilder builder = new StringBuilder();
builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"");
- builder.append(fix ? fixOp.getFixTaskName() : fixOp.getVerifyTaskName());
- String toolTip = AXml.textToXml((fix ? fixOp.getFixDescription() : fixOp.getCheckDescription()));
+ builder.append(taskName);
+ String toolTip = AXml.textToXml(description);
builder.append("\" labelAfter=\"true\" horizontalLabel=\"true\" toolTip=\"" + toolTip + "\"/>");
return builder.toString();
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dbHealth/RelationIntegrityCheck.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dbHealth/RelationIntegrityCheck.java
index 1c178b1..8a50c9f 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dbHealth/RelationIntegrityCheck.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dbHealth/RelationIntegrityCheck.java
@@ -26,20 +26,16 @@ import org.eclipse.osee.framework.ui.skynet.results.XResultData;
import org.eclipse.osee.framework.ui.skynet.results.html.XResultPage.Manipulations;
/**
+ * {@link RelationIntegrityCheckTest }
+ *
* @author Theron Virgin
*/
public class RelationIntegrityCheck extends DatabaseHealthOperation {
- private static class LocalRelationLink {
- public int relLinkId;
- public int gammaId;
- public int relTransId;
- public int branchId;
- public int aArtId;
- public int bArtId;
- public int transIdForArtifactDeletion;
-
- public LocalRelationLink(int relLinkId, int gammaId, int transactionId, int branchId, int aArtId, int bArtId, int transIdForArtifactDeletion) {
- super();
+ public static class LocalRelationLink {
+ public int relLinkId, gammaId, relTransId, branchId, aArtId, bArtId, transIdForArtifactDeletion, commitTrans,
+ modType;
+
+ public LocalRelationLink(int relLinkId, int gammaId, int transactionId, int branchId, int aArtId, int bArtId, int transIdForArtifactDeletion, int commitTrans, int modType) {
this.aArtId = aArtId;
this.bArtId = bArtId;
this.branchId = branchId;
@@ -47,26 +43,63 @@ public class RelationIntegrityCheck extends DatabaseHealthOperation {
this.relLinkId = relLinkId;
this.relTransId = transactionId;
this.transIdForArtifactDeletion = transIdForArtifactDeletion;
+ this.commitTrans = commitTrans;
+ this.modType = modType;
}
- }
+ @Override
+ public String toString() {
+ //System.out.println("gamma_id \t transaction_id \t rel_link_id \t branch_d \t a_art_id \t b_art_id \t deleted_tran \t commit trans \t commit trans mod type");
+ return String.format("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s", gammaId, relTransId, relLinkId, branchId, aArtId,
+ bArtId, transIdForArtifactDeletion, commitTrans, modType);
+ }
+ }
+ //@formatter:off
+ private static final String DELETED_ARTIFACTS_QUERY =
+ " SELECT " +
+ " tx1.gamma_id, " +
+ " tx1.transaction_id, " +
+ " tx1.branch_id, " +
+ " rel1.rel_link_id, " +
+ " rel1.a_art_id, " +
+ " rel1.b_art_id, " +
+ " tx2.transaction_id AS deleted_tran, " +
+ " txd.commit_art_id AS commit_trans_art_id, " +
+ " tx1.mod_type AS creating_trans_mod_type " +
+ " FROM " +
+ " osee_txs tx1, " +
+ " osee_txs tx2, " +
+ " osee_relation_link rel1, " +
+ " osee_artifact av1, " +
+ " osee_tx_details txd " +
+ " WHERE " +
+ " tx1.branch_id = tx2.branch_id AND " +
+ " tx1.tx_current = " + TxChange.CURRENT.getValue() + " AND " +
+ " tx2.tx_current = " + TxChange.DELETED.getValue() + " AND " +
+ " tx1.gamma_id = rel1.gamma_id AND " +
+ " tx2.gamma_id = av1.gamma_id AND " +
+ " av1.art_id = rel1.%s AND " +
+ " tx1.transaction_id = txd.transaction_id ";
+ //@formatter:on
+
+ // relations that reference deleted artifacts on side A
+ public static final String DELETED_A_ARTIFACTS = String.format(DELETED_ARTIFACTS_QUERY, "a_art_id");
+ public static final String DELETED_B_ARTIFACTS = String.format(DELETED_ARTIFACTS_QUERY, "b_art_id");
+
+ public static final String DELETE_FROM_TXS = "DELETE FROM osee_txs where gamma_id = ? AND transaction_id = ?";
+
+ public static final String DEL_FROM_TXS_W_SPEC_BRANCH_ID =
+ "DELETE FROM osee_txs where gamma_id = ? AND transaction_id = ? AND branch_id = ?";
+
+ // relations that no artifact (on side A of relation) references
private static final String NO_ADDRESSING_ARTIFACTS_A =
"SELECT tx1.gamma_id, tx1.transaction_id, rel1.rel_link_id, tx1.branch_id, rel1.a_art_id, rel1.b_art_id, 0 AS deleted_tran FROM osee_txs tx1, osee_relation_link rel1 WHERE tx1.gamma_id = rel1.gamma_id AND NOT EXISTS (SELECT 'x' FROM osee_txs tx2, osee_artifact av1 WHERE tx1.branch_id = tx2.branch_id AND tx2.gamma_id = av1.gamma_id AND av1.art_id = rel1.a_art_id)";
-
+ // relations that no artifact (on side B of relation) references
private static final String NO_ADDRESSING_ARTIFACTS_B =
"SELECT tx1.gamma_id, tx1.transaction_id, rel1.rel_link_id, tx1.branch_id, rel1.a_art_id, rel1.b_art_id, 0 AS deleted_tran FROM osee_txs tx1, osee_relation_link rel1 WHERE tx1.gamma_id = rel1.gamma_id AND NOT EXISTS (SELECT 'x' FROM osee_txs tx2, osee_artifact av1 WHERE tx1.branch_id = tx2.branch_id AND tx2.gamma_id = av1.gamma_id AND av1.art_id = rel1.b_art_id)";
- private static final String DELETED_A_ARTIFACTS =
- "SELECT tx1.gamma_id, tx1.transaction_id, rel1.rel_link_id, tx1.branch_id, rel1.a_art_id, rel1.b_art_id, tx2.transaction_id AS deleted_tran FROM osee_txs tx1, osee_txs tx2, osee_relation_link rel1, osee_artifact av1 WHERE tx1.gamma_id = rel1.gamma_id AND tx1.tx_current = 1 AND tx1.branch_id = tx2.branch_id AND tx2.gamma_id = av1.gamma_id AND tx2.tx_current = 2 AND av1.art_id = rel1.a_art_id";
-
- private static final String DELETED_B_ARTIFACTS =
- "SELECT tx1.gamma_id, tx1.transaction_id, rel1.rel_link_id, tx1.branch_id, rel1.a_art_id, rel1.b_art_id, tx2.transaction_id AS deleted_tran FROM osee_txs tx1, osee_txs tx2, osee_relation_link rel1, osee_artifact av1 WHERE tx1.gamma_id = rel1.gamma_id AND tx1.tx_current = 1 AND tx1.branch_id = tx2.branch_id AND tx2.gamma_id = av1.gamma_id AND tx2.tx_current = 2 AND av1.art_id = rel1.b_art_id";
-
- private static final String DELETE_FROM_TXS = "DELETE FROM osee_txs where gamma_id = ? AND transaction_id = ?";
-
private static final String UPDATE_TXS_PREVIOUS =
"UPDATE osee_txs SET tx_current = 0 WHERE gamma_id = ? AND transaction_id = ?";
-
private static final String UPDATE_TXS_CURRENT =
"UPDATE osee_txs SET tx_current = " + TxChange.ARTIFACT_DELETED.getValue() + ", mod_type = " + ModificationType.ARTIFACT_DELETED.getValue() + " WHERE gamma_id = ? AND transaction_id = ?";
@@ -162,7 +195,7 @@ public class RelationIntegrityCheck extends DatabaseHealthOperation {
rowsToDelete.add(new Object[] {relLink.gammaId, relLink.relTransId});
}
- monitor.subTask("Deleting Relation Addressing with non existent Artifacts");
+ monitor.subTask("Deleting Relation Addressing with " + TxChange.DELETED + " Artifact");
if (rowsToDelete.size() != 0) {
ConnectionHandler.runBatchUpdate(DELETE_FROM_TXS, rowsToDelete);
}
@@ -172,15 +205,31 @@ public class RelationIntegrityCheck extends DatabaseHealthOperation {
}
private void fix() throws OseeCoreException {
+
+ //fix for NO_ADDRESSING_ARTIFACTS_A or NO_ADDRESSING_ARTIFACTS_B
deleteInvalidRelationAddressing();
List<Object[]> insertArtifactDeleted = new LinkedList<Object[]>();
List<Object[]> updatePreviousAddressing = new LinkedList<Object[]>();
List<Object[]> updateCurrentAddressing = new LinkedList<Object[]>();
- List<LocalRelationLink> pathologicalCases = new ArrayList<LocalRelationLink>();
+ List<LocalRelationLink> unExpectedCases = new ArrayList<LocalRelationLink>();
+ List<Object[]> commitOfNewRelationOnDeletedArtifactCases = new ArrayList<Object[]>();
+
for (LocalRelationLink relLink : updateMap.allValues()) {
if (relLink.relTransId > relLink.transIdForArtifactDeletion) {
- pathologicalCases.add(relLink);
+
+ if (relLink.commitTrans > 0 && relLink.modType == 1) {
+ commitOfNewRelationOnDeletedArtifactCases.add(new Object[] {
+ relLink.gammaId,
+ relLink.relTransId,
+ relLink.branchId}); //typically during a merge of a branch
+ //displayUnexpectedRelLinks(unExpectedCases);
+ } else {
+ //NO POST PROCESSING HERE, subset of relLink(s) that are not understood to be classified.
+ //At minimum they should be displayed.
+ unExpectedCases.add(relLink);
+ }
+
} else if (relLink.relTransId == relLink.transIdForArtifactDeletion) {
updateCurrentAddressing.add(new Object[] {relLink.gammaId, relLink.relTransId});
} else {
@@ -192,22 +241,29 @@ public class RelationIntegrityCheck extends DatabaseHealthOperation {
}
}
+ runInsert(commitOfNewRelationOnDeletedArtifactCases, DEL_FROM_TXS_W_SPEC_BRANCH_ID,
+ "Deleting TXs with relation links made with deleted artifacts.");
runInsert(insertArtifactDeleted, INSERT_TXS, "Inserting Addressing for Deleted Artifacts");
runInsert(updatePreviousAddressing, UPDATE_TXS_PREVIOUS, "Updating Addressing for Deleted Artifacts");
runInsert(updateCurrentAddressing, UPDATE_TXS_CURRENT, "Updating Addressing for Deleted Artifacts");
updateMap = null;
}
+ @SuppressWarnings("unused")
+ private void displayUnexpectedRelLinks(LocalRelationLink relationLink) {
+ System.out.println("gam_id \t transaction_id \t rel_link_id \t branch_d \t a_art_id \t b_art_id \t deleted_tran \t commit trans \t commit trans mod type");
+ System.out.println(relationLink.toString());
+ }
+
private void runInsert(List<Object[]> insertParameters, String sql, String taskName) throws OseeCoreException {
monitor.subTask(taskName);
if (insertParameters.size() != 0) {
ConnectionHandler.runBatchUpdate(sql, insertParameters);
}
monitor.worked(calculateWork(0.10));
-
}
- private void endReport() throws OseeCoreException {
+ private void endReport() {
sbFull.append(AHTML.endMultiColumnTable());
XResultData rd = new XResultData();
rd.addRaw(sbFull.toString());
@@ -244,14 +300,22 @@ public class RelationIntegrityCheck extends DatabaseHealthOperation {
try {
chStmt.runPreparedQuery(sql);
while (chStmt.next()) {
- if (!map.containsKey(chStmt.getInt("gamma_id"), chStmt.getInt("transaction_id")) && (forDelete || !deleteMap.containsKey(
- chStmt.getInt("gamma_id"), chStmt.getInt("transaction_id")))) {
- map.put(
- chStmt.getInt("gamma_id"),
- chStmt.getInt("transaction_id"),
- new LocalRelationLink(chStmt.getInt("rel_link_id"), chStmt.getInt("gamma_id"),
- chStmt.getInt("transaction_id"), chStmt.getInt("branch_id"), chStmt.getInt("a_art_id"),
- chStmt.getInt("b_art_id"), chStmt.getInt("deleted_tran")));
+ //@formatter:off
+ int version = chStmt.getInt("gamma_id");
+ int transactionId = chStmt.getInt("transaction_id");
+ int relationId = chStmt.getInt("rel_link_id");
+ int branchId = chStmt.getInt("branch_id");
+ int a_sideArtifactId = chStmt.getInt("a_art_id");
+ int b_sideArtifactId = chStmt.getInt("b_art_id");
+ int deletedTransaction = chStmt.getInt("deleted_tran");
+
+ int commitTransId = chStmt.getInt("commit_trans_art_id");
+ int modType = chStmt.getInt("creating_trans_mod_type");
+ //@formatter:on
+
+ if (!map.containsKey(version, transactionId) && (forDelete || !deleteMap.containsKey(version, transactionId))) {
+ map.put(version, transactionId, new LocalRelationLink(relationId, version, transactionId, branchId,
+ a_sideArtifactId, b_sideArtifactId, deletedTransaction, commitTransId, modType));
} else {
System.out.print("");
}
@@ -272,5 +336,4 @@ public class RelationIntegrityCheck extends DatabaseHealthOperation {
public String getFixDescription() {
return "Enter Fix Description Here";
}
-
}