Commit d619412d authored by Piotr Gawron's avatar Piotr Gawron
Browse files

sort order takes into account public flag information

parent edbccb7a
Pipeline #43180 passed with stage
in 25 minutes and 15 seconds
minerva (16.0.0~beta.1) stable; urgency=medium minerva (16.0.0~beta.1) stable; urgency=medium
* Backward incompatibility: layout parameter in minerva url is not supported * Backward incompatibility: layout parameter in minerva url is not supported
anymore anymore
* Small improvement: info about background and dat aoverlays is separated in * Small improvement: info about background and data overlays is separated in
edit project panel (#1515) edit project panel (#1515)
* Bug fix: there was issue with updating data overlay in admin panel "Unknown * Bug fix: there was issue with updating data overlay in admin panel "Unknown
parameter: defaultOverlay" parameter: defaultOverlay"
* Bug fix: data overlays uploaded in complex map were not processed properly * Bug fix: data overlays uploaded in complex map were not processed properly
(#1485) (#1485)
* Bug fix: sort of the overlays in General Overlays in the left panel was
wrong (#1486)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 9 Jun 2021 15:00:00 +0200 -- Piotr Gawron <piotr.gawron@uni.lu> Wed, 9 Jun 2021 15:00:00 +0200
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -25,7 +25,15 @@ public class DataOverlay implements Serializable { ...@@ -25,7 +25,15 @@ public class DataOverlay implements Serializable {
@Override @Override
public int compare(DataOverlay o1, DataOverlay o2) { public int compare(DataOverlay o1, DataOverlay o2) {
return o1.getOrderIndex() - o2.getOrderIndex(); if (Objects.equals(o1.isPublic(), o2.isPublic())) {
return o1.getOrderIndex() - o2.getOrderIndex();
} else {
if (o1.isPublic()) {
return 1;
} else {
return -1;
}
}
} }
}; };
......
...@@ -5,8 +5,14 @@ import org.junit.runners.Suite; ...@@ -5,8 +5,14 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({ ColorSchemaTest.class, GenericColorSchemaTest.class, GeneVariationColorSchemaTest.class, @SuiteClasses({ ColorSchemaTest.class,
GeneVariationTest.class, InvalidColorSchemaExceptionTest.class, LayoutStatusTest.class, LayoutTest.class }) DataOverlayTest.class,
GenericColorSchemaTest.class,
GeneVariationColorSchemaTest.class,
GeneVariationTest.class,
InvalidColorSchemaExceptionTest.class,
LayoutStatusTest.class,
LayoutTest.class })
public class AllOverlayTests { public class AllOverlayTests {
} }
package lcsb.mapviewer.model.overlay;
import static org.junit.Assert.assertTrue;
import java.util.*;
import org.junit.Test;
public class DataOverlayTest {
@Test
public void testComparator() {
DataOverlay userData1 = new DataOverlay();
DataOverlay userData2 = new DataOverlay();
DataOverlay globalData1 = new DataOverlay();
DataOverlay globalData2 = new DataOverlay();
globalData1.setPublic(true);
globalData2.setPublic(true);
List<DataOverlay> list = new ArrayList<>(Arrays.asList(userData1, globalData1, userData2, globalData2));
list.sort(DataOverlay.ORDER_COMPARATOR);
assertTrue(list.indexOf(userData1) <= 1);
assertTrue(list.indexOf(userData2) <= 1);
assertTrue(list.indexOf(globalData1) > 1);
assertTrue(list.indexOf(globalData2) > 1);
}
}
...@@ -264,7 +264,7 @@ public class OverlayRestImpl extends BaseRestImpl { ...@@ -264,7 +264,7 @@ public class OverlayRestImpl extends BaseRestImpl {
.googleLicenseConsent(googleLicenseConsent.equalsIgnoreCase("true"))); .googleLicenseConsent(googleLicenseConsent.equalsIgnoreCase("true")));
int count = (int) dataOverlayService.getDataOverlaysByProject(project).stream() int count = (int) dataOverlayService.getDataOverlaysByProject(project).stream()
.filter(lay -> lay.getCreator().getLogin().equals(user.getLogin())) .filter(overlay -> (overlay.getCreator().getLogin().equals(user.getLogin()) && !overlay.isPublic()))
.count(); .count();
layout.setOrderIndex(count); layout.setOrderIndex(count);
dataOverlayService.updateDataOverlay(layout); dataOverlayService.updateDataOverlay(layout);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment