use of gov.usgs.cida.coastalhazards.model.Item in project coastal-hazards by USGS-CIDA.
the class ShorelineTest method testGenerateSLDInfo.
/**
* Test of generateSLDInfo method, of class Shoreline.
*/
@Test
public void testGenerateSLDInfo() {
Item item = new Item();
item.setAttr("Date_");
item.setId("abcde");
item.setType(Item.Type.historical);
List<Service> services = new LinkedList<>();
Service wmsService = new Service();
wmsService.setEndpoint("http://test");
wmsService.setServiceParameter("0");
wmsService.setType(ServiceType.source_wms);
services.add(wmsService);
item.setServices(services);
Summary summary = new Summary();
Tiny tiny = new Tiny();
tiny.setText("Shoreline");
summary.setTiny(tiny);
item.setSummary(summary);
SLDGenerator shoreline = new SLDGenerator(item, item.getId(), null, Shorelines.shorelines);
Response response = shoreline.generateSLDInfo();
String json = (String) response.getEntity();
Map<String, Object> sldInfo = new Gson().fromJson(json, HashMap.class);
List<Object> bins = (List) sldInfo.get("bins");
Map<String, Object> bin = (Map) bins.get(0);
Double year0 = ((List<Double>) bin.get("years")).get(0);
String color = (String) bin.get("color");
assertEquals(year0, 0.0f, 0.01f);
assertEquals(color, "#ff0000");
}
use of gov.usgs.cida.coastalhazards.model.Item in project coastal-hazards by USGS-CIDA.
the class ItemLastUpdateComparatorTest method setup.
@Before
public void setup() {
// Before the other
o1 = new Item();
o1.setId("Object1");
o1.setLastModified(new Date(12345678));
// After the other
o2 = new Item();
o2.setId("Object2");
o2.setLastModified(new Date(45678901));
}
use of gov.usgs.cida.coastalhazards.model.Item in project coastal-hazards by USGS-CIDA.
the class ItemLastUpdateComparatorTest method testMax.
@Test
public void testMax() {
ItemLastUpdateComparator comparator = new ItemLastUpdateComparator();
List<Item> items = new ArrayList<>();
items.add(o1);
items.add(o2);
Item max = Collections.max(items, comparator);
assertThat(o2.getId(), is(equalTo(max.getId())));
}
use of gov.usgs.cida.coastalhazards.model.Item in project coastal-hazards by USGS-CIDA.
the class InfoRouter method useInfoJsp.
@GET
@Produces(MediaType.TEXT_HTML)
@Path("/item/{id}")
public Response useInfoJsp(@PathParam("id") String id) {
Map<String, Object> map = new HashMap<>();
Item item;
try (ItemManager mgr = new ItemManager()) {
item = mgr.load(id);
}
if (item == null) {
return Response.status(Status.NOT_FOUND).build();
}
map.put("item", item);
return Response.ok(new Viewable("/WEB-INF/jsp/ui/back/index.jsp", map)).build();
}
use of gov.usgs.cida.coastalhazards.model.Item in project coastal-hazards by USGS-CIDA.
the class InfoRouter method useInfoPrintViewJsp.
@GET
@Produces(MediaType.TEXT_HTML)
@Path("/item/print/{id}")
public Response useInfoPrintViewJsp(@PathParam("id") String id) {
Map<String, Object> map = new HashMap<>();
Item item;
try (ItemManager mgr = new ItemManager()) {
item = mgr.load(id);
}
if (item == null) {
return Response.status(Status.NOT_FOUND).build();
}
map.put("item", item);
return Response.ok(new Viewable("/WEB-INF/jsp/ui/back/index-print.jsp", map)).build();
}
Aggregations