Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorInput.java22
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorInputFactory.java25
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorReloadProvider.java49
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java14
4 files changed, 60 insertions, 50 deletions
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorInput.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorInput.java
index 31b03eb2c2..04ffa18358 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorInput.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorInput.java
@@ -18,9 +18,11 @@ import org.eclipse.osee.ats.internal.Activator;
import org.eclipse.osee.ats.search.AtsSearchWorkflowSearchItem;
import org.eclipse.osee.ats.world.search.WorldSearchItem;
import org.eclipse.osee.framework.core.data.Adaptable;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IMemento;
@@ -101,13 +103,15 @@ public class WorldEditorInput implements IEditorInput, IPersistableElement, Adap
}
}
- public Collection<Integer> getGuids() {
+ public String getIdString() {
+ Collection<? extends ArtifactId> artifactIds;
if (editor.isReloadTabShown() && iWorldEditorProvider instanceof WorldEditorReloadProvider) {
WorldEditorReloadProvider provider = (WorldEditorReloadProvider) iWorldEditorProvider;
- return provider.getValidArtUuids();
+ artifactIds = provider.getValidArtUuids();
} else {
- return Artifacts.toIds(editor.getLoadedArtifacts());
+ artifactIds = editor.getLoadedArtifacts();
}
+ return Collections.toString(artifactIds, ",", ArtifactId::getIdString);
}
public WorldEditor getEditor() {
@@ -127,17 +131,17 @@ public class WorldEditorInput implements IEditorInput, IPersistableElement, Adap
return reload;
}
- public long getBranchUuid() {
- long branchUuid = 0;
+ public BranchId getBranch() {
+ BranchId branch = BranchId.SENTINEL;
if (editor.isReloadTabShown() && iWorldEditorProvider instanceof WorldEditorReloadProvider) {
WorldEditorReloadProvider provider = (WorldEditorReloadProvider) iWorldEditorProvider;
- branchUuid = provider.getBranchUuid();
+ branch = provider.getBranch();
} else {
if (!editor.getLoadedArtifacts().isEmpty()) {
- branchUuid = editor.getLoadedArtifacts().iterator().next().getBranch().getId();
+ branch = editor.getLoadedArtifacts().iterator().next().getBranch();
}
}
- return branchUuid;
+ return branch;
}
public Long getAtsSearchUuid() {
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorInputFactory.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorInputFactory.java
index 1f3ffdc1de..aa20cc4aa0 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorInputFactory.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorInputFactory.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.ats.world;
-import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.osee.ats.search.AtsSearchWorkflowSearchItem;
@@ -20,6 +19,8 @@ import org.eclipse.osee.ats.world.search.AtsSearchReviewSearchItem;
import org.eclipse.osee.ats.world.search.AtsSearchTaskSearchItem;
import org.eclipse.osee.ats.world.search.AtsSearchTeamWorkflowSearchItem;
import org.eclipse.osee.ats.world.search.AtsSearchWorkPackageSearchItem;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.ui.IElementFactory;
@@ -42,18 +43,12 @@ public class WorldEditorInputFactory implements IElementFactory {
@Override
public IAdaptable createElement(IMemento memento) {
long atsSearchUuid = 0L;
- long branchUuid = 0;
+ BranchId branch = BranchId.SENTINEL;
String title = memento.getString(TITLE);
if (Strings.isValid(memento.getString(BRANCH_KEY))) {
- branchUuid = Long.valueOf(memento.getString(BRANCH_KEY));
- }
- List<Integer> artUuids = new ArrayList<>();
- String artUuidsStr = memento.getString(ART_UUIDS);
- if (Strings.isValid(artUuidsStr)) {
- for (String artUuid : artUuidsStr.split(",")) {
- artUuids.add(Integer.valueOf(artUuid));
- }
+ branch = BranchId.valueOf(memento.getString(BRANCH_KEY));
}
+ List<ArtifactId> artUuids = Collections.fromString(memento.getString(ART_UUIDS), ArtifactId::valueOf);
String atsSearchUuidStr = memento.getString(ATS_SEARCH_UUID);
if (Strings.isNumeric(atsSearchUuidStr)) {
atsSearchUuid = Long.valueOf(atsSearchUuidStr);
@@ -100,16 +95,16 @@ public class WorldEditorInputFactory implements IElementFactory {
} catch (Exception ex) {
// do nothing
}
- return new WorldEditorInput(new WorldEditorReloadProvider(title, branchUuid, artUuids));
+ return new WorldEditorInput(new WorldEditorReloadProvider(title, branch, artUuids));
}
public static void saveState(IMemento memento, WorldEditorInput input) {
String title = input.getName();
- String artUuids = Collections.toString(",", input.getGuids());
- long branchUuid = input.getBranchUuid();
+ String artUuids = input.getIdString();
+ BranchId branch = input.getBranch();
- if (Strings.isValid(artUuids) && branchUuid > 0 && Strings.isValid(title)) {
- memento.putString(BRANCH_KEY, String.valueOf(branchUuid));
+ if (Strings.isValid(artUuids) && branch.isValid() && Strings.isValid(title)) {
+ memento.putString(BRANCH_KEY, branch.getIdString());
memento.putString(ART_UUIDS, artUuids);
memento.putString(TITLE, title);
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorReloadProvider.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorReloadProvider.java
index 52b47fd71b..cef187f9f6 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorReloadProvider.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorReloadProvider.java
@@ -18,6 +18,8 @@ import org.eclipse.nebula.widgets.xviewer.core.model.CustomizeData;
import org.eclipse.osee.ats.core.client.config.AtsBulkLoad;
import org.eclipse.osee.ats.internal.AtsClientService;
import org.eclipse.osee.ats.world.search.WorldSearchItem.SearchType;
+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.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
@@ -29,26 +31,26 @@ import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLo
public class WorldEditorReloadProvider extends WorldEditorProvider {
private final String name;
- private final Collection<Integer> artUuids;
+ private final Collection<ArtifactId> artifactIds;
private Collection<Artifact> artifacts;
private boolean reload = true;
- private final long branchUuid;
+ private final BranchId branch;
- public WorldEditorReloadProvider(String name, long branchUuid, Collection<Integer> artUuids) {
- this(name, branchUuid, artUuids, null, TableLoadOption.None);
+ public WorldEditorReloadProvider(String name, BranchId branch, Collection<ArtifactId> artifactIds) {
+ this(name, branch, artifactIds, null, TableLoadOption.None);
}
- public WorldEditorReloadProvider(String name, long branchUuid, Collection<Integer> artUuids, CustomizeData customizeData, TableLoadOption... tableLoadOption) {
+ public WorldEditorReloadProvider(String name, BranchId branch, Collection<ArtifactId> artifactIds, CustomizeData customizeData, TableLoadOption... tableLoadOption) {
super(customizeData, tableLoadOption);
this.name = name;
- this.branchUuid = branchUuid;
- this.artUuids = artUuids;
+ this.branch = branch;
+ this.artifactIds = artifactIds;
}
@Override
public IWorldEditorProvider copyProvider() {
WorldEditorReloadProvider provider =
- new WorldEditorReloadProvider(name, branchUuid, artUuids, customizeData, tableLoadOptions);
+ new WorldEditorReloadProvider(name, branch, artifactIds, customizeData, tableLoadOptions);
provider.setReload(reload);
provider.artifacts = artifacts;
return provider;
@@ -63,31 +65,32 @@ public class WorldEditorReloadProvider extends WorldEditorProvider {
return reload;
}
- public long getBranchUuid() {
- return branchUuid;
+ public BranchId getBranch() {
+ return branch;
}
public boolean searchAndLoad() {
- List<Integer> validartUuids = getValidArtUuids();
- if (validartUuids.isEmpty()) {
+ List<ArtifactId> validArtifactIds = getValidArtUuids();
+ if (validArtifactIds.isEmpty()) {
AWorkbench.popup("No valid ids to load");
} else {
- artifacts = new ArrayList<>();
- if (AtsClientService.get().getAtsBranch().equals(branchUuid)) {
- artifacts.addAll(ArtifactQuery.getArtifactListFromIds(new ArrayList<Integer>(validartUuids),
- AtsClientService.get().getAtsBranch()));
+ BranchId atsBranch = AtsClientService.get().getAtsBranch();
+ if (atsBranch.equals(branch)) {
+ artifacts = ArtifactQuery.getArtifactListFrom(validArtifactIds, atsBranch);
AtsBulkLoad.bulkLoadArtifacts(artifacts);
+ } else {
+ artifacts = new ArrayList<>();
}
}
reload = false;
- return artifacts.size() > 0;
+ return !artifacts.isEmpty();
}
- public List<Integer> getValidArtUuids() {
- List<Integer> validartUuids = new ArrayList<>();
- for (Integer artUuid : artUuids) {
- if (artUuid > 0) {
- validartUuids.add(artUuid);
+ public List<ArtifactId> getValidArtUuids() {
+ List<ArtifactId> validartUuids = new ArrayList<>();
+ for (ArtifactId artifactId : artifactIds) {
+ if (artifactId.isValid()) {
+ validartUuids.add(artifactId);
}
}
return validartUuids;
@@ -108,4 +111,4 @@ public class WorldEditorReloadProvider extends WorldEditorProvider {
public void setReload(boolean reload) {
this.reload = reload;
}
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java
index 966de71e9b..94793e6062 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java
@@ -61,7 +61,15 @@ public class Collections {
* @return A String which starts with 'start', followed by the elements in the Collection c separated by 'separator',
* ending with 'end'.
*/
- public static String toString(Iterable<?> items, String prefix, String separator, String suffix) {
+ public static <T> String toString(Iterable<T> items, String prefix, String separator, String suffix) {
+ return toString(items, prefix, separator, suffix, String::valueOf);
+ }
+
+ public static <T> String toString(Iterable<T> items, String separator, Function<T, String> function) {
+ return toString(items, null, separator, null, function);
+ }
+
+ public static <T> String toString(Iterable<T> items, String prefix, String separator, String suffix, Function<T, String> function) {
StringBuilder strB = new StringBuilder();
if (prefix != null) {
@@ -69,13 +77,13 @@ public class Collections {
}
boolean first = true;
- for (Object item : items) {
+ for (T item : items) {
if (first) {
first = false;
} else {
strB.append(separator);
}
- strB.append(String.valueOf(item));
+ strB.append(function.apply(item));
}
if (suffix != null) {

Back to the top