Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormegumi.telles2013-04-05 23:03:38 +0000
committerGerrit Code Review @ Eclipse.org2013-05-13 20:06:56 +0000
commit32be3aaa1d6edfac2a3aa8c28cf93364743c2b6c (patch)
treec32878a1e68088b8b9363a241e91052605436786
parentb690f8429e4e5d5fbf78b23b8aef9233c29fc92f (diff)
downloadorg.eclipse.osee-32be3aaa1d6edfac2a3aa8c28cf93364743c2b6c.tar.gz
org.eclipse.osee-32be3aaa1d6edfac2a3aa8c28cf93364743c2b6c.tar.xz
org.eclipse.osee-32be3aaa1d6edfac2a3aa8c28cf93364743c2b6c.zip
refactor: Replace with baseline version now using introduce functionality
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtilTest.java28
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtil.java6
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/IntroduceArtifactOperation.java6
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ReplaceArtifactWithBaselineOperation.java66
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/replace/ReplaceWithBaselineVersionDialog.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java3
6 files changed, 22 insertions, 89 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtilTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtilTest.java
index 1b9d939930b..7a479b480d7 100644
--- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtilTest.java
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtilTest.java
@@ -178,34 +178,6 @@ public class ChangeItemUtilTest {
}
@Test
- public void testNewOrIntroducedOnSource() {
- ChangeVersion introduced = ChangeTestUtility.createChange(2222L, ModificationType.INTRODUCED);
- ChangeVersion modified = ChangeTestUtility.createChange(1234L, ModificationType.MODIFIED);
- ChangeItem item;
-
- item = ChangeTestUtility.createItem(200, null, introduced, modified, null, null);
- assertTrue(ChangeItemUtil.wasNewOrIntroducedOnSource(item));
-
- item = ChangeTestUtility.createItem(200, null, null, introduced, null, null);
- assertTrue(ChangeItemUtil.wasNewOrIntroducedOnSource(item));
-
- item = ChangeTestUtility.createItem(200, null, null, modified, null, null);
- assertFalse(ChangeItemUtil.wasNewOrIntroducedOnSource(item));
-
- ChangeVersion newType = ChangeTestUtility.createChange(2222L, ModificationType.NEW);
- modified = ChangeTestUtility.createChange(2223L, ModificationType.MODIFIED);
-
- item = ChangeTestUtility.createItem(200, null, newType, modified, null, null);
- assertTrue(ChangeItemUtil.wasNewOrIntroducedOnSource(item));
-
- item = ChangeTestUtility.createItem(200, null, null, newType, null, null);
- assertTrue(ChangeItemUtil.wasNewOrIntroducedOnSource(item));
-
- item = ChangeTestUtility.createItem(200, null, modified, modified, null, null);
- assertFalse(ChangeItemUtil.wasNewOrIntroducedOnSource(item));
- }
-
- @Test
public void testIntroducedOnSource() {
ChangeVersion introduced = ChangeTestUtility.createChange(2222L, ModificationType.INTRODUCED);
ChangeVersion modified = ChangeTestUtility.createChange(1234L, ModificationType.MODIFIED);
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtil.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtil.java
index 1c73eb13f04..37e1a9324bb 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtil.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtil.java
@@ -75,10 +75,6 @@ public final class ChangeItemUtil {
return isIntroduced(changeItem.getFirstNonCurrentChange()) || isIntroduced(changeItem.getCurrentVersion());
}
- public static boolean wasNewOrIntroducedOnSource(ChangeItem changeItem) {
- return wasNewOnSource(changeItem) || wasIntroducedOnSource(changeItem);
- }
-
public static boolean hasBeenReplacedWithVersion(ChangeItem changeItem) {
boolean results = areGammasEqual(changeItem.getCurrentVersion(), changeItem.getBaselineVersion()) && //
isModType(changeItem.getCurrentVersion(), ModificationType.MODIFIED);
@@ -128,7 +124,7 @@ public final class ChangeItemUtil {
}
public static boolean wasCreatedAndDeleted(ChangeItem changeItem) {
- return wasNewOrIntroducedOnSource(changeItem) && isDeleted(changeItem.getCurrentVersion());
+ return !changeItem.getBaselineVersion().isValid() && isDeleted(changeItem.getCurrentVersion());
}
public static boolean isDeletedAndDoesNotExistInDestination(ChangeItem changeItem) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/IntroduceArtifactOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/IntroduceArtifactOperation.java
index 22ba8fbe986..d05903d9b3e 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/IntroduceArtifactOperation.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/IntroduceArtifactOperation.java
@@ -59,11 +59,7 @@ public class IntroduceArtifactOperation {
destinationArtifacts = new ArrayList<Artifact>(sourceArtifacts.size());
for (Artifact sourceArtifact : sourceArtifacts) {
- if (sourceArtifact.getBranch().equals(destinationBranch)) {
- destinationArtifacts.add(sourceArtifact);
- } else {
- introduceArtifact(sourceArtifact);
- }
+ introduceArtifact(sourceArtifact);
}
return destinationArtifacts;
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ReplaceArtifactWithBaselineOperation.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ReplaceArtifactWithBaselineOperation.java
index 21557ffe4bb..9229ebda2cc 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ReplaceArtifactWithBaselineOperation.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ReplaceArtifactWithBaselineOperation.java
@@ -10,20 +10,18 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.blam.operation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeStateException;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.operation.AbstractOperation;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.IntroduceArtifactOperation;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.change.Change;
-import org.eclipse.osee.framework.skynet.core.change.IChangeWorker;
-import org.eclipse.osee.framework.skynet.core.change.RelationChange;
-import org.eclipse.osee.framework.skynet.core.revision.LoadChangeType;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
import org.eclipse.osee.framework.ui.skynet.internal.Activator;
@@ -49,67 +47,37 @@ public class ReplaceArtifactWithBaselineOperation extends AbstractOperation {
monitor.beginTask("Reverting artifact(s)", artifacts.size());
if (!artifacts.isEmpty()) {
Artifact firstArtifact = artifacts.iterator().next();
+ IOseeBranch branch = firstArtifact.getBranch();
SkynetTransaction transaction =
- TransactionManager.createTransaction(firstArtifact.getBranch(),
- ReplaceArtifactWithBaselineOperation.class.getSimpleName());
+ TransactionManager.createTransaction(branch, ReplaceArtifactWithBaselineOperation.class.getSimpleName());
+ TransactionRecord txRecord = firstArtifact.getFullBranch().getBaseTransaction();
for (Artifact artifact : artifacts) {
monitor.subTask("Reverting: " + artifact.getName());
monitor.worked(1);
- Collection<Change> changes = getArtifactSpecificChanges(artifact.getArtId(), changeReportChanges);
- revertArtifact(artifact, changes);
- artifact.persist(transaction);
+ Artifact sourceArtifact =
+ ArtifactQuery.checkHistoricalArtifactFromId(artifact.getArtId(), txRecord,
+ DeletionFlag.INCLUDE_DELETED);
+ if (sourceArtifact != null) {
+ transaction.addArtifact(new IntroduceArtifactOperation(branch).introduce(sourceArtifact));
+ } else {
+ artifact.delete();
+ transaction.addArtifact(artifact);
+ }
monitor.done();
}
-
monitor.subTask(String.format("Persisting %s artifact(s)", artifacts.size()));
transaction.execute();
persistAndReloadArtifacts();
-
}
monitor.done();
}
}
- /**
- * Conditions of filter:
- * <ul>
- * <li>!ChangeItem.isSynthetic()</li>
- * <li>change is for the specific artifact</li>
- * <li>if change is of type Relation and is NOT on the A side but on B side of that relation</li>
- * </ul>
- *
- * @return filtered changes based on the above conditions
- */
- private Collection<Change> getArtifactSpecificChanges(int artId, Collection<Change> changeReport) {
- Collection<Change> artifactChanges = new ArrayList<Change>(changeReport.size());
- for (Change change : changeReport) {
- if (!change.getChangeItem().isSynthetic()) {
- if (change.getArtId() == artId) {
- artifactChanges.add(change);
- } else if (change.getChangeType() == LoadChangeType.relation) {
- RelationChange relationChange = (RelationChange) change;
- if (relationChange.getBArtId() == artId) {
- artifactChanges.add(relationChange);
- }
- }
- }
- }
- return artifactChanges;
- }
-
private void persistAndReloadArtifacts() throws OseeCoreException {
for (Artifact artifact : artifacts) {
artifact.reloadAttributesAndRelations();
}
}
- private void revertArtifact(Artifact artifact, Collection<Change> changes) throws OseeStateException, OseeCoreException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
- for (Change change : changes) {
- Class<? extends IChangeWorker> workerClass = change.getWorker();
- Constructor<?> ctor = workerClass.getConstructor(Change.class, Artifact.class);
- IChangeWorker worker = (IChangeWorker) ctor.newInstance(change, artifact);
- worker.revert();
- }
- }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/replace/ReplaceWithBaselineVersionDialog.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/replace/ReplaceWithBaselineVersionDialog.java
index 1a7ceacfc20..96685fb8fcc 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/replace/ReplaceWithBaselineVersionDialog.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/replace/ReplaceWithBaselineVersionDialog.java
@@ -61,7 +61,7 @@ public class ReplaceWithBaselineVersionDialog extends TitleAreaDialog {
attribute.setEnabled(attrEnabled);
Button artifact = new Button(composite, SWT.RADIO);
- artifact.setText("Replace Artifact");
+ artifact.setText("Replace Artifact Attributes");
artifact.setEnabled(attrEnabled || artEnabled);
composite.setLayout(new GridLayout());
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java
index d302c4d8188..c657088eff2 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java
@@ -109,10 +109,10 @@ public class LoadDeltasBetweenTxsOnTheSameBranch extends DatabaseCallable<List<C
}
private void loadByItemId(Collection<ChangeItem> changeData, int txJoinId, ChangeItemFactory factory) throws OseeCoreException {
- HashMap<Integer, ChangeItem> changesByItemId = new HashMap<Integer, ChangeItem>();
IdJoinQuery idJoin = JoinUtility.createIdJoinQuery();
+ HashMap<Integer, ChangeItem> changesByItemId = new HashMap<Integer, ChangeItem>();
changeItemLoader.loadItemIdsBasedOnGammas(factory, txJoinId, changesByItemId, idJoin);
idJoin.store();
@@ -144,6 +144,7 @@ public class LoadDeltasBetweenTxsOnTheSameBranch extends DatabaseCallable<List<C
ChangeItem change = changesByItemId.get(itemId);
change.getDestinationVersion().setModType(modType);
change.getDestinationVersion().setGammaId(gammaId);
+ change.getBaselineVersion().copy(change.getDestinationVersion());
}
} finally {
chStmt.close();

Back to the top