Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Avila2015-03-19 21:34:51 +0000
committerAngel Avila2015-03-19 21:34:51 +0000
commit16d6f7ef8479b053a3df4b0f66411306e86d5f7e (patch)
tree655097e1908d1959cdff22d9ee90b92e530629b1 /plugins
parent9422eee01a56004b6799060d7da355e1ad271250 (diff)
downloadorg.eclipse.osee-16d6f7ef8479b053a3df4b0f66411306e86d5f7e.tar.gz
org.eclipse.osee-16d6f7ef8479b053a3df4b0f66411306e86d5f7e.tar.xz
org.eclipse.osee-16d6f7ef8479b053a3df4b0f66411306e86d5f7e.zip
refactor: Generalize ChangeItem class
Use type enumeration to identify different change items. Allow construction of change items through default constructor. Make change item serialization friendly. Change-Id: I962caffc8806e08a32e2a851587e97ad3aaf1bb1 Signed-off-by: Angel Avila <angel.avila2@boeing.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/MockRequestFactory.java9
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/ChangeReportResponseTranslator.java59
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/ChangeTestUtility.java11
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockChangeItem.java24
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/AttributeChangeItem.java25
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItem.java101
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtil.java51
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeType.java (renamed from plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ArtifactChangeItem.java)26
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/RelationChangeItem.java37
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeDataLoader.java99
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateFileDiffer.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ChangeItemConflictTest.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ChangeTestUtility.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryTest.java30
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MockChangeItem.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java23
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/AddArtifactChangeDataCallable.java23
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/ArtifactChangeItemFactory.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/AttributeChangeItemFactory.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java49
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/RelationChangeItemFactory.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/conflict/ConflictUtil.java23
22 files changed, 328 insertions, 320 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/MockRequestFactory.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/MockRequestFactory.java
index 295480cace9..833df1c07e7 100644
--- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/MockRequestFactory.java
+++ b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/MockRequestFactory.java
@@ -21,7 +21,8 @@ import org.eclipse.osee.framework.core.message.CacheUpdateRequest;
import org.eclipse.osee.framework.core.model.BranchFactory;
import org.eclipse.osee.framework.core.model.OseeModelFactoryService;
import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
-import org.eclipse.osee.framework.core.model.change.ArtifactChangeItem;
+import org.eclipse.osee.framework.core.model.change.ChangeItem;
+import org.eclipse.osee.framework.core.model.change.ChangeItemUtil;
import org.eclipse.osee.framework.core.model.change.ChangeVersion;
import org.eclipse.osee.framework.core.model.type.ArtifactTypeFactory;
import org.eclipse.osee.framework.core.model.type.AttributeTypeFactory;
@@ -42,12 +43,12 @@ public final class MockRequestFactory {
new ArtifactTypeFactory(), new AttributeTypeFactory(), new RelationTypeFactory(), new OseeEnumTypeFactory());
}
- public static ArtifactChangeItem createArtifactChangeItem() throws OseeArgumentException {
+ public static ChangeItem createArtifactChangeItem() throws OseeArgumentException {
int artId = (int) Math.random();
Long gammaIdNumber = Long.valueOf((int) Math.random());
int artTypeId = artId * 10;
- ArtifactChangeItem changeItem =
- new ArtifactChangeItem(artId, artTypeId, gammaIdNumber, ModificationType.getMod(1));
+ ChangeItem changeItem =
+ ChangeItemUtil.newArtifactChange(artId, artTypeId, gammaIdNumber, ModificationType.getMod(1));
populateChangeVersion(changeItem.getDestinationVersion(), 22);
populateChangeVersion(changeItem.getCurrentVersion(), 15);
return changeItem;
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/ChangeReportResponseTranslator.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/ChangeReportResponseTranslator.java
index 813112ee6cd..e9cdc59d2fb 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/ChangeReportResponseTranslator.java
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/ChangeReportResponseTranslator.java
@@ -15,11 +15,9 @@ import org.eclipse.osee.framework.core.enums.ChangeItemType;
import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.message.ChangeReportResponse;
import org.eclipse.osee.framework.core.message.TranslationUtil;
-import org.eclipse.osee.framework.core.model.change.ArtifactChangeItem;
-import org.eclipse.osee.framework.core.model.change.AttributeChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
+import org.eclipse.osee.framework.core.model.change.ChangeItemUtil;
import org.eclipse.osee.framework.core.model.change.ChangeVersion;
-import org.eclipse.osee.framework.core.model.change.RelationChangeItem;
import org.eclipse.osee.framework.core.translation.ITranslator;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -114,29 +112,32 @@ public class ChangeReportResponseTranslator implements ITranslator<ChangeReportR
private static String[] toArray(ChangeItem item) throws OseeStateException {
String[] row;
- if (item instanceof ArtifactChangeItem) {
- row = new String[4];
- row[0] = ChangeItemType.ARTIFACT.name();
- row[1] = String.valueOf(item.getItemId());
- row[2] = String.valueOf(item.getItemTypeId());
- row[3] = String.valueOf(item.isSynthetic());
- } else if (item instanceof AttributeChangeItem) {
- row = new String[4];
- row[0] = ChangeItemType.ATTRIBUTE.name();
- row[1] = String.valueOf(item.getItemId());
- row[2] = String.valueOf(item.getItemTypeId());
- row[3] = String.valueOf(item.getArtId());
- } else if (item instanceof RelationChangeItem) {
- row = new String[6];
- RelationChangeItem relationChangeItem = (RelationChangeItem) item;
- row[0] = ChangeItemType.RELATION.name();
- row[1] = String.valueOf(item.getItemId());
- row[2] = String.valueOf(item.getItemTypeId());
- row[3] = String.valueOf(relationChangeItem.getArtId());
- row[4] = String.valueOf(relationChangeItem.getBArtId());
- row[5] = relationChangeItem.getRationale();
- } else {
- throw new OseeStateException("Invalid change item type");
+ switch (item.getChangeType()) {
+ case ARTIFACT_CHANGE:
+ row = new String[4];
+ row[0] = ChangeItemType.ARTIFACT.name();
+ row[1] = String.valueOf(item.getItemId());
+ row[2] = String.valueOf(item.getItemTypeId());
+ row[3] = String.valueOf(item.isSynthetic());
+ break;
+ case ATTRIBUTE_CHANGE:
+ row = new String[4];
+ row[0] = ChangeItemType.ATTRIBUTE.name();
+ row[1] = String.valueOf(item.getItemId());
+ row[2] = String.valueOf(item.getItemTypeId());
+ row[3] = String.valueOf(item.getArtId());
+ break;
+ case RELATION_CHANGE:
+ row = new String[6];
+ row[0] = ChangeItemType.RELATION.name();
+ row[1] = String.valueOf(item.getItemId());
+ row[2] = String.valueOf(item.getItemTypeId());
+ row[3] = String.valueOf(item.getArtId());
+ row[4] = String.valueOf(item.getArtIdB());
+ row[5] = item.getCurrentVersion().getValue();
+ break;
+ default:
+ throw new OseeStateException("Invalid change item type");
}
return row;
@@ -151,12 +152,12 @@ public class ChangeReportResponseTranslator implements ITranslator<ChangeReportR
switch (type) {
case ARTIFACT:
boolean synthetic = Boolean.parseBoolean(row[3]);
- changeItem = new ArtifactChangeItem(itemId, itemTypeId, -1, ModificationType.NEW);
+ changeItem = ChangeItemUtil.newArtifactChange(itemId, itemTypeId, -1, ModificationType.NEW);
changeItem.setSynthetic(synthetic);
break;
case ATTRIBUTE:
int artId = Integer.parseInt(row[3]);
- changeItem = new AttributeChangeItem(itemId, itemTypeId, artId, -1, ModificationType.NEW, null);
+ changeItem = ChangeItemUtil.newAttributeChange(itemId, itemTypeId, artId, -1, ModificationType.NEW, null);
break;
case RELATION:
int aArtId = Integer.parseInt(row[3]);
@@ -164,7 +165,7 @@ public class ChangeReportResponseTranslator implements ITranslator<ChangeReportR
String rationale = row[5];
changeItem =
- new RelationChangeItem(itemId, itemTypeId, -1, ModificationType.NEW, aArtId, bArtId, rationale);
+ ChangeItemUtil.newRelationChange(itemId, itemTypeId, -1, ModificationType.NEW, aArtId, bArtId, rationale);
break;
default:
throw new OseeStateException("Invalid change item type");
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/ChangeTestUtility.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/ChangeTestUtility.java
index 33866a5c906..7b1cc304925 100644
--- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/ChangeTestUtility.java
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/ChangeTestUtility.java
@@ -40,8 +40,15 @@ public final class ChangeTestUtility {
}
public static ChangeItem createItem(int itemId, ChangeVersion base, ChangeVersion first, ChangeVersion current, ChangeVersion destination, ChangeVersion net) {
- MockChangeItem change =
- new MockChangeItem(itemId, itemId * 10, itemId * 100, current.getGammaId(), current.getModType());
+ ChangeItem change = new ChangeItem();
+ change.setItemId(itemId);
+ change.setItemTypeId(itemId * 10);
+ change.setArtId(itemId * 100);
+
+ ChangeVersion currentVersion = change.getCurrentVersion();
+ currentVersion.setGammaId(current.getGammaId());
+ currentVersion.setModType(current.getModType());
+
if (base != null) {
change.getBaselineVersion().copy(base);
}
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockChangeItem.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockChangeItem.java
deleted file mode 100644
index 11384d74043..00000000000
--- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockChangeItem.java
+++ /dev/null
@@ -1,24 +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.core.model.mocks;
-
-import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.model.change.ChangeItem;
-
-/**
- * @author Roberto E. Escobar
- */
-public class MockChangeItem extends ChangeItem {
-
- public MockChangeItem(int itemId, int itemTypeId, int artId, long currentSourceGammaId, ModificationType currentSourceModType) {
- super(itemId, itemTypeId, artId, currentSourceGammaId, currentSourceModType);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/AttributeChangeItem.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/AttributeChangeItem.java
deleted file mode 100644
index febd1d30c43..00000000000
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/AttributeChangeItem.java
+++ /dev/null
@@ -1,25 +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.core.model.change;
-
-import org.eclipse.osee.framework.core.enums.ModificationType;
-
-/**
- * @author Jeff C. Phillips
- */
-public class AttributeChangeItem extends ChangeItem {
-
- public AttributeChangeItem(int attrId, long attrTypeId, int artId, long currentSourceGammaId, ModificationType currentSourceModType, String value) {
- super(attrId, attrTypeId, artId, currentSourceGammaId, currentSourceModType);
- this.getCurrentVersion().setValue(value);
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItem.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItem.java
index 01152234ae4..ebb2ff46f63 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItem.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItem.java
@@ -10,43 +10,54 @@
*******************************************************************************/
package org.eclipse.osee.framework.core.model.change;
-import org.eclipse.osee.framework.core.enums.ModificationType;
-
/**
* @author Roberto E. Escobar
*/
-public abstract class ChangeItem implements Comparable<ChangeItem> {
- private final int artId;
- private final int itemId;
- private final long itemTypeId;
-
- private final ChangeVersion baseEntry;
- private final ChangeVersion firstChange;
- private final ChangeVersion currentEntry;
- private final ChangeVersion destinationEntry;
- private final ChangeVersion netEntry;
+public class ChangeItem implements Comparable<ChangeItem> {
- private boolean synthetic;
+ private ChangeType changeType = ChangeType.UNKNOWN_CHANGE;
+ private int artId = -1;
+ private int itemId = -1;
+ private long itemTypeId = -1;
- protected ChangeItem(int itemId, long itemTypeId, int artId, long currentSourceGammaId, ModificationType currentSourceModType) {
- this.itemId = itemId;
- this.itemTypeId = itemTypeId;
- this.artId = artId;
+ private ChangeVersion baselineVersion = new ChangeVersion();
+ private ChangeVersion firstNonCurrentChange = new ChangeVersion();
+ private ChangeVersion currentVersion = new ChangeVersion();
+ private ChangeVersion destinationVersion = new ChangeVersion();
+ private ChangeVersion netChange = new ChangeVersion();
- this.currentEntry = new ChangeVersion(currentSourceGammaId, currentSourceModType);
+ private boolean synthetic = false;
- this.baseEntry = new ChangeVersion();
- this.firstChange = new ChangeVersion();
- this.destinationEntry = new ChangeVersion();
- this.netEntry = new ChangeVersion();
+ private int artIdB = -1;
- this.synthetic = false;
+ public ChangeItem() {
+ super();
}
public void setSynthetic(boolean synthetic) {
this.synthetic = synthetic;
}
+ public ChangeType getChangeType() {
+ return changeType;
+ }
+
+ public void setChangeType(ChangeType changeType) {
+ this.changeType = changeType;
+ }
+
+ public void setArtId(int artId) {
+ this.artId = artId;
+ }
+
+ public void setItemId(int itemId) {
+ this.itemId = itemId;
+ }
+
+ public void setItemTypeId(long itemTypeId) {
+ this.itemTypeId = itemTypeId;
+ }
+
public boolean isSynthetic() {
return synthetic;
}
@@ -64,23 +75,51 @@ public abstract class ChangeItem implements Comparable<ChangeItem> {
}
public ChangeVersion getBaselineVersion() {
- return baseEntry;
+ return baselineVersion;
}
public ChangeVersion getFirstNonCurrentChange() {
- return firstChange;
+ return firstNonCurrentChange;
}
public ChangeVersion getCurrentVersion() {
- return currentEntry;
+ return currentVersion;
}
public ChangeVersion getDestinationVersion() {
- return destinationEntry;
+ return destinationVersion;
}
public ChangeVersion getNetChange() {
- return netEntry;
+ return netChange;
+ }
+
+ public void setBaselineVersion(ChangeVersion baselineVersion) {
+ this.baselineVersion = baselineVersion;
+ }
+
+ public void setFirstNonCurrentChange(ChangeVersion firstNonCurrentChange) {
+ this.firstNonCurrentChange = firstNonCurrentChange;
+ }
+
+ public void setCurrentVersion(ChangeVersion currentVersion) {
+ this.currentVersion = currentVersion;
+ }
+
+ public void setDestinationVersion(ChangeVersion destinationVersion) {
+ this.destinationVersion = destinationVersion;
+ }
+
+ public void setNetChange(ChangeVersion netChange) {
+ this.netChange = netChange;
+ }
+
+ public int getArtIdB() {
+ return artIdB;
+ }
+
+ public void setArtIdB(int artIdB) {
+ this.artIdB = artIdB;
}
@Override
@@ -108,12 +147,12 @@ public abstract class ChangeItem implements Comparable<ChangeItem> {
if (artId != other.artId) {
return false;
}
- if (currentEntry == null) {
- if (other.currentEntry != null) {
+ if (currentVersion == null) {
+ if (other.currentVersion != null) {
return false;
}
}
- if (!currentEntry.equals(other.currentEntry)) {
+ if (!currentVersion.equals(other.currentVersion)) {
return false;
}
if (itemTypeId != other.itemTypeId) {
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 79cf7dd2a02..325aed198eb 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
@@ -25,6 +25,57 @@ public final class ChangeItemUtil {
// Utility Class
}
+ public static ChangeItem newArtifactChange(int artId, long artTypeId, long currentSourceGammaId, ModificationType currentSourceModType) {
+ ChangeItem item = new ChangeItem();
+ item.setChangeType(ChangeType.ARTIFACT_CHANGE);
+
+ item.setItemId(artId);
+ item.setItemTypeId(artTypeId);
+ item.setSynthetic(false);
+
+ ChangeVersion current = item.getCurrentVersion();
+ current.setGammaId(currentSourceGammaId);
+ current.setModType(currentSourceModType);
+
+ item.setArtId(artId);
+ return item;
+ }
+
+ public static ChangeItem newAttributeChange(int attrId, long attrTypeId, int artId, long currentSourceGammaId, ModificationType currentSourceModType, String value) {
+ ChangeItem item = new ChangeItem();
+ item.setChangeType(ChangeType.ATTRIBUTE_CHANGE);
+
+ item.setItemId(attrId);
+ item.setItemTypeId(attrTypeId);
+ item.setSynthetic(false);
+
+ ChangeVersion current = item.getCurrentVersion();
+ current.setGammaId(currentSourceGammaId);
+ current.setModType(currentSourceModType);
+
+ item.setArtId(artId);
+ item.getCurrentVersion().setValue(value);
+ return item;
+ }
+
+ public static ChangeItem newRelationChange(int relLinkId, long relTypeId, long currentSourceGammaId, ModificationType currentSourceModType, int aArtId, int bArtId, String rationale) {
+ ChangeItem item = new ChangeItem();
+ item.setChangeType(ChangeType.RELATION_CHANGE);
+
+ item.setItemId(relLinkId);
+ item.setItemTypeId(relTypeId);
+ item.setSynthetic(false);
+
+ ChangeVersion current = item.getCurrentVersion();
+ current.setGammaId(currentSourceGammaId);
+ current.setModType(currentSourceModType);
+
+ item.setArtId(aArtId);
+ item.setArtIdB(bArtId);
+ item.getCurrentVersion().setValue(rationale);
+ return item;
+ }
+
public static ChangeVersion getStartingVersion(ChangeItem item) throws OseeCoreException {
if (item == null) {
throw new OseeArgumentException("ChangeItem cannot be null");
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ArtifactChangeItem.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeType.java
index bca1e07cb8a..c0370b73b38 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ArtifactChangeItem.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
+ * Copyright (c) 2015 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
@@ -10,14 +10,24 @@
*******************************************************************************/
package org.eclipse.osee.framework.core.model.change;
-import org.eclipse.osee.framework.core.enums.ModificationType;
-
/**
- * @author Jeff C. Phillips
+ * @author Roberto E. Escobar
*/
-public class ArtifactChangeItem extends ChangeItem {
+public enum ChangeType {
+ ARTIFACT_CHANGE,
+ ATTRIBUTE_CHANGE,
+ RELATION_CHANGE,
+ UNKNOWN_CHANGE;
+
+ public boolean isArtifactChange() {
+ return this == ARTIFACT_CHANGE;
+ }
+
+ public boolean isAttributeChange() {
+ return this == ATTRIBUTE_CHANGE;
+ }
- public ArtifactChangeItem(int artId, long artTypeId, long currentSourceGammaId, ModificationType currentSourceModType) {
- super(artId, artTypeId, artId, currentSourceGammaId, currentSourceModType);
+ public boolean isRelationChange() {
+ return this == RELATION_CHANGE;
}
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/RelationChangeItem.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/RelationChangeItem.java
deleted file mode 100644
index da0ce427393..00000000000
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/RelationChangeItem.java
+++ /dev/null
@@ -1,37 +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.core.model.change;
-
-import org.eclipse.osee.framework.core.enums.ModificationType;
-
-/**
- * @author Jeff C. Phillips
- */
-public class RelationChangeItem extends ChangeItem {
- private final int bArtId;
- private final String rationale;
-
- public RelationChangeItem(int relLinkId, long relTypeId, long currentSourceGammaId, ModificationType currentSourceModType, int aArtId, int bArtId, String rationale) {
- super(relLinkId, relTypeId, aArtId, currentSourceGammaId, currentSourceModType);
-
- this.getCurrentVersion().setValue(rationale);
- this.bArtId = bArtId;
- this.rationale = rationale;
- }
-
- public int getBArtId() {
- return bArtId;
- }
-
- public String getRationale() {
- return rationale;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeDataLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeDataLoader.java
index 88e14261b76..543e8693a16 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeDataLoader.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeDataLoader.java
@@ -29,12 +29,9 @@ import org.eclipse.osee.framework.core.message.ChangeReportResponse;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionDelta;
import org.eclipse.osee.framework.core.model.TransactionRecord;
-import org.eclipse.osee.framework.core.model.change.ArtifactChangeItem;
-import org.eclipse.osee.framework.core.model.change.AttributeChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItemUtil;
import org.eclipse.osee.framework.core.model.change.ChangeVersion;
-import org.eclipse.osee.framework.core.model.change.RelationChangeItem;
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.AbstractOperation;
@@ -203,53 +200,55 @@ public class ChangeDataLoader extends AbstractOperation {
Artifact changeArtifact = artifactDelta.getEndArtifact();
boolean isHistorical = txDelta.areOnTheSameBranch();
- if (item instanceof ArtifactChangeItem) {
- change =
- new ArtifactChange(startTxBranch, itemGammaId, itemId, txDelta, netModType, isHistorical, changeArtifact,
- artifactDelta);
- } else if (item instanceof AttributeChangeItem) {
- String isValue = item.getCurrentVersion().getValue();
- AttributeType attributeType = AttributeTypeManager.getTypeByGuid(item.getItemTypeId());
-
- String wasValue = "";
- if (!txDelta.areOnTheSameBranch()) {
- ChangeVersion netChange = item.getNetChange();
- if (!ChangeItemUtil.isNew(netChange) && !ChangeItemUtil.isIntroduced(netChange)) {
- ChangeVersion fromVersion = ChangeItemUtil.getStartingVersion(item);
- wasValue = fromVersion.getValue();
- }
- } else {
- Artifact startArtifact = artifactDelta.getBaseArtifact();
- if (startArtifact == null) {
- startArtifact = artifactDelta.getStartArtifact();
- }
- if (startArtifact != null) {
- wasValue = startArtifact.getAttributesToString(attributeType);
- if (wasValue == null) {
- wasValue = "";
+ switch (item.getChangeType()) {
+ case ARTIFACT_CHANGE:
+ change =
+ new ArtifactChange(startTxBranch, itemGammaId, itemId, txDelta, netModType, isHistorical,
+ changeArtifact, artifactDelta);
+ break;
+ case ATTRIBUTE_CHANGE:
+ String isValue = item.getCurrentVersion().getValue();
+ AttributeType attributeType = AttributeTypeManager.getTypeByGuid(item.getItemTypeId());
+
+ String wasValue = "";
+ if (!txDelta.areOnTheSameBranch()) {
+ ChangeVersion netChange = item.getNetChange();
+ if (!ChangeItemUtil.isNew(netChange) && !ChangeItemUtil.isIntroduced(netChange)) {
+ ChangeVersion fromVersion = ChangeItemUtil.getStartingVersion(item);
+ wasValue = fromVersion.getValue();
+ }
+ } else {
+ Artifact startArtifact = artifactDelta.getBaseArtifact();
+ if (startArtifact == null) {
+ startArtifact = artifactDelta.getStartArtifact();
+ }
+ if (startArtifact != null) {
+ wasValue = startArtifact.getAttributesToString(attributeType);
+ if (wasValue == null) {
+ wasValue = "";
+ }
}
}
- }
- change =
- new AttributeChange(startTxBranch, itemGammaId, artId, txDelta, netModType, isValue, wasValue, itemId,
- attributeType, netModType, isHistorical, changeArtifact, artifactDelta);
-
- } else if (item instanceof RelationChangeItem) {
- RelationChangeItem relationItem = (RelationChangeItem) item;
- RelationType relationType = RelationTypeManager.getTypeByGuid(relationItem.getItemTypeId());
-
- TransactionRecord transaction = txDelta.getStartTx();
- if (txDelta.areOnTheSameBranch()) {
- transaction = txDelta.getEndTx();
- }
- Artifact endTxBArtifact = bulkLoaded.get(transaction, relationItem.getBArtId());
-
- change =
- new RelationChange(startTxBranch, itemGammaId, artId, txDelta, netModType, endTxBArtifact.getArtId(),
- itemId, relationItem.getRationale(), relationType, isHistorical, changeArtifact, artifactDelta,
- endTxBArtifact);
- } else {
- throw new OseeCoreException("The change item must map to either an artifact, attribute or relation change");
+ change =
+ new AttributeChange(startTxBranch, itemGammaId, artId, txDelta, netModType, isValue, wasValue, itemId,
+ attributeType, netModType, isHistorical, changeArtifact, artifactDelta);
+ break;
+ case RELATION_CHANGE:
+ RelationType relationType = RelationTypeManager.getTypeByGuid(item.getItemTypeId());
+
+ TransactionRecord transaction = txDelta.getStartTx();
+ if (txDelta.areOnTheSameBranch()) {
+ transaction = txDelta.getEndTx();
+ }
+ Artifact endTxBArtifact = bulkLoaded.get(transaction, item.getArtIdB());
+
+ String rationale = item.getCurrentVersion().getValue();
+ change =
+ new RelationChange(startTxBranch, itemGammaId, artId, txDelta, netModType, endTxBArtifact.getArtId(),
+ itemId, rationale, relationType, isHistorical, changeArtifact, artifactDelta, endTxBArtifact);
+ break;
+ default:
+ throw new OseeCoreException("The change item must map to either an artifact, attribute or relation change");
}
return change;
}
@@ -284,8 +283,8 @@ public class ChangeDataLoader extends AbstractOperation {
Set<Integer> artIds = new HashSet<Integer>();
for (ChangeItem item : changeItems) {
artIds.add(item.getArtId());
- if (item instanceof RelationChangeItem) {
- artIds.add(((RelationChangeItem) item).getBArtId());
+ if (item.getChangeType().isRelationChange()) {
+ artIds.add(item.getArtIdB());
}
}
return artIds;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateFileDiffer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateFileDiffer.java
index 4ae9b99eb26..44c3d38fd87 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateFileDiffer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateFileDiffer.java
@@ -26,7 +26,6 @@ import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionDelta;
import org.eclipse.osee.framework.core.model.TransactionRecord;
-import org.eclipse.osee.framework.core.model.change.RelationChangeItem;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.logging.OseeLog;
@@ -134,7 +133,7 @@ public final class WordTemplateFileDiffer {
if (changeIds.contains(artId)) {
// If there is a change on the IS branch
Change newChange = findChange(artId, changes);
- if (newChange != null && !(newChange.getChangeItem() instanceof RelationChangeItem) && !addedIds.contains(artId)) {
+ if (newChange != null && !newChange.getChangeItem().getChangeType().isRelationChange() && !addedIds.contains(artId)) {
artifactDeltas.add(newChange.getDelta());
addedIds.add(artId);
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ChangeItemConflictTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ChangeItemConflictTest.java
index aaf16310618..bea7678a7d0 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ChangeItemConflictTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ChangeItemConflictTest.java
@@ -14,9 +14,8 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.model.change.ArtifactChangeItem;
-import org.eclipse.osee.framework.core.model.change.AttributeChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
+import org.eclipse.osee.framework.core.model.change.ChangeItemUtil;
import org.eclipse.osee.framework.core.model.change.ChangeVersion;
import org.junit.Assert;
import org.junit.Ignore;
@@ -89,9 +88,9 @@ public class ChangeItemConflictTest {
// but since we don't seem to handle the mixed case of say artifact on src and attribute on destination
ChangeItem item;
if (itemType == ItemType.artifact) {
- item = new ArtifactChangeItem(0, 0, GAMMA, ModificationType.MODIFIED);
+ item = ChangeItemUtil.newArtifactChange(0, 0, GAMMA, ModificationType.MODIFIED);
} else {
- item = new AttributeChangeItem(0, 0, 0, GAMMA, ModificationType.MODIFIED, "change");
+ item = ChangeItemUtil.newAttributeChange(0, 0, 0, GAMMA, ModificationType.MODIFIED, "change");
}
buildTestCase(GAMMA, item);
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ChangeTestUtility.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ChangeTestUtility.java
index 10a61647ab4..4d6ca457969 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ChangeTestUtility.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ChangeTestUtility.java
@@ -40,8 +40,16 @@ public final class ChangeTestUtility {
}
public static ChangeItem createItem(int itemId, ChangeVersion base, ChangeVersion first, ChangeVersion current, ChangeVersion destination, ChangeVersion net) {
- MockChangeItem change =
- new MockChangeItem(itemId, itemId * 10, itemId * 100, current.getGammaId(), current.getModType());
+ ChangeItem change = new ChangeItem();
+
+ change.setItemId(itemId);
+ change.setItemTypeId(itemId * 10);
+ change.setArtId(itemId * 100);
+
+ ChangeVersion currentVersion = change.getCurrentVersion();
+ currentVersion.setGammaId(current.getGammaId());
+ currentVersion.setModType(current.getModType());
+
if (base != null) {
change.getBaselineVersion().copy(base);
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryTest.java
index 4a56566a0aa..7658816a58b 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryTest.java
@@ -21,10 +21,8 @@ import java.util.List;
import org.eclipse.osee.executor.admin.HasCancellation;
import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.change.ArtifactChangeItem;
-import org.eclipse.osee.framework.core.model.change.AttributeChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
-import org.eclipse.osee.framework.core.model.change.RelationChangeItem;
+import org.eclipse.osee.framework.core.model.change.ChangeItemUtil;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.jdk.core.util.Strings;
@@ -184,7 +182,7 @@ public class MissingChangeItemFactoryTest {
long artGamma = 7L;
ChangeItem ci1 =
- new AttributeChangeItem(ci1AttrId, 2, artId, 4L, ModificationType.MODIFIED, Strings.EMPTY_STRING);
+ ChangeItemUtil.newAttributeChange(ci1AttrId, 2, artId, 4L, ModificationType.MODIFIED, Strings.EMPTY_STRING);
changes.add(ci1);
List<AttributeData> attrDatas = new LinkedList<AttributeData>();
@@ -217,7 +215,7 @@ public class MissingChangeItemFactoryTest {
int artA = 65;
int artB = 2;
long srcGamma = 7L;
- ChangeItem ci1 = new RelationChangeItem(relId, 0, srcGamma, ModificationType.NEW, artA, artB, "");
+ ChangeItem ci1 = ChangeItemUtil.newRelationChange(relId, 0, srcGamma, ModificationType.NEW, artA, artB, "");
changes.add(ci1);
List<AttributeData> attrDatas = new LinkedList<AttributeData>();
@@ -254,7 +252,8 @@ public class MissingChangeItemFactoryTest {
List<ChangeItem> changes = new LinkedList<ChangeItem>();
final int artId = 3;
- ChangeItem ci1 = new AttributeChangeItem(22, 2, artId, 4L, ModificationType.DELETED, Strings.EMPTY_STRING);
+ ChangeItem ci1 =
+ ChangeItemUtil.newAttributeChange(22, 2, artId, 4L, ModificationType.DELETED, Strings.EMPTY_STRING);
changes.add(ci1);
List<AttributeData> attrDatas = new LinkedList<AttributeData>();
@@ -283,7 +282,7 @@ public class MissingChangeItemFactoryTest {
final int artId = 3;
ChangeItem ci1 =
- new AttributeChangeItem(22, 2, artId, 4L, ModificationType.ARTIFACT_DELETED, Strings.EMPTY_STRING);
+ ChangeItemUtil.newAttributeChange(22, 2, artId, 4L, ModificationType.ARTIFACT_DELETED, Strings.EMPTY_STRING);
changes.add(ci1);
List<AttributeData> attrDatas = new LinkedList<AttributeData>();
@@ -312,18 +311,19 @@ public class MissingChangeItemFactoryTest {
}
}
- private static RelationChangeItem createExpected(RelationData data) {
- return new RelationChangeItem(data.getLocalId(), 0, data.getVersion().getGammaId(), determineModType(data),
- data.getArtIdA(), data.getArtIdB(), "");
+ private static ChangeItem createExpected(RelationData data) {
+ return ChangeItemUtil.newRelationChange(data.getLocalId(), 0, data.getVersion().getGammaId(),
+ determineModType(data), data.getArtIdA(), data.getArtIdB(), "");
}
- private static AttributeChangeItem createExpected(AttributeData data) {
- return new AttributeChangeItem(data.getLocalId(), 0, data.getArtifactId(), data.getVersion().getGammaId(),
- determineModType(data), "");
+ private static ChangeItem createExpected(AttributeData data) {
+ return ChangeItemUtil.newAttributeChange(data.getLocalId(), 0, data.getArtifactId(),
+ data.getVersion().getGammaId(), determineModType(data), "");
}
- private static ArtifactChangeItem createExpected(ArtifactData data) {
- return new ArtifactChangeItem(data.getLocalId(), 0, data.getVersion().getGammaId(), determineModType(data));
+ private static ChangeItem createExpected(ArtifactData data) {
+ return ChangeItemUtil.newArtifactChange(data.getLocalId(), 0, data.getVersion().getGammaId(),
+ determineModType(data));
}
private ChangeItem getMatchingChangeItem(ChangeItem item) {
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MockChangeItem.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MockChangeItem.java
deleted file mode 100644
index e04ebd81149..00000000000
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MockChangeItem.java
+++ /dev/null
@@ -1,24 +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.orcs.db.internal.change;
-
-import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.model.change.ChangeItem;
-
-/**
- * @author Roberto E. Escobar
- */
-public class MockChangeItem extends ChangeItem {
-
- public MockChangeItem(int itemId, int itemTypeId, int artId, long currentSourceGammaId, ModificationType currentSourceModType) {
- super(itemId, itemTypeId, artId, currentSourceGammaId, currentSourceModType);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java
index fa2223cd7d5..79dfa29d7e5 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java
@@ -18,10 +18,7 @@ import org.eclipse.osee.framework.core.enums.ConflictStatus;
import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.core.enums.TxChange;
-import org.eclipse.osee.framework.core.model.change.ArtifactChangeItem;
-import org.eclipse.osee.framework.core.model.change.AttributeChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
-import org.eclipse.osee.framework.core.model.change.RelationChangeItem;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
@@ -127,14 +124,18 @@ public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<
UpdatePreviousTxCurrent updater =
new UpdatePreviousTxCurrent(getJdbcClient(), joinFactory, connection, destinationBranch.getUuid());
for (ChangeItem change : changes) {
- if (change instanceof ArtifactChangeItem) {
- updater.addArtifact(change.getItemId());
- } else if (change instanceof AttributeChangeItem) {
- updater.addAttribute(change.getItemId());
- } else if (change instanceof RelationChangeItem) {
- updater.addRelation(change.getItemId());
- } else {
- throw new OseeStateException("Unexpected change type");
+ switch (change.getChangeType()) {
+ case ARTIFACT_CHANGE:
+ updater.addArtifact(change.getItemId());
+ break;
+ case ATTRIBUTE_CHANGE:
+ updater.addAttribute(change.getItemId());
+ break;
+ case RELATION_CHANGE:
+ updater.addRelation(change.getItemId());
+ break;
+ default:
+ throw new OseeStateException("Unexpected change type");
}
}
updater.updateTxNotCurrents();
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/AddArtifactChangeDataCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/AddArtifactChangeDataCallable.java
index 4d930f863da..fc0f40ee680 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/AddArtifactChangeDataCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/AddArtifactChangeDataCallable.java
@@ -16,8 +16,6 @@ import java.util.List;
import java.util.Map;
import org.eclipse.osee.executor.admin.CancellableCallable;
import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.model.change.ArtifactChangeItem;
-import org.eclipse.osee.framework.core.model.change.AttributeChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItemUtil;
@@ -31,27 +29,26 @@ public class AddArtifactChangeDataCallable extends CancellableCallable<List<Chan
@Override
public List<ChangeItem> call() throws Exception {
- Map<Integer, ArtifactChangeItem> artifactChanges = new HashMap<Integer, ArtifactChangeItem>();
+ Map<Integer, ChangeItem> artifactChanges = new HashMap<Integer, ChangeItem>();
for (ChangeItem item : changeItems) {
- if (item instanceof ArtifactChangeItem) {
- ArtifactChangeItem artItem = (ArtifactChangeItem) item;
- artifactChanges.put(artItem.getArtId(), artItem);
+ if (item.getChangeType().isArtifactChange()) {
+ artifactChanges.put(item.getArtId(), item);
}
}
- List<AttributeChangeItem> attrItems = new ArrayList<AttributeChangeItem>();
- Map<Integer, ArtifactChangeItem> syntheticArtifactChanges = new HashMap<Integer, ArtifactChangeItem>();
+ List<ChangeItem> attrItems = new ArrayList<ChangeItem>();
+ Map<Integer, ChangeItem> syntheticArtifactChanges = new HashMap<Integer, ChangeItem>();
for (ChangeItem item : changeItems) {
- if (item instanceof AttributeChangeItem) {
- AttributeChangeItem attributeChange = (AttributeChangeItem) item;
+ if (item.getChangeType().isAttributeChange()) {
+ ChangeItem attributeChange = item;
Integer artIdToCheck = attributeChange.getArtId();
- ArtifactChangeItem artifactChange = artifactChanges.get(artIdToCheck);
+ ChangeItem artifactChange = artifactChanges.get(artIdToCheck);
if (artifactChange == null) {
artifactChange = syntheticArtifactChanges.get(artIdToCheck);
if (artifactChange == null) {
- artifactChange = new ArtifactChangeItem(artIdToCheck, -1, -1, null);
+ artifactChange = ChangeItemUtil.newArtifactChange(artIdToCheck, -1, -1, null);
syntheticArtifactChanges.put(artIdToCheck, artifactChange);
artifactChange.setSynthetic(true);
}
@@ -64,7 +61,7 @@ public class AddArtifactChangeDataCallable extends CancellableCallable<List<Chan
return changeItems;
}
- private void updateArtifactChangeItem(ArtifactChangeItem artifact, AttributeChangeItem attribute) {
+ private void updateArtifactChangeItem(ChangeItem artifact, ChangeItem attribute) {
try {
if (!artifact.getBaselineVersion().isValid() && attribute.getBaselineVersion().isValid()) {
ChangeItemUtil.copy(attribute.getBaselineVersion(), artifact.getBaselineVersion());
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/ArtifactChangeItemFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/ArtifactChangeItemFactory.java
index 26991785cd8..8f5b8c65fc8 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/ArtifactChangeItemFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/ArtifactChangeItemFactory.java
@@ -12,8 +12,8 @@ package org.eclipse.osee.orcs.db.internal.change;
import java.util.HashMap;
import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.model.change.ArtifactChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
+import org.eclipse.osee.framework.core.model.change.ChangeItemUtil;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.jdbc.JdbcStatement;
import org.eclipse.osee.orcs.db.internal.change.ChangeItemLoader.ChangeItemFactory;
@@ -42,7 +42,7 @@ public final class ArtifactChangeItemFactory implements ChangeItemFactory {
long gammaId = chStmt.getLong("gamma_id");
ModificationType modType = changeByGammaId.get(gammaId);
- return new ArtifactChangeItem(artId, artTypeId, gammaId, modType);
+ return ChangeItemUtil.newArtifactChange(artId, artTypeId, gammaId, modType);
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/AttributeChangeItemFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/AttributeChangeItemFactory.java
index f3d162d3784..d53dca584e0 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/AttributeChangeItemFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/AttributeChangeItemFactory.java
@@ -12,8 +12,8 @@ package org.eclipse.osee.orcs.db.internal.change;
import java.util.HashMap;
import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.model.change.AttributeChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
+import org.eclipse.osee.framework.core.model.change.ChangeItemUtil;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.jdbc.JdbcStatement;
import org.eclipse.osee.orcs.db.internal.change.ChangeItemLoader.ChangeItemFactory;
@@ -45,7 +45,7 @@ public final class AttributeChangeItemFactory implements ChangeItemFactory {
String value = chStmt.getString("value");
- return new AttributeChangeItem(attrId, attrTypeId, artId, gammaId, modType, value);
+ return ChangeItemUtil.newAttributeChange(attrId, attrTypeId, artId, gammaId, modType, value);
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java
index 669897f071a..2853f4138ce 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java
@@ -21,11 +21,10 @@ import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.LoadLevel;
import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.model.change.ArtifactChangeItem;
-import org.eclipse.osee.framework.core.model.change.AttributeChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
-import org.eclipse.osee.framework.core.model.change.RelationChangeItem;
+import org.eclipse.osee.framework.core.model.change.ChangeItemUtil;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
import org.eclipse.osee.orcs.core.ds.AttributeData;
@@ -58,15 +57,21 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory {
Multimap<Integer, Integer> modifiedRels = LinkedListMultimap.create();
for (ChangeItem change : changes) {
- if (change instanceof AttributeChangeItem) {
- modifiedAttrIds.put(change.getArtId(), change.getItemId());
- } else if (change instanceof ArtifactChangeItem) {
- if (!change.isSynthetic()) {
- modifiedArtIds.add(change.getArtId());
- }
- } else if (change instanceof RelationChangeItem) {
- modifiedRels.put(change.getArtId(), change.getItemId());
- modifiedRels.put(((RelationChangeItem) change).getBArtId(), change.getItemId());
+ switch (change.getChangeType()) {
+ case ARTIFACT_CHANGE:
+ if (!change.isSynthetic()) {
+ modifiedArtIds.add(change.getArtId());
+ }
+ break;
+ case ATTRIBUTE_CHANGE:
+ modifiedAttrIds.put(change.getArtId(), change.getItemId());
+ break;
+ case RELATION_CHANGE:
+ modifiedRels.put(change.getArtId(), change.getItemId());
+ modifiedRels.put(change.getArtIdB(), change.getItemId());
+ break;
+ default:
+ throw new OseeStateException("Unknonw change type detected [%s]", change);
}
}
@@ -162,8 +167,8 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory {
return TokenFactory.createBranch(tx.getBranchId(), "Missing Change Items");
}
- private Set<RelationChangeItem> createExistingRelations(HasCancellation cancellation, OrcsSession session, TransactionReadable destTx, final Multimap<Integer, RelationData> relationChangesToAdd) throws OseeCoreException {
- final Set<RelationChangeItem> toReturn = new LinkedHashSet<RelationChangeItem>();
+ private Set<ChangeItem> createExistingRelations(HasCancellation cancellation, OrcsSession session, TransactionReadable destTx, final Multimap<Integer, RelationData> relationChangesToAdd) throws OseeCoreException {
+ final Set<ChangeItem> toReturn = new LinkedHashSet<ChangeItem>();
DataLoader loader =
dataLoaderFactory.newDataLoaderFromIds(session, getBranch(destTx), relationChangesToAdd.keySet());
@@ -188,23 +193,23 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory {
}
}
- private ArtifactChangeItem createArtifactChangeItem(ArtifactData data) throws OseeCoreException {
- ArtifactChangeItem artChange =
- new ArtifactChangeItem(data.getLocalId(), data.getTypeUuid(), data.getVersion().getGammaId(),
+ private ChangeItem createArtifactChangeItem(ArtifactData data) throws OseeCoreException {
+ ChangeItem artChange =
+ ChangeItemUtil.newArtifactChange(data.getLocalId(), data.getTypeUuid(), data.getVersion().getGammaId(),
determineModType(data));
return artChange;
}
- private AttributeChangeItem createAttributeChangeItem(AttributeData data) throws OseeCoreException {
- AttributeChangeItem attrChange =
- new AttributeChangeItem(data.getLocalId(), data.getTypeUuid(), data.getArtifactId(),
+ private ChangeItem createAttributeChangeItem(AttributeData data) throws OseeCoreException {
+ ChangeItem attrChange =
+ ChangeItemUtil.newAttributeChange(data.getLocalId(), data.getTypeUuid(), data.getArtifactId(),
data.getVersion().getGammaId(), determineModType(data), data.getDataProxy().getDisplayableString());
attrChange.getNetChange().copy(attrChange.getCurrentVersion());
return attrChange;
}
- private RelationChangeItem createRelationChangeItem(RelationData data) throws OseeCoreException {
- return new RelationChangeItem(data.getLocalId(), data.getTypeUuid(), data.getVersion().getGammaId(),
+ private ChangeItem createRelationChangeItem(RelationData data) throws OseeCoreException {
+ return ChangeItemUtil.newRelationChange(data.getLocalId(), data.getTypeUuid(), data.getVersion().getGammaId(),
determineModType(data), data.getArtIdA(), data.getArtIdB(), data.getRationale());
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/RelationChangeItemFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/RelationChangeItemFactory.java
index c15e7db25b0..f13735e3ea3 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/RelationChangeItemFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/RelationChangeItemFactory.java
@@ -13,7 +13,7 @@ package org.eclipse.osee.orcs.db.internal.change;
import java.util.HashMap;
import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
-import org.eclipse.osee.framework.core.model.change.RelationChangeItem;
+import org.eclipse.osee.framework.core.model.change.ChangeItemUtil;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.jdbc.JdbcStatement;
import org.eclipse.osee.orcs.db.internal.change.ChangeItemLoader.ChangeItemFactory;
@@ -46,7 +46,7 @@ public final class RelationChangeItemFactory implements ChangeItemFactory {
int bArtId = chStmt.getInt("b_art_id");
String rationale = chStmt.getString("rationale");
- return new RelationChangeItem(relLinkId, relTypeId, gammaId, modType, aArtId, bArtId, rationale);
+ return ChangeItemUtil.newRelationChange(relLinkId, relTypeId, gammaId, modType, aArtId, bArtId, rationale);
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/conflict/ConflictUtil.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/conflict/ConflictUtil.java
index f9c28c0f41e..ac768f9b33d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/conflict/ConflictUtil.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/conflict/ConflictUtil.java
@@ -14,10 +14,7 @@ import org.eclipse.osee.framework.core.enums.ConflictStatus;
import org.eclipse.osee.framework.core.enums.ConflictType;
import org.eclipse.osee.framework.core.enums.StorageState;
import org.eclipse.osee.framework.core.model.MergeBranch;
-import org.eclipse.osee.framework.core.model.change.ArtifactChangeItem;
-import org.eclipse.osee.framework.core.model.change.AttributeChangeItem;
import org.eclipse.osee.framework.core.model.change.ChangeItem;
-import org.eclipse.osee.framework.core.model.change.RelationChangeItem;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -73,14 +70,18 @@ public final class ConflictUtil {
public static ConflictType toConflictType(ChangeItem item) throws OseeCoreException {
ConflictType type = null;
- if (item instanceof ArtifactChangeItem) {
- type = ConflictType.ARTIFACT;
- } else if (item instanceof AttributeChangeItem) {
- type = ConflictType.ATTRIBUTE;
- } else if (item instanceof RelationChangeItem) {
- type = ConflictType.RELATION;
- } else {
- throw new OseeArgumentException("Unable to convert change item [%s] to conflict type", item);
+ switch (item.getChangeType()) {
+ case ARTIFACT_CHANGE:
+ type = ConflictType.ARTIFACT;
+ break;
+ case ATTRIBUTE_CHANGE:
+ type = ConflictType.ATTRIBUTE;
+ break;
+ case RELATION_CHANGE:
+ type = ConflictType.RELATION;
+ break;
+ default:
+ throw new OseeArgumentException("Unable to convert change item [%s] to conflict type", item);
}
return type;
}

Back to the top