Commit 885f19e1 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1486-left-panel-general-overlays-sort-the-overlays' into 'master'

Resolve "Left panel General Overlays - sort the overlays"

Closes #1486

See merge request !1312
parents d7a1e379 d619412d
Pipeline #43214 passed with stage
in 23 minutes and 46 seconds
minerva (16.0.0~beta.1) stable; urgency=medium
* Backward incompatibility: layout parameter in minerva url is not supported
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)
* Bug fix: there was issue with updating data overlay in admin panel "Unknown
parameter: defaultOverlay"
* Bug fix: data overlays uploaded in complex map were not processed properly
(#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
......
This diff is collapsed.
......@@ -25,7 +25,15 @@ public class DataOverlay implements Serializable {
@Override
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;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ ColorSchemaTest.class, GenericColorSchemaTest.class, GeneVariationColorSchemaTest.class,
GeneVariationTest.class, InvalidColorSchemaExceptionTest.class, LayoutStatusTest.class, LayoutTest.class })
@SuiteClasses({ ColorSchemaTest.class,
DataOverlayTest.class,
GenericColorSchemaTest.class,
GeneVariationColorSchemaTest.class,
GeneVariationTest.class,
InvalidColorSchemaExceptionTest.class,
LayoutStatusTest.class,
LayoutTest.class })
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 {
.googleLicenseConsent(googleLicenseConsent.equalsIgnoreCase("true")));
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();
layout.setOrderIndex(count);
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