Skip to content
Snippets Groups Projects
Commit 554e784c authored by tpylak's avatar tpylak
Browse files

LMS-2190 ensure that the replicate sequence will be always the same for a fixes set of replicas

SVN: 21199
parent d95b1c2c
No related branches found
No related tags found
No related merge requests found
...@@ -19,10 +19,13 @@ package ch.systemsx.cisd.openbis.plugin.screening.server.logic; ...@@ -19,10 +19,13 @@ package ch.systemsx.cisd.openbis.plugin.screening.server.logic;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.collections.comparators.NullComparator;
import ch.systemsx.cisd.common.collections.GroupByMap; import ch.systemsx.cisd.common.collections.GroupByMap;
import ch.systemsx.cisd.common.collections.IKeyExtractor; import ch.systemsx.cisd.common.collections.IKeyExtractor;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityPropertiesHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityPropertiesHolder;
...@@ -53,7 +56,9 @@ class ReplicateSequenceProvider ...@@ -53,7 +56,9 @@ class ReplicateSequenceProvider
GroupByMap<Double, IEntityPropertiesHolder> biologicalReplicates = GroupByMap<Double, IEntityPropertiesHolder> biologicalReplicates =
groupByBiologicalReplicate(replicaWells); groupByBiologicalReplicate(replicaWells);
int biologicalReplicateSeq = 1; int biologicalReplicateSeq = 1;
for (Double biologicalReplicateKey : biologicalReplicates.getKeys()) // NOTE: by sorting the keys we ensure that the replicate sequence will be always the same
// for a fixes set of replicas.
for (Double biologicalReplicateKey : createSortedCopy(biologicalReplicates.getKeys()))
{ {
if (biologicalReplicateKey != null) if (biologicalReplicateKey != null)
{ {
...@@ -118,7 +123,13 @@ class ReplicateSequenceProvider ...@@ -118,7 +123,13 @@ class ReplicateSequenceProvider
private static <T extends Comparable<T>> Collection<T> createSortedCopy(Collection<T> keys) private static <T extends Comparable<T>> Collection<T> createSortedCopy(Collection<T> keys)
{ {
ArrayList<T> sortedKeys = new ArrayList<T>(keys); ArrayList<T> sortedKeys = new ArrayList<T>(keys);
Collections.sort(sortedKeys); Collections.sort(sortedKeys, new NullComparator<T>(new Comparator<T>()
{
public int compare(T o1, T o2)
{
return o1.compareTo(o2);
}
}));
return sortedKeys; return sortedKeys;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment