Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Avila2015-03-19 17:34:51 -0400
committerAngel Avila2015-03-19 17:34:51 -0400
commit16d6f7ef8479b053a3df4b0f66411306e86d5f7e (patch)
tree655097e1908d1959cdff22d9ee90b92e530629b1 /plugins/org.eclipse.osee.framework.core.message/src/org
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/org.eclipse.osee.framework.core.message/src/org')
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/ChangeReportResponseTranslator.java59
1 files changed, 30 insertions, 29 deletions
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 813112ee6c..e9cdc59d2f 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");

Back to the top