Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2018-10-15 14:14:50 -0400
committerDonald Dunne2018-10-16 12:59:49 -0400
commitb79cda0ca152396295adb542c4f01cfc43ecebe6 (patch)
treef3300dbffb0398032eab1ee514271736b9953b9b
parent9ce9317c54f95eb3efcd1ab3aadb5741c779519c (diff)
downloadorg.eclipse.osee-b79cda0ca152396295adb542c4f01cfc43ecebe6.tar.gz
org.eclipse.osee-b79cda0ca152396295adb542c4f01cfc43ecebe6.tar.xz
org.eclipse.osee-b79cda0ca152396295adb542c4f01cfc43ecebe6.zip
bug[ats_TW11431]: Artifact Editor relation order not showing correctly
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AbstractArtifactNameComparator.java50
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactNameComparator.java29
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactNameRelationLinkComparator.java32
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationLink.java5
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java19
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationTypeSideSorter.java6
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/order/IRelationSorter.java3
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/AbstractUserDefinedOrderComparator.java41
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/LexicographicalRelationSorter.java14
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UnorderedRelationSorter.java6
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedOrderComparator.java21
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedRelationOrderComparator.java32
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedRelationSorter.java8
13 files changed, 218 insertions, 48 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AbstractArtifactNameComparator.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AbstractArtifactNameComparator.java
new file mode 100644
index 0000000000..3f0e08b975
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AbstractArtifactNameComparator.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2018 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.skynet.core.artifact;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Donald G. Dunne
+ */
+public abstract class AbstractArtifactNameComparator {
+ private static final Pattern numberPattern = Pattern.compile("[+-]?\\d+");
+ private final Matcher numberMatcher = numberPattern.matcher("");
+ private boolean descending = false;
+ private static final int NUMBER_STRING_LIMIT = 19;
+
+ public AbstractArtifactNameComparator(boolean descending) {
+ this.descending = descending;
+ }
+
+ public int compareNames(String name1, String name2) {
+ numberMatcher.reset(name1);
+ if (numberMatcher.matches()) {
+ numberMatcher.reset(name2);
+ if (numberMatcher.matches()) {
+ if (name1.length() < NUMBER_STRING_LIMIT && name2.length() < NUMBER_STRING_LIMIT) {
+ if (descending) {
+ return Long.valueOf(name2).compareTo(Long.valueOf(name1));
+ } else {
+ return Long.valueOf(name1).compareTo(Long.valueOf(name2));
+ }
+ }
+ }
+ }
+ if (descending) {
+ return name2.compareTo(name1);
+ } else {
+ return name1.compareTo(name2);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactNameComparator.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactNameComparator.java
index 47ffa896c9..ffd7c23ded 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactNameComparator.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactNameComparator.java
@@ -11,18 +11,12 @@
package org.eclipse.osee.framework.skynet.core.artifact;
import java.util.Comparator;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.eclipse.osee.framework.core.data.ArtifactToken;
-public class ArtifactNameComparator implements Comparator<ArtifactToken> {
- private static final Pattern numberPattern = Pattern.compile("[+-]?\\d+");
- private final Matcher numberMatcher = numberPattern.matcher("");
- private boolean descending = false;
- private static final int NUMBER_STRING_LIMIT = 19;
+public class ArtifactNameComparator extends AbstractArtifactNameComparator implements Comparator<ArtifactToken> {
public ArtifactNameComparator(boolean descending) {
- this.descending = descending;
+ super(descending);
}
@Override
@@ -30,23 +24,6 @@ public class ArtifactNameComparator implements Comparator<ArtifactToken> {
String name1 = artifact1.getName();
String name2 = artifact2.getName();
- numberMatcher.reset(name1);
- if (numberMatcher.matches()) {
- numberMatcher.reset(name2);
- if (numberMatcher.matches()) {
- if (name1.length() < NUMBER_STRING_LIMIT && name2.length() < NUMBER_STRING_LIMIT) {
- if (descending) {
- return Long.valueOf(name2).compareTo(Long.valueOf(name1));
- } else {
- return Long.valueOf(name1).compareTo(Long.valueOf(name2));
- }
- }
- }
- }
- if (descending) {
- return name2.compareTo(name1);
- } else {
- return name1.compareTo(name2);
- }
+ return compareNames(name1, name2);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactNameRelationLinkComparator.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactNameRelationLinkComparator.java
new file mode 100644
index 0000000000..f26945a456
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactNameRelationLinkComparator.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2018 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.skynet.core.artifact;
+
+import java.util.Comparator;
+import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class ArtifactNameRelationLinkComparator extends AbstractArtifactNameComparator implements Comparator<RelationLink> {
+
+ public ArtifactNameRelationLinkComparator(boolean descending) {
+ super(descending);
+ }
+
+ @Override
+ public int compare(RelationLink link1, RelationLink link2) {
+ String name1 = link1.getArtifactB().getName();
+ String name2 = link2.getArtifactB().getName();
+
+ return compareNames(name1, name2);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationLink.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationLink.java
index c8ed92fb9b..212fc21b14 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationLink.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationLink.java
@@ -277,8 +277,9 @@ public class RelationLink implements HasBranch {
@Override
public String toString() {
- return String.format("type[%s] id[%d] modType[%s] [%s]: aId[%d] <--> bId[%s]", relationType.getName(), relationId,
- getModificationType(), isDirty() ? "dirty" : "not dirty", aArtifactId, bArtifactId);
+ return String.format("type[%s] id[%d] modType[%s] [%s]: a%s <--> b%s", relationType.getName(), relationId,
+ getModificationType(), isDirty() ? "dirty" : "not dirty", artifactA.toStringWithId(),
+ artifactB.toStringWithId());
}
public void setNotDirty() {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
index 5e99809472..8bfe1acd77 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
@@ -365,7 +365,15 @@ public class RelationManager {
return null;
}
+ public static List<RelationLink> getRelationsUnordered(Artifact artifact, IRelationType relationType, RelationSide relationSide) throws OseeCoreException {
+ return getRelations(artifact, relationType, relationSide, false);
+ }
+
public static List<RelationLink> getRelations(Artifact artifact, IRelationType relationType, RelationSide relationSide) throws OseeCoreException {
+ return getRelations(artifact, relationType, relationSide, true);
+ }
+
+ public static List<RelationLink> getRelations(Artifact artifact, IRelationType relationType, RelationSide relationSide, boolean sort) throws OseeCoreException {
if (artifact.isHistorical()) {
throw new OseeCoreException("Artifact [%s] is historical. Historical relations are only supported on server",
artifact);
@@ -392,6 +400,9 @@ public class RelationManager {
}
}
}
+ if (sort) {
+ sortRelations(artifact, relationType, relationSide, relations);
+ }
return relations;
}
@@ -576,6 +587,14 @@ public class RelationManager {
sorter.sort(listToOrder);
}
+ private static void sortRelations(Artifact artifact, IRelationType type, RelationSide side, List<RelationLink> listToOrder) throws OseeCoreException {
+ if (type == null || side == null || listToOrder.size() <= 1) {
+ return;
+ }
+ RelationTypeSideSorter sorter = createTypeSideSorter(artifact, type, side);
+ sorter.sortRelations(listToOrder);
+ }
+
private static void updateOrderListOnDelete(Artifact artifact, IRelationType relationType, RelationSide relationSide, List<Artifact> relatives) throws OseeCoreException {
RelationTypeSideSorter sorter = createTypeSideSorter(artifact, relationType, relationSide);
sorter.setOrder(relatives, sorter.getSorterId());
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationTypeSideSorter.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationTypeSideSorter.java
index 28746a6fde..ef5833758f 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationTypeSideSorter.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationTypeSideSorter.java
@@ -78,6 +78,12 @@ public class RelationTypeSideSorter extends RelationTypeSide {
order.sort(listToOrder, relativeOrder);
}
+ public void sortRelations(List<? extends RelationLink> listToOrder) throws OseeCoreException {
+ IRelationSorter order = sorterProvider.getRelationOrder(getSorterId());
+ List<String> relativeOrder = orderData.getOrderList(getRelationType(), getSide());
+ order.sortRelations(listToOrder, relativeOrder);
+ }
+
public RelationLink getRelation(Artifact artifact) {
return artToRelation.get(artifact);
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/order/IRelationSorter.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/order/IRelationSorter.java
index fa5fdc6dde..00ba6dd57d 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/order/IRelationSorter.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/order/IRelationSorter.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.framework.skynet.core.relation.order;
import java.util.List;
import org.eclipse.osee.framework.core.data.ArtifactToken;
import org.eclipse.osee.framework.core.enums.RelationSorter;
+import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
/**
* @author Andrew M. Finkbeiner
@@ -22,4 +23,6 @@ public interface IRelationSorter {
RelationSorter getSorterId();
void sort(List<? extends ArtifactToken> relatives, List<String> relativeSequence);
+
+ void sortRelations(List<? extends RelationLink> listToOrder, List<String> relativeOrder);
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/AbstractUserDefinedOrderComparator.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/AbstractUserDefinedOrderComparator.java
new file mode 100644
index 0000000000..bc4e487f08
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/AbstractUserDefinedOrderComparator.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2018 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.skynet.core.relation.sorters;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Donald G. Dunne
+ */
+public abstract class AbstractUserDefinedOrderComparator {
+
+ protected final Map<String, Integer> value;
+
+ public AbstractUserDefinedOrderComparator(List<String> guidOrder) {
+ value = new HashMap<>(guidOrder.size());
+ for (int i = 0; i < guidOrder.size(); i++) {
+ value.put(guidOrder.get(i), i);
+ }
+ }
+
+ public int compareIntegers(Integer val1, Integer val2) {
+ if (val1 == null) {
+ val1 = Integer.MAX_VALUE - 1;
+ }
+ if (val2 == null) {
+ val2 = Integer.MAX_VALUE;
+ }
+ return val1 - val2;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/LexicographicalRelationSorter.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/LexicographicalRelationSorter.java
index 6ec342b0ab..457903535a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/LexicographicalRelationSorter.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/LexicographicalRelationSorter.java
@@ -17,6 +17,8 @@ import java.util.List;
import org.eclipse.osee.framework.core.data.ArtifactToken;
import org.eclipse.osee.framework.core.enums.RelationSorter;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactNameComparator;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactNameRelationLinkComparator;
+import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
import org.eclipse.osee.framework.skynet.core.relation.order.IRelationSorter;
/**
@@ -29,12 +31,11 @@ public class LexicographicalRelationSorter implements IRelationSorter {
ASCENDING,
DESCENDING;
}
- private final ArtifactNameComparator comparator;
private final RelationSorter id;
+ private final boolean isDescending;
public LexicographicalRelationSorter(SortMode sortMode) {
- boolean isDescending = SortMode.DESCENDING == sortMode;
- this.comparator = new ArtifactNameComparator(isDescending);
+ isDescending = SortMode.DESCENDING == sortMode;
this.id = isDescending ? LEXICOGRAPHICAL_DESC : LEXICOGRAPHICAL_ASC;
}
@@ -45,6 +46,13 @@ public class LexicographicalRelationSorter implements IRelationSorter {
@Override
public void sort(List<? extends ArtifactToken> relatives, List<String> relativeSequence) {
+ ArtifactNameComparator comparator = new ArtifactNameComparator(isDescending);
+ Collections.sort(relatives, comparator);
+ }
+
+ @Override
+ public void sortRelations(List<? extends RelationLink> relatives, List<String> relativeSequence) {
+ ArtifactNameRelationLinkComparator comparator = new ArtifactNameRelationLinkComparator(isDescending);
Collections.sort(relatives, comparator);
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UnorderedRelationSorter.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UnorderedRelationSorter.java
index a4b90332b1..309c5239ac 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UnorderedRelationSorter.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UnorderedRelationSorter.java
@@ -14,6 +14,7 @@ import static org.eclipse.osee.framework.core.enums.RelationSorter.UNORDERED;
import java.util.List;
import org.eclipse.osee.framework.core.data.ArtifactToken;
import org.eclipse.osee.framework.core.enums.RelationSorter;
+import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
import org.eclipse.osee.framework.skynet.core.relation.order.IRelationSorter;
/**
@@ -30,4 +31,9 @@ public class UnorderedRelationSorter implements IRelationSorter {
public void sort(List<? extends ArtifactToken> relatives, List<String> relativeSequence) {
// do nothing
}
+
+ @Override
+ public void sortRelations(List<? extends RelationLink> listToOrder, List<String> relativeOrder) {
+ // do nothing
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedOrderComparator.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedOrderComparator.java
index 83146d98d0..6518f2c090 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedOrderComparator.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedOrderComparator.java
@@ -11,35 +11,22 @@
package org.eclipse.osee.framework.skynet.core.relation.sorters;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.eclipse.osee.framework.core.data.ArtifactToken;
/**
* @author Andrew M. Finkbeiner
*/
-class UserDefinedOrderComparator implements Comparator<ArtifactToken> {
+class UserDefinedOrderComparator extends AbstractUserDefinedOrderComparator implements Comparator<ArtifactToken> {
- private final Map<String, Integer> value;
-
- UserDefinedOrderComparator(List<String> guidOrder) {
- value = new HashMap<>(guidOrder.size());
- for (int i = 0; i < guidOrder.size(); i++) {
- value.put(guidOrder.get(i), i);
- }
+ public UserDefinedOrderComparator(List<String> guidOrder) {
+ super(guidOrder);
}
@Override
public int compare(ArtifactToken artifact1, ArtifactToken artifact2) {
Integer val1 = value.get(artifact1.getGuid());
Integer val2 = value.get(artifact2.getGuid());
- if (val1 == null) {
- val1 = Integer.MAX_VALUE - 1;
- }
- if (val2 == null) {
- val2 = Integer.MAX_VALUE;
- }
- return val1 - val2;
+ return compareIntegers(val1, val2);
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedRelationOrderComparator.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedRelationOrderComparator.java
new file mode 100644
index 0000000000..f55e84d8b4
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedRelationOrderComparator.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2018 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.skynet.core.relation.sorters;
+
+import java.util.Comparator;
+import java.util.List;
+import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
+
+/**
+ * @author Donald G. Dunne
+ */
+class UserDefinedRelationOrderComparator extends AbstractUserDefinedOrderComparator implements Comparator<RelationLink> {
+
+ public UserDefinedRelationOrderComparator(List<String> guidOrder) {
+ super(guidOrder);
+ }
+
+ @Override
+ public int compare(RelationLink link1, RelationLink link2) {
+ Integer val1 = value.get(link1.getArtifactB().getGuid());
+ Integer val2 = value.get(link2.getArtifactB().getGuid());
+ return compareIntegers(val1, val2);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedRelationSorter.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedRelationSorter.java
index 572fdaa098..ebf0146577 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedRelationSorter.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/sorters/UserDefinedRelationSorter.java
@@ -15,6 +15,7 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.osee.framework.core.data.ArtifactToken;
import org.eclipse.osee.framework.core.enums.RelationSorter;
+import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
import org.eclipse.osee.framework.skynet.core.relation.order.IRelationSorter;
/**
@@ -33,4 +34,11 @@ public class UserDefinedRelationSorter implements IRelationSorter {
Collections.sort(relatives, new UserDefinedOrderComparator(relativeSequence));
}
}
+
+ @Override
+ public void sortRelations(List<? extends RelationLink> relatives, List<String> relativeSequence) {
+ if (relatives.size() > 1) {
+ Collections.sort(relatives, new UserDefinedRelationOrderComparator(relativeSequence));
+ }
+ }
}

Back to the top