diff options
Diffstat (limited to 'plugins')
2 files changed, 30 insertions, 8 deletions
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ReplaceWithBaselineTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ReplaceWithBaselineTest.java index 0e4025cd69b..a3e20349aa6 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ReplaceWithBaselineTest.java +++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ReplaceWithBaselineTest.java @@ -64,9 +64,9 @@ import org.junit.runners.Parameterized.Parameters; * <pre> * New | Deleted | Modified | Moved | Introduced | RelationOrderAttr * ------------------------------------------------------------------------- - * Artifact | 1 2 3 - * Attribute | 4 5 6 - * Relation | 7 8 9* 0** + * Artifact | 0 1 3 2 + * Attribute | 4 5 6 + * Relation | 7 8 9* ** * ------------------------------------------------------------------------- * * @@ -163,10 +163,11 @@ public final class ReplaceWithBaselineTest { data.add(new Object[] {"Case 0", Arrays.asList(new TestData(Item.ARTIFACT, ChangeItem.NEW, false)), 0}); data.add(new Object[] {"Case 1", Arrays.asList(new TestData(Item.ARTIFACT, ChangeItem.DELETED, true)), 0}); data.add(new Object[] {"Case 2", Arrays.asList(new TestData(Item.ARTIFACT, ChangeItem.INTRODUCED, false)), 0}); + data.add(new Object[] {"Case 3", Arrays.asList(new TestData(Item.ARTIFACT, ChangeItem.MODIFIED, true)), 0}); - data.add(new Object[] {"Case 3", Arrays.asList(new TestData(Item.ATTRBUTE, ChangeItem.NEW, true)), 0}); - data.add(new Object[] {"Case 4", Arrays.asList(new TestData(Item.ATTRBUTE, ChangeItem.DELETED, true)), 0}); - data.add(new Object[] {"Case 5", Arrays.asList(new TestData(Item.ATTRBUTE, ChangeItem.MODIFIED, true)), 0}); + data.add(new Object[] {"Case 4", Arrays.asList(new TestData(Item.ATTRBUTE, ChangeItem.NEW, true)), 0}); + data.add(new Object[] {"Case 5", Arrays.asList(new TestData(Item.ATTRBUTE, ChangeItem.DELETED, true)), 0}); + data.add(new Object[] {"Case 6", Arrays.asList(new TestData(Item.ATTRBUTE, ChangeItem.MODIFIED, true)), 0}); List<TestData> combinedCases = new ArrayList<TestData>(data.size()); @@ -175,9 +176,9 @@ public final class ReplaceWithBaselineTest { List<TestData> caseTestDatas = (List<TestData>) objects[1]; combinedCases.addAll(caseTestDatas); } - data.add(new Object[] {"Case 6", combinedCases, 0}); - Collections.reverse(combinedCases); data.add(new Object[] {"Case 7", combinedCases, 0}); + Collections.reverse(combinedCases); + data.add(new Object[] {"Case 8", combinedCases, 0}); return data; } @@ -382,6 +383,11 @@ public final class ReplaceWithBaselineTest { artifact = ArtifactQuery.getArtifactFromId(testData.getArtifactId(), workingBranch); artifact.persist(testName); break; + case MODIFIED: + artifact = ArtifactQuery.getArtifactFromId(testData.getArtifactId(), workingBranch); + artifact.addAttribute(CoreAttributeTypes.Active, true); + artifact.persist(testName); + break; } break; case RELATION: 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 dc8942503a9..b6bcd07cfd7 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 @@ -103,6 +103,9 @@ public class IntroduceArtifactOperation { private void introduceAttributes(Artifact sourceArtifact, Artifact destinationArtifact) throws OseeDataStoreException, OseeCoreException { List<Attribute<?>> sourceAttributes = sourceArtifact.getAttributes(true); + removeNewAttributesFromDestination(sourceArtifact, destinationArtifact); + + // introduce the existing attributes for (Attribute<?> sourceAttribute : sourceAttributes) { // must be valid for the destination branch if (destinationArtifact.isAttributeTypeValid(sourceAttribute.getAttributeType())) { @@ -167,6 +170,19 @@ public class IntroduceArtifactOperation { } } + private void removeNewAttributesFromDestination(Artifact sourceArtifact, Artifact destinationArtifact) throws OseeCoreException { + List<Attribute<?>> destAttributes = destinationArtifact.getAttributes(true); + + // since introduce is 'replacing' the destination artifact with the source artifact, + // any new attributes from the destination artifact should be removed/deleted. + for (Attribute<?> destAttribute : destAttributes) { + Attribute<?> attribute = sourceArtifact.getAttributeById(destAttribute.getId(), true); + if (attribute == null) { + destAttribute.delete(); + } + } + } + private boolean doesRelatedArtifactExist(Artifact destinationArtifact, int aArtifactId, int bArtifactId) throws OseeCoreException { int checkArtId = destinationArtifact.getArtId() == aArtifactId ? bArtifactId : aArtifactId; |