Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjphillips2011-04-07 21:07:58 +0000
committerRyan D. Brooks2011-04-07 21:07:58 +0000
commit12873602645b7729cb0d6498f40d45c839308c27 (patch)
tree5c1d7e7801c4e6f971c7c7c2bb0f24f596e3c8eb
parentb4bf85d66c5ff6e2e6d2a04e03bab1a7257abda1 (diff)
downloadorg.eclipse.osee-12873602645b7729cb0d6498f40d45c839308c27.tar.gz
org.eclipse.osee-12873602645b7729cb0d6498f40d45c839308c27.tar.xz
org.eclipse.osee-12873602645b7729cb0d6498f40d45c839308c27.zip
refactor: Replace attribute revert with replace with version
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/ModificationType.java6
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/AttributeEventModificationType.java2
-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/cases/ReplaceWithAttributeTest.java51
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java18
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java89
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Attribute.java24
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/RevertOperation.java36
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UpdateMergeBranch.java9
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/revert/ArtifactRevert.java53
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/revert/Revert.java (renamed from plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/RevertAction.java)93
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/conflict/AttributeConflict.java7
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java22
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java16
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml6
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/ReplaceWithBaseline.java (renamed from plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/RevertAttributeHandler.java)76
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/RevertJob.java59
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/revert/RevertWizardPage.java30
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java47
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/DiffHandler.java2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeUtility.java59
22 files changed, 334 insertions, 374 deletions
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/ModificationType.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/ModificationType.java
index 1a0d970a87..6ce98ca689 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/ModificationType.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/ModificationType.java
@@ -46,7 +46,11 @@ public enum ModificationType {
// Previously deleted artifact, attribute, or relation has been reinstated
// Relation can be in this state in memory, but this mod type is persisted as MODIFIED
- UNDELETED("Undeleted", 7);
+ UNDELETED("Undeleted", 7),
+
+ //Artifact: Not valid
+ //Attribute: Valid and can be used to replace the current version of an attribute with another historical version
+ REPLACED_WITH_VERSION("Replace_with_version", 8);
private final static Set<ModificationType> ALL_NONE_HARD_DELETED = new HashSet<ModificationType>();
private final static Set<ModificationType> ALL_MOD_TYPES = new HashSet<ModificationType>();
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/AttributeEventModificationType.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/AttributeEventModificationType.java
index 4777ec56f4..14bdbf8ac6 100644
--- a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/AttributeEventModificationType.java
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/AttributeEventModificationType.java
@@ -45,6 +45,8 @@ public class AttributeEventModificationType {
"AYsmWP05uX1Dl6q2pIwA");
public static AttributeEventModificationType Undeleted = new AttributeEventModificationType(
ModificationType.UNDELETED, "AYsmWP1q1B2bK1kj0ugA");
+ public static AttributeEventModificationType replaceWithVersion = new AttributeEventModificationType(
+ ModificationType.REPLACED_WITH_VERSION, "AYsmWP1q1B2bK1kj0ugC");
public AttributeEventModificationType(ModificationType modificationType, String guid) {
this.modificationType = modificationType;
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 8bf5db21f0..73279e8956 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
@@ -29,6 +29,7 @@ import org.eclipse.osee.framework.skynet.core.test.cases.NativeArtifactTest;
import org.eclipse.osee.framework.skynet.core.test.cases.PurgeTransactionTest;
import org.eclipse.osee.framework.skynet.core.test.cases.RelationDeletionTest;
import org.eclipse.osee.framework.skynet.core.test.cases.RelationOrderingTest;
+import org.eclipse.osee.framework.skynet.core.test.cases.ReplaceWithAttributeTest;
import org.eclipse.osee.framework.skynet.core.test.cases.SevereLogMonitorTest;
import org.eclipse.osee.framework.skynet.core.test.cases.StaticIdManagerTest;
import org.eclipse.osee.framework.skynet.core.test.cases.TransactionManagerTest;
@@ -54,6 +55,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
+ ReplaceWithAttributeTest.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/cases/ReplaceWithAttributeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ReplaceWithAttributeTest.java
new file mode 100644
index 0000000000..26a3dfa735
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ReplaceWithAttributeTest.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.cases;
+
+import static org.junit.Assert.assertTrue;
+import java.util.Collections;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+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.ArtifactTypeManager;
+import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.support.test.util.DemoSawBuilds;
+import org.junit.Assert;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class ReplaceWithAttributeTest {
+
+ @org.junit.Test
+ public void testReplaceAttributeVersion() throws Exception {
+ Branch branch = BranchManager.getBranchByGuid(DemoSawBuilds.SAW_Bld_1.getGuid());
+ Assert.assertNotNull(branch);
+ Artifact artifact =
+ ArtifactTypeManager.addArtifact(CoreArtifactTypes.GeneralDocument, branch, getClass().getSimpleName());
+ artifact.setAttributeValues(CoreAttributeTypes.Name, Collections.singletonList("Name"));
+ artifact.persist();
+
+ Attribute<?> nameAttribute = artifact.getAttributes(CoreAttributeTypes.Name).iterator().next();
+ int previousGamma = nameAttribute.getGammaId();
+ String previousName = nameAttribute.getDisplayableString();
+
+ nameAttribute.setFromString("New Name");
+ nameAttribute.getArtifact().persist();
+
+ nameAttribute.replaceWithVersion(previousGamma);
+ assertTrue(nameAttribute.getGammaId() == previousGamma);
+ assertTrue(artifact.getAttributes(CoreAttributeTypes.Name).iterator().next().getValue().equals(previousName));
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF
index cb49242fb2..68242272e2 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF
@@ -22,6 +22,7 @@ Export-Package: org.eclipse.osee.framework.skynet.core,
org.eclipse.osee.framework.skynet.core.artifact.factory,
org.eclipse.osee.framework.skynet.core.artifact.format,
org.eclipse.osee.framework.skynet.core.artifact.operation,
+ org.eclipse.osee.framework.skynet.core.artifact.revert,
org.eclipse.osee.framework.skynet.core.artifact.search,
org.eclipse.osee.framework.skynet.core.artifact.update,
org.eclipse.osee.framework.skynet.core.attribute,
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java
index 4b0708a968..a347f3fcf1 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java
@@ -63,9 +63,8 @@ import org.eclipse.osee.framework.core.model.event.IBasicGuidArtifact;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.core.model.type.RelationType;
+import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.core.services.IAccessControlService;
-import org.eclipse.osee.framework.database.core.DbTransaction;
-import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.jdk.core.util.Collections;
@@ -80,6 +79,7 @@ import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.annotation.ArtifactAnnotation;
import org.eclipse.osee.framework.skynet.core.artifact.annotation.AttributeAnnotationManager;
import org.eclipse.osee.framework.skynet.core.artifact.annotation.IArtifactAnnotation;
+import org.eclipse.osee.framework.skynet.core.artifact.revert.ArtifactRevert;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
import org.eclipse.osee.framework.skynet.core.event.model.AttributeChange;
@@ -989,14 +989,12 @@ public class Artifact extends NamedIdentity implements IArtifact, IAdaptable, IB
}
}
- public final void revert() throws OseeCoreException {
- DbTransaction dbTransaction = new DbTransaction() {
- @Override
- protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
- ArtifactPersistenceManager.revertArtifact(connection, Artifact.this);
- }
- };
- dbTransaction.execute();
+ public final void revert() {
+ ArtifactRevert artifactRevert = new ArtifactRevert(branch, getArtId());
+ RevertOperation revertOperation =
+ new RevertOperation(artifactRevert, Activator.getInstance().getOseeDatabaseService(), "Revert Artifact",
+ Activator.PLUGIN_ID);
+ Operations.executeAsJob(revertOperation, false);
}
/**
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java
index c8b716afa9..cfdd63b1b1 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java
@@ -21,40 +21,21 @@ import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.enums.TxChange;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.TransactionRecord;
-import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.database.core.ConnectionHandler;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.artifact.search.ISearchPrimitive;
import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
-import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
/**
* @author Ryan D. Brooks
* @author Robert A. Fisher
*/
public class ArtifactPersistenceManager {
-
- private static final String GET_GAMMAS_ARTIFACT_REVERT =
- "SELECT txs1.gamma_id, txs1.transaction_id FROM osee_txs txs1, osee_attribute attr1 WHERE txs1.gamma_id = attr1.gamma_id and txs1.branch_id = ? and attr1.art_id = ? " + //
- "UNION ALL SELECT txs2.gamma_id, txs2.transaction_id FROM osee_txs txs2, osee_relation_link rel2 WHERE txs2.gamma_id = rel2.gamma_id AND txs2.branch_id = ? AND (rel2.a_art_id = ? or rel2.b_art_id = ?) " + //
- "UNION ALL SELECT txs3.gamma_id, txs3.transaction_id FROM osee_txs txs3, osee_artifact art3 WHERE txs3.gamma_id = art3.gamma_id AND txs3.branch_id = ? AND art3.art_id = ?";
-
- private static final String GET_GAMMAS_RELATION_REVERT =
- "SELECT txs.gamma_id, txs.transaction_id FROM osee_txs txs, osee_relation_link rel WHERE txs.gamma_id = rel.gamma_id AND txs.branch_id = ? AND rel.rel_link_id = ?";
-
- private static final String GET_GAMMAS_ATTRIBUTE_REVERT =
- "SELECT txs.gamma_id, txs.transaction_id FROM osee_txs txs, osee_attribute attr WHERE txs.gamma_id = attr.gamma_id AND txs.branch_id = ? AND attr.attr_id = ?";
-
private static final String ARTIFACT_SELECT =
"SELECT art1.art_id, txs1.branch_id FROM osee_artifact art1, osee_txs txs1 WHERE art1.gamma_id = txs1.gamma_id AND txs1.tx_current = " + TxChange.CURRENT.getValue() + " AND txs1.branch_id = ? AND ";
@@ -214,76 +195,6 @@ public class ArtifactPersistenceManager {
}
}
- public static void revertAttribute(OseeConnection connection, Attribute<?> attribute) throws OseeCoreException {
- if (attribute == null) {
- return;
- }
- revertAttribute(connection, attribute.getArtifact().getBranch().getId(), attribute.getArtifact().getArtId(),
- attribute.getId());
- }
-
- public static void revertAttribute(OseeConnection connection, int branchId, int artId, int attributeId) throws OseeCoreException {
- TransactionRecord transId =
- TransactionManager.createNextTransactionId(connection, BranchManager.getBranch(branchId),
- UserManager.getUser(), "");
- long totalTime = System.currentTimeMillis();
- //Get attribute Gammas
- IOseeStatement chStmt = ConnectionHandler.getStatement(connection);
- RevertAction revertAction = null;
- try {
- chStmt.runPreparedQuery(GET_GAMMAS_ATTRIBUTE_REVERT, branchId, attributeId);
- revertAction = new RevertAction(connection, chStmt, transId);
- revertAction.revertObject(totalTime, artId, "Attribute");
- } finally {
- chStmt.close();
- }
- revertAction.fixArtifactVersionForAttributeRevert(branchId, artId);
- }
-
- /**
- * Should NOT be used for relation types that maintain order. Not handled yet
- */
- public static void revertRelationLink(OseeConnection connection, RelationLink link) throws OseeCoreException {
-
- // Only reverts relation links that don't span multiple branches. Need
- // to revisit if additional functionality is needed.
- if (!link.getArtifactA().getBranch().equals(link.getArtifactB().getBranch())) {
- throw new OseeArgumentException("Cannot revert Relation %d. Relation spans multiple branches", link.getId());
- }
- long totalTime = System.currentTimeMillis();
- Branch branch = link.getArtifactA().getBranch();
- IOseeStatement chStmt = ConnectionHandler.getStatement(connection);
- try {
- chStmt.runPreparedQuery(GET_GAMMAS_RELATION_REVERT, branch.getId(), link.getId());
- TransactionRecord transId =
- TransactionManager.createNextTransactionId(connection, branch, UserManager.getUser(), "");
- RevertAction revertAction = new RevertAction(connection, chStmt, transId);
- revertAction.revertObject(totalTime, link.getId(), "Relation Link");
- } finally {
- chStmt.close();
- }
- }
-
- public static void revertArtifact(OseeConnection connection, Artifact artifact) throws OseeCoreException {
- Conditions.checkNotNull(artifact, "Artifact to revert");
- revertArtifact(connection, artifact.getBranch(), artifact.getArtId());
- }
-
- public static void revertArtifact(OseeConnection connection, Branch branch, int artId) throws OseeCoreException {
- long totalTime = System.currentTimeMillis();
- IOseeStatement chStmt = ConnectionHandler.getStatement(connection);
- try {
- int branchId = branch.getId();
- chStmt.runPreparedQuery(GET_GAMMAS_ARTIFACT_REVERT, branchId, artId, branchId, artId, artId, branchId, artId);
- TransactionRecord transId =
- TransactionManager.createNextTransactionId(connection, branch, UserManager.getUser(), "");
- RevertAction revertAction = new RevertAction(connection, chStmt, transId);
- revertAction.revertObject(totalTime, artId, "Artifact");
- } finally {
- chStmt.close();
- }
- }
-
public static boolean isArtifactNewOnBranch(Artifact artifact) throws OseeCoreException {
Branch branch = artifact.getBranch();
return ConnectionHandler.runPreparedQueryFetchInt(0, ARTIFACT_NEW_ON_BRANCH, artifact.getArtId(), branch.getId(),
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Attribute.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Attribute.java
index 21f83d5c16..7b9f8c2213 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Attribute.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Attribute.java
@@ -23,8 +23,6 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.core.model.type.AttributeType;
-import org.eclipse.osee.framework.database.core.DbTransaction;
-import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
@@ -197,8 +195,6 @@ public abstract class Attribute<T> implements Comparable<Attribute<T>> {
ArtifactCache.updateCachedArtifact(artifact.getArtId(), artifact.getBranch().getId());
} catch (OseeStateException ex) {
OseeLog.log(Attribute.class, Level.SEVERE, ex.toString(), ex);
- } catch (OseeCoreException ex) {
- OseeLog.log(Attribute.class, Level.SEVERE, ex.toString(), ex);
}
}
@@ -323,14 +319,18 @@ public abstract class Attribute<T> implements Comparable<Attribute<T>> {
return false;
}
- public void revert() throws OseeCoreException {
- DbTransaction dbTransaction = new DbTransaction() {
- @Override
- protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
- ArtifactPersistenceManager.revertAttribute(connection, Attribute.this);
- }
- };
- dbTransaction.execute();
+ public void revert() {
+ //Do Nothing
+ }
+
+ public void replaceWithVersion(int gammaId) throws OseeStateException, OseeCoreException {
+ modificationType = ModificationType.REPLACED_WITH_VERSION;
+ this.gammaId = gammaId;
+ setDirtyFlag(true);
+
+ //this could be in the calling object
+ getArtifact().persist();
+ getArtifact().reloadAttributesAndRelations();
}
/**
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/RevertOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/RevertOperation.java
new file mode 100644
index 0000000000..3d0b0ca92a
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/RevertOperation.java
@@ -0,0 +1,36 @@
+/*
+ * Created on Mar 30, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.skynet.core.artifact;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.AbstractDbTxOperation;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.skynet.core.artifact.revert.Revert;
+import org.eclipse.osee.framework.skynet.core.internal.Activator;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class RevertOperation extends AbstractDbTxOperation {
+
+ private final Revert revert;
+
+ public RevertOperation(Revert revert, String operationTitle) {
+ this(revert, Activator.getInstance().getOseeDatabaseService(), operationTitle, Activator.PLUGIN_ID);
+ }
+
+ public RevertOperation(Revert revert, IOseeDatabaseService databaseService, String operationTitle, String pluginId) {
+ super(databaseService, operationTitle, pluginId);
+ this.revert = revert;
+ }
+
+ @Override
+ protected void doTxWork(IProgressMonitor monitor, OseeConnection connection) throws OseeCoreException {
+ revert.revert(connection);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UpdateMergeBranch.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UpdateMergeBranch.java
index c265732f6f..984c386874 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UpdateMergeBranch.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UpdateMergeBranch.java
@@ -23,6 +23,7 @@ import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.enums.TxChange;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.database.core.ConnectionHandler;
import org.eclipse.osee.framework.database.core.DbTransaction;
import org.eclipse.osee.framework.database.core.IOseeStatement;
@@ -32,7 +33,9 @@ import org.eclipse.osee.framework.database.core.SQL3DataType;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
+import org.eclipse.osee.framework.skynet.core.artifact.revert.ArtifactRevert;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.internal.Activator;
/**
* @author Theron Virgin
@@ -243,7 +246,11 @@ public class UpdateMergeBranch extends DbTransaction {
int baseTxId = branch.getBaseTransaction().getId();
int branchId = branch.getId();
- ArtifactPersistenceManager.revertArtifact(connection, branch, artId);
+ ArtifactRevert artifactRevert = new ArtifactRevert(branch, artId);
+ RevertOperation revertOperation =
+ new RevertOperation(artifactRevert, Activator.getInstance().getOseeDatabaseService(), "Revert Artifact",
+ Activator.PLUGIN_ID);
+ Operations.executeAsJob(revertOperation, false);
//Remove from Baseline
ConnectionHandler.runPreparedUpdate(connection, PURGE_BASELINE_ATTRIBUTE_TRANS, baseTxId, branchId, artId);
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/revert/ArtifactRevert.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/revert/ArtifactRevert.java
new file mode 100644
index 0000000000..0c44a2f36b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/revert/ArtifactRevert.java
@@ -0,0 +1,53 @@
+/*
+ * Created on Apr 4, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.skynet.core.artifact.revert;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
+
+/**
+ * @author Theron Virgin
+ */
+public class ArtifactRevert extends Revert {
+
+ private static final String GET_GAMMAS_ARTIFACT_REVERT =
+ "SELECT txs1.gamma_id, txs1.transaction_id FROM osee_txs txs1, osee_attribute attr1 WHERE txs1.gamma_id = attr1.gamma_id and txs1.branch_id = ? and attr1.art_id = ? " + //
+ "UNION ALL SELECT txs2.gamma_id, txs2.transaction_id FROM osee_txs txs2, osee_relation_link rel2 WHERE txs2.gamma_id = rel2.gamma_id AND txs2.branch_id = ? AND (rel2.a_art_id = ? or rel2.b_art_id = ?) " + //
+ "UNION ALL SELECT txs3.gamma_id, txs3.transaction_id FROM osee_txs txs3, osee_artifact art3 WHERE txs3.gamma_id = art3.gamma_id AND txs3.branch_id = ? AND art3.art_id = ?";
+
+ private final Integer[] artifactIds;
+ private final Branch branch;
+
+ public ArtifactRevert(Branch branch, Integer... artifactIds) {
+ super();
+ this.artifactIds = artifactIds;
+ this.branch = branch;
+ }
+
+ @Override
+ public void revert(OseeConnection connection) throws OseeCoreException {
+ long totalTime = System.currentTimeMillis();
+ IOseeStatement chStmt = ConnectionHandler.getStatement(connection);
+ try {
+ for (Integer artId : artifactIds) {
+ int branchId = branch.getId();
+ chStmt.runPreparedQuery(GET_GAMMAS_ARTIFACT_REVERT, branchId, artId, branchId, artId, artId, branchId,
+ artId);
+ TransactionRecord transId =
+ TransactionManager.createNextTransactionId(connection, branch, UserManager.getUser(), "");
+ revertObject(totalTime, artId, "Artifact", chStmt, transId, connection);
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/RevertAction.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/revert/Revert.java
index eb2bcd5b09..fbc686678d 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/RevertAction.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/revert/Revert.java
@@ -1,14 +1,9 @@
-/*******************************************************************************
- * 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
+/*
+ * Created on Apr 3, 2011
*
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.skynet.core.artifact;
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.skynet.core.artifact.revert;
import java.util.ArrayList;
import java.util.Arrays;
@@ -27,8 +22,7 @@ import org.eclipse.osee.framework.jdk.core.util.Lib;
/**
* @author Theron Virgin
*/
-public class RevertAction {
-
+public abstract class Revert {
private static final String REVERT_COMMENT = "Reverted Transaction";
private static final String DELETE_TXS_GAMMAS_REVERT =
@@ -52,34 +46,27 @@ public class RevertAction {
private static final String REVERT_ARTIFACT_VERSION_SELECT =
"SELECT txs.gamma_id, txs.transaction_id FROM osee_txs txs, osee_artifact art WHERE txs.transaction_id in (%s) AND txs.gamma_id = art.gamma_id AND NOT EXISTS (SELECT 'x' FROM osee_txs txs2 WHERE txs2.transaction_id = txs.transaction_id AND txs2.gamma_id != txs.gamma_id)";
- private static final boolean DEBUG =
- "TRUE".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.osee.framework.skynet.core/debug/Revert"));
-
- List<Object[]> gammaIdsModifications = new ArrayList<Object[]>();
- List<Object[]> gammaIdsToInsert = new ArrayList<Object[]>();
- List<Object[]> gammaIdsBaseline = new ArrayList<Object[]>();
- List<Integer> transactionIds = new ArrayList<Integer>();
+ private final List<Object[]> gammaIdsModifications = new ArrayList<Object[]>();
+ private final List<Object[]> gammaIdsToInsert = new ArrayList<Object[]>();
+ private final List<Object[]> gammaIdsBaseline = new ArrayList<Object[]>();
+ private final List<Integer> transactionIds = new ArrayList<Integer>();
- private final OseeConnection connection;
- private IOseeStatement chStmt;
- private final TransactionRecord transId;
private String objectReverted;
- public RevertAction(OseeConnection connection, IOseeStatement chStmt, TransactionRecord transId) {
- this.connection = connection;
- this.chStmt = chStmt;
- this.transId = transId;
- }
+ private static final boolean DEBUG =
+ "TRUE".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.osee.framework.skynet.core/debug/Revert"));
- public void revertObject(long totalTime, int id, String objectReverted) throws OseeCoreException {
+ public abstract void revert(OseeConnection connection) throws OseeCoreException;
+
+ protected void revertObject(long totalTime, int id, String objectReverted, IOseeStatement chStmt, TransactionRecord transId, OseeConnection connection) throws OseeCoreException {
this.objectReverted = objectReverted;
- processChStmtSortGammas();
+ processChStmtSortGammas(chStmt, transId);
if (!gammaIdsModifications.isEmpty()) {
- updateTransactionTables();
+ updateTransactionTables(connection, transId);
if (!gammaIdsBaseline.isEmpty()) {
- setTxCurrentForRevertedObjects();
+ setTxCurrentForRevertedObjects(connection);
}
}
if (DEBUG) {
@@ -88,23 +75,7 @@ public class RevertAction {
}
}
- public void fixArtifactVersionForAttributeRevert(int branchId, int artId) throws OseeCoreException {
- if (!transactionIds.isEmpty()) {
- chStmt = ConnectionHandler.getStatement(connection);
- try {
- chStmt.runPreparedQuery(String.format(REVERT_ARTIFACT_VERSION_SELECT,
- Collections.toString(",", transactionIds)));
- objectReverted = "Atrtribute";
- processChStmtSortGammas();
- updateTransactionTables();
- updateArtifactVersionTxCurrents(branchId, artId);
- } finally {
- chStmt.close();
- }
- }
- }
-
- private void processChStmtSortGammas() throws OseeCoreException {
+ private void processChStmtSortGammas(IOseeStatement chStmt, TransactionRecord transId) throws OseeCoreException {
gammaIdsModifications.clear();
gammaIdsToInsert.clear();
gammaIdsBaseline.clear();
@@ -137,7 +108,24 @@ public class RevertAction {
}
}
- private void updateTransactionTables() throws OseeDataStoreException, OseeCoreException {
+ public void fixArtifactVersionForAttributeRevert(int branchId, int artId, OseeConnection connection, TransactionRecord transId) throws OseeCoreException {
+ if (!transactionIds.isEmpty()) {
+ IOseeStatement chStmt = ConnectionHandler.getStatement(connection);
+ try {
+ chStmt.runPreparedQuery(String.format(REVERT_ARTIFACT_VERSION_SELECT,
+ Collections.toString(",", transactionIds)));
+ objectReverted = "Atrtribute";
+ processChStmtSortGammas(chStmt, transId);
+ updateTransactionTables(connection, transId);
+ updateArtifactVersionTxCurrents(branchId, artId, connection);
+ } finally {
+ chStmt.close();
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void updateTransactionTables(OseeConnection connection, TransactionRecord transId) throws OseeDataStoreException, OseeCoreException {
long time = System.currentTimeMillis();
ConnectionHandler.runPreparedUpdate(connection, UPDATE_DETAILS_TABLE, REVERT_COMMENT,
TxChange.DELETED.getValue(), transId.getId());
@@ -145,8 +133,7 @@ public class RevertAction {
int count2 = ConnectionHandler.runBatchUpdate(connection, DELETE_TXS_GAMMAS_REVERT, gammaIdsModifications);
if (count1 != count2) {
- throw new OseeCoreException("Revert Transaction moved %d transaction but should have moved %d",
- count1, count2);
+ throw new OseeCoreException("Revert Transaction moved %d transaction but should have moved %d", count1, count2);
}
if (DEBUG) {
displayRevertResults(time, objectReverted, gammaIdsModifications, count2);
@@ -163,7 +150,7 @@ public class RevertAction {
System.out.println(String.format(" Displayed all the data in %s", Lib.getElapseString(time)));
}
- private void setTxCurrentForRevertedObjects() throws OseeCoreException {
+ private void setTxCurrentForRevertedObjects(OseeConnection connection) throws OseeCoreException {
int count2;
long time = System.currentTimeMillis();
count2 = ConnectionHandler.runBatchUpdate(connection, SET_TX_CURRENT_REVERT, gammaIdsBaseline);
@@ -176,7 +163,7 @@ public class RevertAction {
}
}
- private void updateArtifactVersionTxCurrents(int branchId, int artId) throws OseeCoreException {
+ private void updateArtifactVersionTxCurrents(int branchId, int artId, OseeConnection connection) throws OseeCoreException {
if (DEBUG) {
IOseeStatement chStmt = ConnectionHandler.getStatement(connection);
try {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/conflict/AttributeConflict.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/conflict/AttributeConflict.java
index 3732967b7c..1d4c0deb16 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/conflict/AttributeConflict.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/conflict/AttributeConflict.java
@@ -470,13 +470,6 @@ public class AttributeConflict extends Conflict {
return false;
}
- public void revertSourceAttribute() throws OseeCoreException {
- if (DEBUG) {
- System.out.println(String.format("AttributeConflict: Reverting Attribute %d", getAttrId()));
- }
- getSourceAttribute(true).revert();
- }
-
@Override
public boolean applyPreviousMerge(int mergeBranchId, int destBranchId) throws OseeCoreException {
if (DEBUG) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
index 968233be56..4249f7fa01 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
@@ -42,7 +42,6 @@ import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactPersistenceManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.internal.Activator;
import org.eclipse.osee.framework.skynet.core.relation.RelationLink.ArtifactLinker;
@@ -282,7 +281,7 @@ public class RelationManager {
return getRelatedArtifact(artifact, relationEnum, relationEnum.getSide());
}
- public static int getRelatedArtifactsCount(Artifact artifact, IRelationEnumeration relationTypeEnum) throws OseeCoreException {
+ public static int getRelatedArtifactsCount(Artifact artifact, IRelationEnumeration relationTypeEnum) {
return getRelatedArtifactsCount(artifact, relationTypeEnum, relationTypeEnum.getSide());
}
@@ -502,25 +501,6 @@ public class RelationManager {
}
/**
- * This method should only be called for unordered Relation Types. It does not handle reordering relation types that
- * maintain order.
- */
- public static void revertRelations(Artifact artifact, RelationType relationType, RelationSide relationSide) throws OseeCoreException {
- List<RelationLink> selectedRelations = relationCache.getAllByType(artifact, relationType);
- if (selectedRelations != null) {
- for (RelationLink relation : selectedRelations) {
- if (relationSide == null) {
- ArtifactPersistenceManager.revertRelationLink(null, relation);
- } else {
- if (relation.getSide(artifact) != relationSide) {
- ArtifactPersistenceManager.revertRelationLink(null, relation);
- }
- }
- }
- }
- }
-
- /**
* Remove all relations stored in the list awaiting to be deleted.
*/
public static void purgeRelationsFor(Artifact artifact) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java
index ac5b92a297..9d623533c9 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java
@@ -50,6 +50,7 @@ public abstract class BaseTransactionData {
case ARTIFACT_DELETED:
case DELETED:
case INTRODUCED:
+ case REPLACED_WITH_VERSION:
return true;
}
return false;
@@ -70,9 +71,20 @@ public abstract class BaseTransactionData {
}
protected void addInsertToBatch(InsertDataCollector collector) throws OseeCoreException {
+ ModificationType modTypeToStore = getAdjustedModificationType();
+
internalAddInsertToBatch(collector, Integer.MAX_VALUE, INSERT_INTO_TRANSACTION_TABLE,
- collector.getTransactionNumber(), getGammaId(), getModificationType().getValue(),
- TxChange.getCurrent(getModificationType()).getValue(), collector.getBranchId());
+ collector.getTransactionNumber(), getGammaId(), modTypeToStore.getValue(),
+ TxChange.getCurrent(modTypeToStore).getValue(), collector.getBranchId());
+ }
+
+ //Replaces the replace_with_version modtype with modification for storage.
+ private ModificationType getAdjustedModificationType() {
+ ModificationType modtypeToReturn = getModificationType();
+ if (modtypeToReturn == ModificationType.REPLACED_WITH_VERSION) {
+ modtypeToReturn = ModificationType.MODIFIED;
+ }
+ return modtypeToReturn;
}
protected final int getItemId() {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml b/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
index fe10493a45..4d4381d4b5 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
@@ -559,7 +559,7 @@
</separator>
<command
commandId="org.eclipse.osee.framework.ui.skynet.changeReportView.revertAttribute.command"
- label="Revert Source Attribute...">
+ label="Set attribute to baseline...">
</command>
</menuContribution>
</extension>
@@ -717,7 +717,7 @@
</enabledWhen>
</handler>
<handler
- class="org.eclipse.osee.framework.ui.skynet.commandHandlers.RevertAttributeHandler"
+ class="org.eclipse.osee.framework.ui.skynet.commandHandlers.ReplaceWithBaseline"
commandId="org.eclipse.osee.framework.ui.skynet.changeReportView.revertAttribute.command">
<enabledWhen>
<with
@@ -1353,7 +1353,7 @@
</command>
<command
id="org.eclipse.osee.framework.ui.skynet.changeReportView.revertAttribute.command"
- name="Revert Attribute...">
+ name="Set attribute to baseline...">
</command>
<command id="org.eclipse.osee.framework.ui.skynet.changeReportView.viewWordChangeReport.command" name="View Word Change Report - F5">
</command>
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/RevertAttributeHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/ReplaceWithBaseline.java
index 946b736b40..f6e8a34169 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/RevertAttributeHandler.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/ReplaceWithBaseline.java
@@ -13,25 +13,20 @@ package org.eclipse.osee.framework.ui.skynet.commandHandlers;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osee.framework.access.AccessControlManager;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.database.core.DbTransaction;
-import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
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.ArtifactPersistenceManager;
import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
+import org.eclipse.osee.framework.skynet.core.change.Change;
+import org.eclipse.osee.framework.skynet.core.revision.ChangeManager;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.ui.PlatformUI;
@@ -39,53 +34,32 @@ import org.eclipse.ui.PlatformUI;
* @author Jeff C. Phillips
* @author Theron Virgin
*/
-public class RevertAttributeHandler extends AbstractHandler {
+public class ReplaceWithBaseline extends AbstractHandler {
+ @SuppressWarnings("rawtypes")
private List<Attribute> attributes;
@Override
public Object execute(ExecutionEvent event) {
- // This is serious stuff, make sure the user understands the impact.
- if (MessageDialog.openConfirm(
- Displays.getActiveShell(),
- "Confirm Revert of " + attributes.size() + " attributes.",
- "All attribute changes selected will be reverted." + "\n\nTHIS IS IRREVERSIBLE" + "\n\nOSEE must be restarted after all reverting is finished to see the results")) {
-
- Jobs.startJob(new RevertJob());
- }
- return null;
- }
- private class RevertJob extends Job {
-
- public RevertJob() {
- super("Reverting " + attributes.size() + " attributes.");
- }
-
- @Override
- protected IStatus run(final IProgressMonitor monitor) {
- IStatus toReturn;
- try {
- monitor.beginTask("Reverting ...", attributes.size());
-
- DbTransaction dbTransaction = new DbTransaction() {
- @Override
- protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
- for (Attribute<?> attribute : attributes) {
- monitor.setTaskName(attribute.getArtifact().getName() + " : " + attribute.getDisplayableString());
- ArtifactPersistenceManager.revertAttribute(connection, attribute);
- monitor.worked(1);
+ if (MessageDialog.openConfirm(Displays.getActiveShell(),
+ "Confirm Replace with baseline version of " + attributes.size() + " attributes.",
+ "All attribute changes selected will be replaced with thier baseline version.")) {
+ for (Attribute<?> attribute : attributes) {
+ try {
+ TransactionRecord baselineTransactionRecord = attribute.getArtifact().getBranch().getBaseTransaction();
+ for (Change change : ChangeManager.getChangesPerArtifact(attribute.getArtifact(),
+ new NullProgressMonitor())) {
+ if (change.getTxDelta().getEndTx().getId() == baselineTransactionRecord.getId()) {
+ if (change.getItemKind().equals("Attribute") && change.getItemId() == attribute.getId()) {
+ attribute.replaceWithVersion((int) change.getGamma());
+ }
}
}
- };
- dbTransaction.execute();
-
- toReturn = Status.OK_STATUS;
- } catch (Exception ex) {
- toReturn = new Status(IStatus.ERROR, SkynetGuiPlugin.PLUGIN_ID, -1, ex.getMessage(), ex);
- } finally {
- monitor.done();
+ } catch (OseeCoreException ex) {
+ OseeLog.log(getClass(), OseeLevel.SEVERE_POPUP, ex);
+ }
}
- return toReturn;
}
+ return null;
}
@Override
@@ -101,14 +75,12 @@ public class RevertAttributeHandler extends AbstractHandler {
if (selectionProvider != null && selectionProvider.getSelection() instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selectionProvider.getSelection();
- List<Attribute> changes = Handlers.processSelectionObjects(Attribute.class, structuredSelection);
+ this.attributes = Handlers.processSelectionObjects(Attribute.class, structuredSelection);
- if (changes.isEmpty()) {
+ if (attributes.isEmpty()) {
return false;
}
- this.attributes = changes;
-
for (Attribute<?> attribute : attributes) {
isEnabled = AccessControlManager.hasPermission(attribute.getArtifact(), PermissionEnum.WRITE);
if (!isEnabled) {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/RevertJob.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/RevertJob.java
deleted file mode 100644
index 7a44e5bdfe..0000000000
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/RevertJob.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * 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.ui.skynet.commandHandlers;
-
-import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.database.core.DbTransaction;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactPersistenceManager;
-import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
-
-public class RevertJob extends Job {
- private final List<Artifact> artifacts;
-
- public RevertJob(List<Artifact> artifacts) {
- super("Reverting " + artifacts.size() + " artifacts.");
- this.artifacts = artifacts;
- }
-
- @Override
- protected IStatus run(final IProgressMonitor monitor) {
- IStatus toReturn;
- try {
- monitor.beginTask("Reverting ...", artifacts.size());
-
- DbTransaction dbTransaction = new DbTransaction() {
- @Override
- protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
- for (Artifact artifact : artifacts) {
- monitor.setTaskName(artifact.getName());
- ArtifactPersistenceManager.revertArtifact(connection, artifact);
- monitor.worked(1);
- }
- }
- };
- dbTransaction.execute();
-
- toReturn = Status.OK_STATUS;
- } catch (Exception ex) {
- toReturn = new Status(IStatus.ERROR, SkynetGuiPlugin.PLUGIN_ID, -1, ex.getMessage(), ex);
- } finally {
- monitor.done();
- }
- return toReturn;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/revert/RevertWizardPage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/revert/RevertWizardPage.java
index 8bcbec7e2c..05d705424b 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/revert/RevertWizardPage.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/revert/RevertWizardPage.java
@@ -11,16 +11,19 @@
package org.eclipse.osee.framework.ui.skynet.revert;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.operation.Operations;
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.RevertOperation;
+import org.eclipse.osee.framework.skynet.core.artifact.revert.ArtifactRevert;
import org.eclipse.osee.framework.ui.skynet.ArtifactDoubleClick;
-import org.eclipse.osee.framework.ui.skynet.commandHandlers.RevertJob;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.custom.TreeEditor;
@@ -57,13 +60,23 @@ public class RevertWizardPage extends WizardPage {
revertList.add(artList.get(0));
}
}
- Jobs.startJob(new RevertJob(revertList));
+
+ Branch branch = revertList.get(0).getBranch();
+ ArtifactRevert artifactRevert = new ArtifactRevert(branch, getArtids(revertList));
+ RevertOperation revertOperation = new RevertOperation(artifactRevert, "Revert Artifacts");
+ Operations.executeAsJob(revertOperation, false);
+
artifactSelectionBox.setItems(new String[] {});
treeViewer.setInput(null);
}
if (event.widget == revertSelectedButton) {
int index = artifactSelectionBox.getSelectionIndex();
- Jobs.startJob(new RevertJob(artifacts.get(index)));
+
+ Branch branch = artifacts.get(index).get(0).getBranch();
+ ArtifactRevert artifactRevert = new ArtifactRevert(branch, getArtids(artifacts.get(index)));
+ RevertOperation revertOperation = new RevertOperation(artifactRevert, "Revert Artifacts");
+ Operations.executeAsJob(revertOperation, false);
+
artifacts.remove(index);
artifactSelectionBox.remove(index);
if (artifacts.isEmpty()) {
@@ -86,6 +99,15 @@ public class RevertWizardPage extends WizardPage {
}
};
+ private Integer[] getArtids(Collection<Artifact> artifacts) {
+ Integer[] artIds = new Integer[artifacts.size()];
+ int index = 0;
+ for (Artifact artifact : artifacts) {
+ artIds[index++] = artifact.getArtId();
+ }
+ return artIds;
+ }
+
public RevertWizardPage(List<List<Artifact>> artifacts) {
super(TITLE);
this.artifacts = artifacts;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java
index d192babea5..e7c4c96deb 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java
@@ -36,8 +36,10 @@ 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.Attribute;
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.change.AttributeChange;
import org.eclipse.osee.framework.skynet.core.change.Change;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.filter.IEventFilter;
@@ -180,6 +182,9 @@ public class HistoryView extends GenericViewPart implements IBranchEventListener
createChangeReportMenuItem(popupMenu);
+ new MenuItem(popupMenu, SWT.SEPARATOR);
+ createReplaceAttributeWithVersionMenuItem(popupMenu);
+
IAction action = new CompareArtifactAction("Compare two Artifacts", xHistoryWidget.getXViewer());
(new ActionContributionItem(action)).fill(popupMenu, 3);
@@ -199,6 +204,48 @@ public class HistoryView extends GenericViewPart implements IBranchEventListener
xHistoryWidget.getXViewer().getTree().setMenu(popupMenu);
}
+ private void createReplaceAttributeWithVersionMenuItem(Menu popupMenu) {
+ final MenuItem replaceWithMenu = new MenuItem(popupMenu, SWT.CASCADE);
+ replaceWithMenu.setText("&Replace Attribute with Version");
+ popupMenu.addMenuListener(new MenuAdapter() {
+
+ @Override
+ public void menuShown(MenuEvent e) {
+ List<?> selections = ((IStructuredSelection) xHistoryWidget.getXViewer().getSelection()).toList();
+ replaceWithMenu.setEnabled(selections.size() == 1 && selections.iterator().next() instanceof AttributeChange);
+ }
+
+ });
+
+ replaceWithMenu.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IStructuredSelection selection = (IStructuredSelection) xHistoryWidget.getXViewer().getSelection();
+ Object selectedObject = selection.getFirstElement();
+
+ if (selectedObject instanceof AttributeChange) {
+ try {
+ AttributeChange attributeChange = (AttributeChange) selectedObject;
+ Artifact artifact =
+ ArtifactQuery.getArtifactFromId(attributeChange.getArtId(), attributeChange.getBranch());
+
+ for (Attribute<?> attribute : artifact.getAttributes(attributeChange.getAttributeType())) {
+ if (attribute.getId() == attributeChange.getAttrId()) {
+ attribute.replaceWithVersion((int) attributeChange.getGamma());
+ break;
+ }
+ }
+
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ }
+
+ });
+ }
+
private void createChangeReportMenuItem(Menu popupMenu) {
final MenuItem changeReportMenuItem = new MenuItem(popupMenu, SWT.CASCADE);
changeReportMenuItem.setText("&Change Report");
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/DiffHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/DiffHandler.java
index 70a9bd7e53..0d330d0ce3 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/DiffHandler.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/DiffHandler.java
@@ -148,7 +148,7 @@ class DiffHandler extends AbstractSelectionEnabledHandler {
try {
switch (diffToShow) {
case 1:
- if (artifactConflict.getSourceArtifact() != null && conflicts.get(0).getStatus().isNotResolvable() && MergeUtility.getStartArtifact(artifactConflict) != null) {
+ if (artifactConflict.getSourceArtifact() != null && MergeUtility.getStartArtifact(artifactConflict) != null) {
artifacts.add(artifactConflict.getSourceArtifact());
artifacts.add(MergeUtility.getStartArtifact(artifactConflict));
} else {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeUtility.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeUtility.java
index b2df0eff71..98e95101bc 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeUtility.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeUtility.java
@@ -12,11 +12,8 @@
package org.eclipse.osee.framework.ui.skynet.widgets.xmerge;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
-import java.util.LinkedList;
-import java.util.List;
import java.util.logging.Level;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.osee.framework.core.enums.ConflictType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.operation.Operations;
@@ -27,16 +24,13 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.attribute.WordAttribute;
import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta;
-import org.eclipse.osee.framework.skynet.core.conflict.ArtifactConflict;
import org.eclipse.osee.framework.skynet.core.conflict.AttributeConflict;
import org.eclipse.osee.framework.skynet.core.conflict.Conflict;
import org.eclipse.osee.framework.ui.plugin.util.HelpUtil;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
-import org.eclipse.osee.framework.ui.skynet.revert.RevertWizard;
import org.eclipse.osee.framework.ui.swt.Displays;
-import org.eclipse.osee.framework.ui.swt.NonmodalWizardDialog;
import org.eclipse.swt.widgets.Shell;
/**
@@ -106,59 +100,6 @@ public class MergeUtility {
RendererManager.diffInJob(new ArtifactDelta(art1, art2), filePrefix);
}
- public static boolean showDeletedConflict(Conflict conflict, Shell shell) {
- if (conflict.getConflictType().equals(ConflictType.ARTIFACT)) {
- return showArtifactDeletedConflict(conflict, shell);
- } else if (conflict.getConflictType().equals(ConflictType.ATTRIBUTE)) {
- return showAttributeDeletedConflict(conflict, shell);
- }
- return false;
- }
-
- public static boolean showArtifactDeletedConflict(Conflict conflict, Shell shell) {
- if (conflict.getConflictType().equals(ConflictType.ARTIFACT)) {
- MessageDialog dialog =
- new MessageDialog(shell, "Unresovable Conflict", null, ARTIFACT_DELETED_PROMPT, 1, new String[] {
- "Revert Source Artifact",
- "Handle Later"}, 1);
- if (dialog.open() == 0) {
- try {
- List<List<Artifact>> artifacts = new LinkedList<List<Artifact>>();
-
- List<Artifact> artifactList = new LinkedList<Artifact>();
- artifactList.add(((ArtifactConflict) conflict).getSourceArtifact());
- artifacts.add(artifactList);
- RevertWizard wizard = new RevertWizard(artifacts);
- NonmodalWizardDialog dialog2 = new NonmodalWizardDialog(Displays.getActiveShell(), wizard);
- dialog2.create();
- dialog2.open();
- return true;
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
- }
- return false;
- }
-
- public static boolean showAttributeDeletedConflict(Conflict conflict, Shell shell) {
- if (conflict.getConflictType().equals(ConflictType.ATTRIBUTE)) {
- MessageDialog dialog =
- new MessageDialog(shell, "Unresovable Conflict", null, ATTRIBUTE_DELETED_PROMPT, 1, new String[] {
- "Revert Source Attribute",
- "Handle Later"}, 1);
- if (dialog.open() == 0) {
- try {
- ((AttributeConflict) conflict).revertSourceAttribute();
- return true;
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
- }
- return false;
- }
-
public static boolean showInformationalConflict(Shell shell) {
MessageDialog dialog =
new MessageDialog(shell, "Informational Conflict", null, INFORMATIONAL_CONFLICT, 2, new String[] {"OK"}, 1);

Back to the top