Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2017-01-31 18:15:39 +0000
committerDavid W. Miller2017-01-31 18:15:39 +0000
commit2bdc6937dec65677d3bc3bfb3b6f71b0d211dfa9 (patch)
treea6a508adcc63291f30ed8e879de0cb1bdd26a73b /plugins
parent294d1adcb7622071fc793654484c71b42779d719 (diff)
downloadorg.eclipse.osee-2bdc6937dec65677d3bc3bfb3b6f71b0d211dfa9.tar.gz
org.eclipse.osee-2bdc6937dec65677d3bc3bfb3b6f71b0d211dfa9.tar.xz
org.eclipse.osee-2bdc6937dec65677d3bc3bfb3b6f71b0d211dfa9.zip
refactor: Remove redundancy in WfeInput hierarchicy
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeInput.java71
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeInputFactory.java35
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeReloadTab.java7
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorInput.java26
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorInputFactory.java35
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactEditorReloadTab.java9
6 files changed, 71 insertions, 112 deletions
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeInput.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeInput.java
index e57ec3bdf54..a60750ba0e2 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeInput.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeInput.java
@@ -14,6 +14,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osee.ats.AtsImage;
import org.eclipse.osee.ats.agile.AgileUtilClient;
import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditorInput;
@@ -24,57 +25,14 @@ import org.eclipse.ui.IPersistableElement;
/**
* @author Donald G. Dunne
*/
-public class WfeInput extends ArtifactEditorInput implements IPersistableElement {
-
- private final boolean pend;
- private int artUuid;
- private String title;
- private BranchId branch;
+public class WfeInput extends ArtifactEditorInput {
public WfeInput(Artifact artifact) {
- this(artifact, false);
- }
-
- public WfeInput(Artifact artifact, boolean pend) {
super(artifact);
- this.pend = pend;
}
- public WfeInput(BranchId branch, int artUuid, String title) {
- this(null);
- this.branch = branch;
- this.artUuid = artUuid;
- this.title = title;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + artUuid;
- result = prime * result + (int) (branch.getId() ^ branch.getId() >>> 32);
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- WfeInput other = (WfeInput) obj;
- if (artUuid != other.artUuid) {
- return false;
- }
- if (!branch.equals(other.branch)) {
- return false;
- }
- return true;
+ public WfeInput(BranchId branch, ArtifactId artUuid, String title) {
+ super(branch, artUuid, title);
}
@Override
@@ -82,10 +40,6 @@ public class WfeInput extends ArtifactEditorInput implements IPersistableElement
return getArtifact() == null;
}
- public boolean isPend() {
- return pend;
- }
-
@Override
public IPersistableElement getPersistable() {
return this;
@@ -101,21 +55,9 @@ public class WfeInput extends ArtifactEditorInput implements IPersistableElement
return WfeInputFactory.ID;
}
- public int getArtUuid() {
- return artUuid;
- }
-
- public BranchId getBranchId() {
- return branch;
- }
-
- public String getTitle() {
- return title;
- }
-
@Override
public String getName() {
- String name = title;
+ String name = getSavedTitle();
if (getArtifact() != null && !getArtifact().isDeleted()) {
if (isBacklog()) {
name = "Backlog: " + getArtifact().getName();
@@ -137,5 +79,4 @@ public class WfeInput extends ArtifactEditorInput implements IPersistableElement
}
return ImageManager.getImageDescriptor(AtsImage.TEAM_WORKFLOW);
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeInputFactory.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeInputFactory.java
index 00b01e449fd..a8d694c3926 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeInputFactory.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeInputFactory.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.ats.editor;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.ui.IElementFactory;
@@ -25,6 +26,7 @@ public class WfeInputFactory implements IElementFactory {
public final static String ID = "org.eclipse.osee.ats.WEEditorInputFactory"; //$NON-NLS-1$
public final static String ART_KEY = "org.eclipse.osee.ats.WEEditorInputFactory.artUuid"; //$NON-NLS-1$
+ public final static String ART_KEY_AS_LONG = "org.eclipse.osee.ats.WEEditorInputFactory.artUuidAsLong"; //$NON-NLS-1$
public final static String BRANCH_KEY = "org.eclipse.osee.ats.WEEditorInputFactory.branchUuid"; //$NON-NLS-1$
public final static String TITLE = "org.eclipse.osee.ats.WEEditorInputFactory.title"; //$NON-NLS-1$
@@ -36,29 +38,38 @@ public class WfeInputFactory implements IElementFactory {
*/
@Override
public IAdaptable createElement(IMemento memento) {
- BranchId branch = BranchId.SENTINEL;
- if (Strings.isValid(memento.getString(BRANCH_KEY))) {
- branch = BranchId.valueOf(memento.getString(BRANCH_KEY));
+ String branchStr = memento.getString(BRANCH_KEY);
+ BranchId branch = branchStr == null ? BranchId.SENTINEL : BranchId.valueOf(branchStr);
+
+ ArtifactId artifactId;
+
+ String artKeyAsLong = memento.getString(ART_KEY_AS_LONG);
+ if (Strings.isValid(artKeyAsLong)) {
+ artifactId = ArtifactId.valueOf(artKeyAsLong);
+ } else {
+ String artKeyAsInt = memento.getString(ART_KEY);
+ artifactId = artKeyAsInt == null ? ArtifactId.SENTINEL : ArtifactId.valueOf(artKeyAsInt);
}
- Integer artUuid = memento.getInteger(ART_KEY);
+
String title = memento.getString(TITLE);
- return new WfeInput(branch, artUuid == null ? 0 : artUuid, title);
+ return new WfeInput(branch, artifactId, title);
}
public static void saveState(IMemento memento, WfeInput input) {
- int artUuid = input.getArtUuid();
+ ArtifactId artifactId = input.getArtUuid();
BranchId branch = input.getBranchId();
- String title = input.getTitle();
+ String title = input.getSavedTitle();
if (input.getArtifact() != null && !input.getArtifact().isDeleted()) {
- artUuid = input.getArtifact().getArtId();
+ artifactId = input.getArtifact();
branch = input.getArtifact().getBranch();
title = input.getName();
}
- if (artUuid > 0 && branch.isValid() && Strings.isValid(title)) {
+ if (artifactId.isValid() && branch.isValid() && Strings.isValid(title)) {
memento.putString(BRANCH_KEY, branch.getIdString());
- memento.putInteger(ART_KEY, artUuid);
+ // Keep Storing the id as an Int so that the release can still read the workspace
+ memento.putInteger(ART_KEY, artifactId.getId().intValue());
+ memento.putString(ART_KEY_AS_LONG, artifactId.getIdString());
memento.putString(TITLE, title);
}
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeReloadTab.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeReloadTab.java
index 4892745128c..52f2c9c47db 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeReloadTab.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/WfeReloadTab.java
@@ -22,6 +22,7 @@ import org.eclipse.osee.ats.AtsImage;
import org.eclipse.osee.ats.core.client.config.AtsBulkLoad;
import org.eclipse.osee.ats.internal.Activator;
import org.eclipse.osee.ats.internal.AtsClientService;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -61,14 +62,14 @@ public class WfeReloadTab extends FormPage {
public final static String ID = "ats.reload.tab";
private final WorkflowEditor editor;
private final String title;
- private final int artUuid;
+ private final ArtifactId artUuid;
private final BranchId branch;
public WfeReloadTab(WorkflowEditor editor) {
super(editor, ID, "Reload");
this.editor = editor;
this.artUuid = editor.getWfeInput().getArtUuid();
- this.title = editor.getWfeInput().getTitle();
+ this.title = editor.getWfeInput().getSavedTitle();
this.branch = editor.getWfeInput().getBranchId();
}
@@ -183,7 +184,7 @@ public class WfeReloadTab extends FormPage {
@Override
protected IStatus run(IProgressMonitor monitor) {
- if (artUuid > 0 && AtsClientService.get().getAtsBranch().equals(branch)) {
+ if (artUuid.isValid() && AtsClientService.get().getAtsBranch().equals(branch)) {
try {
artifact = ArtifactQuery.getArtifactFromId(artUuid, AtsClientService.get().getAtsBranch());
} catch (ArtifactDoesNotExist ex) {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorInput.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorInput.java
index 7f01631a732..cfc54808ee4 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorInput.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorInput.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.framework.ui.skynet.artifact.editor;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
@@ -28,7 +29,7 @@ import org.eclipse.ui.IPersistableElement;
public class ArtifactEditorInput implements IEditorInput, IPersistableElement {
private Artifact artifact;
private BranchId savedBranchId;
- private Long savedArtUuid;
+ private ArtifactId savedArtUuid;
private String savedTitle;
private boolean attemptedReload = false;
@@ -36,9 +37,9 @@ public class ArtifactEditorInput implements IEditorInput, IPersistableElement {
this.artifact = artifact;
}
- public ArtifactEditorInput(BranchId branchId, Long artUuid, String title) {
+ public ArtifactEditorInput(BranchId branchId, ArtifactId artifactId, String title) {
this.savedBranchId = branchId;
- this.savedArtUuid = artUuid;
+ this.savedArtUuid = artifactId;
this.savedTitle = title;
}
@@ -141,7 +142,7 @@ public class ArtifactEditorInput implements IEditorInput, IPersistableElement {
return result;
}
- private BranchId getBranchId() {
+ public BranchId getBranchId() {
BranchId id = BranchId.SENTINEL;
if (artifact != null) {
id = artifact.getBranch();
@@ -151,22 +152,21 @@ public class ArtifactEditorInput implements IEditorInput, IPersistableElement {
return id;
}
- private Long getArtUuid() {
- Long uuid = 0L;
+ public ArtifactId getArtUuid() {
+ ArtifactId artifactId = ArtifactId.SENTINEL;
if (artifact != null) {
- uuid = artifact.getUuid();
+ artifactId = artifact;
} else if (savedArtUuid != null) {
- uuid = savedArtUuid;
+ artifactId = savedArtUuid;
}
- return uuid;
+ return artifactId;
}
@Override
public boolean equals(Object obj) {
-
if (obj instanceof ArtifactEditorInput) {
ArtifactEditorInput other = (ArtifactEditorInput) obj;
- if (!getArtUuid().equals(other.getArtUuid())) {
+ if (getArtUuid().notEqual(other.getArtUuid())) {
return false;
}
return getBranchId().equals(other.getBranchId());
@@ -178,11 +178,11 @@ public class ArtifactEditorInput implements IEditorInput, IPersistableElement {
return savedBranchId;
}
- public Long getSavedArtUuid() {
+ public ArtifactId getSavedArtUuid() {
return savedArtUuid;
}
public String getSavedTitle() {
return savedTitle;
}
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorInputFactory.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorInputFactory.java
index 058ba469a73..570c76bc2d6 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorInputFactory.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorInputFactory.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.framework.ui.skynet.artifact.editor;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
@@ -25,26 +26,31 @@ import org.eclipse.ui.IMemento;
public class ArtifactEditorInputFactory implements IElementFactory {
public final static String ID = "org.eclipse.osee.framework.ui.skynet.ArtifactEditorInputFactory"; //$NON-NLS-1$
- public final static String ART_UUID = "org.eclipse.osee.framework.ui.skynet.ArtifactEditorInputFactory.uuid"; //$NON-NLS-1$
- public final static String BRANCH_KEY = "org.eclipse.osee.framework.ui.skynet.ArtifactEditorInputFactory.branchUuid"; //$NON-NLS-1$
- public final static String TITLE = "org.eclipse.osee.framework.ui.skynet.ArtifactEditorInputFactory.title"; //$NON-NLS-1$
+ private final static String ART_KEY = "org.eclipse.osee.framework.ui.skynet.ArtifactEditorInputFactory.uuid"; //$NON-NLS-1$
+ private final static String ART_KEY_AS_LONG = "org.eclipse.osee.ats.WEEditorInputFactory.artIdAsLong"; //$NON-NLS-1$
+ private final static String BRANCH_KEY =
+ "org.eclipse.osee.framework.ui.skynet.ArtifactEditorInputFactory.branchUuid"; //$NON-NLS-1$
+ private final static String TITLE = "org.eclipse.osee.framework.ui.skynet.ArtifactEditorInputFactory.title"; //$NON-NLS-1$
public ArtifactEditorInputFactory() {
}
@Override
public IAdaptable createElement(IMemento memento) {
- BranchId branchId = BranchId.SENTINEL;
String title = memento.getString(TITLE);
- if (Strings.isValid(memento.getString(BRANCH_KEY))) {
- branchId = BranchId.valueOf(memento.getString(BRANCH_KEY));
- }
- Integer artUuid = null;
- String artUuidStr = memento.getString(ART_UUID);
- if (Strings.isValid(artUuidStr)) {
- artUuid = Integer.valueOf(artUuidStr);
+ String branchStr = memento.getString(BRANCH_KEY);
+ BranchId branch = branchStr == null ? BranchId.SENTINEL : BranchId.valueOf(branchStr);
+
+ ArtifactId artifactId;
+ String artKeyAsLong = memento.getString(ART_KEY_AS_LONG);
+ if (Strings.isValid(artKeyAsLong)) {
+ artifactId = ArtifactId.valueOf(artKeyAsLong);
+ } else {
+ String artKeyAsInt = memento.getString(ART_KEY);
+ artifactId = artKeyAsInt == null ? ArtifactId.SENTINEL : ArtifactId.valueOf(artKeyAsInt);
}
- return new ArtifactEditorInput(branchId, (artUuid == null ? null : Long.valueOf(artUuid)), title);
+
+ return new ArtifactEditorInput(branch, artifactId, title);
}
public static void saveState(IMemento memento, ArtifactEditorInput input) {
@@ -55,10 +61,9 @@ public class ArtifactEditorInputFactory implements IElementFactory {
long branchUuid = artifact.getBranchId();
if (Strings.isValid(artUuid) && branchUuid > 0 && Strings.isValid(title)) {
memento.putString(BRANCH_KEY, String.valueOf(branchUuid));
- memento.putString(ART_UUID, artUuid);
+ memento.putString(ART_KEY, artUuid);
memento.putString(TITLE, title);
}
}
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactEditorReloadTab.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactEditorReloadTab.java
index a616f65f4dd..5e7b209d37c 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactEditorReloadTab.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactEditorReloadTab.java
@@ -17,6 +17,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -54,13 +55,13 @@ public class ArtifactEditorReloadTab extends FormPage {
public final static String ID = "artifact.editor.reload.tab";
private final ArtifactEditor editor;
private final String title;
- private final long artUuid;
+ private final ArtifactId artifactId;
private final BranchId branchId;
public ArtifactEditorReloadTab(ArtifactEditor editor) {
super(editor, ID, "Reload");
this.editor = editor;
- this.artUuid = editor.getEditorInput().getSavedArtUuid();
+ this.artifactId = editor.getEditorInput().getSavedArtUuid();
this.title = editor.getEditorInput().getSavedTitle();
this.branchId = editor.getEditorInput().getSavedBranchId();
}
@@ -167,9 +168,9 @@ public class ArtifactEditorReloadTab extends FormPage {
@Override
protected IStatus run(IProgressMonitor monitor) {
- if (artUuid > 0) {
+ if (artifactId.isValid()) {
try {
- artifact = ArtifactQuery.getArtifactFromId(artUuid, branchId);
+ artifact = ArtifactQuery.getArtifactFromId(artifactId, branchId);
} catch (ArtifactDoesNotExist ex) {
// do nothing
}

Back to the top