GetMapConfigurationCommand implements CommandHasRequest<GetMapConfigurationRequest, GetMapConfigurationResponse> { @Override public void execute(GetMapConfigurationRequest request, GetMapConfigurationResponse response) throws Exception { if (null == request.getApplicationId()) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "applicationId"); } String mapId = request.getMapId(); if (null == mapId) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "mapId"); } ClientApplicationInfo application = context.getBean(request.getApplicationId(), ClientApplicationInfo.class); for (ClientMapInfo map : application.getMaps()) { if (mapId.equals(map.getId())) { response.setMapInfo(securityClone(map)); } } if (response.getMapInfo() == null) { throw new GeomajasException(ExceptionCode.MAP_NOT_FOUND, request.getMapId(), request.getApplicationId()); } }  @Override GetMapConfigurationRequest getEmptyCommandRequest(); @Override GetMapConfigurationResponse getEmptyCommandResponse(); @Override void execute(GetMapConfigurationRequest request, GetMapConfigurationResponse response); ClientMapInfo securityClone(ClientMapInfo original); Map<String, ClientWidgetInfo> securityClone(Map<String, ClientWidgetInfo> widgetInfo); Map<String, LayerExtraInfo> securityCloneLayerExtraInfo(Map<String, LayerExtraInfo> extraInfoMap); ClientLayerInfo securityClone(ClientLayerInfo original); ClientLayerTreeInfo securityClone(ClientLayerTreeInfo original); ClientLayerTreeNodeInfo securityClone(ClientLayerTreeNodeInfo original); ClientToolbarInfo securityClone(ClientToolbarInfo original); List<ClientToolInfo> securityClone(List<ClientToolInfo> original);  }
@Test public void testConvertMaxExtent() throws Exception { Layer layer = configurationService.getLayer("countries"); Bbox configMaxExtent = layer.getLayerInfo().getMaxExtent(); Assert.assertEquals(-85.05112877980659, configMaxExtent.getX(), DOUBLE_TOLERANCE); Assert.assertEquals(-85.05112877980659, configMaxExtent.getY(), DOUBLE_TOLERANCE); Assert.assertEquals(170.102257, configMaxExtent.getWidth(), DOUBLE_TOLERANCE); Assert.assertEquals(170.102257, configMaxExtent.getHeight(), DOUBLE_TOLERANCE); GetMapConfigurationRequest request = new GetMapConfigurationRequest(); request.setApplicationId("simplevectors"); request.setMapId("coordTestMap"); GetMapConfigurationResponse response = (GetMapConfigurationResponse) dispatcher.execute( GetMapConfigurationRequest.COMMAND, request, null, "en"); if (response.isError()) { response.getErrors().get(0).printStackTrace(); } Assert.assertFalse(response.isError()); ClientMapInfo mapInfo = response.getMapInfo(); Assert.assertNotNull(mapInfo); Bbox mapMaxExtent = mapInfo.getLayers().get(0).getMaxExtent(); Assert.assertEquals(-9467848.347161204, mapMaxExtent.getX(), DOUBLE_TOLERANCE); Assert.assertEquals(-2.0037508342789236E7, mapMaxExtent.getY(), DOUBLE_TOLERANCE); Assert.assertEquals(1.8935696632026553E7, mapMaxExtent.getWidth(), DOUBLE_TOLERANCE); Assert.assertEquals(4.007501596344786E7, mapMaxExtent.getHeight(), DOUBLE_TOLERANCE); ClientUserDataInfo info = mapInfo.getUserData(); Assert.assertNotNull(info); Assert.assertTrue(info instanceof ClientApplicationInfo.DummyClientUserDataInfo); Assert.assertEquals("some data", ((ClientApplicationInfo.DummyClientUserDataInfo) info).getDummy()); Assert.assertNotNull(mapInfo.getWidgetInfo()); Assert.assertNull(mapInfo.getWidgetInfo("mapSelect")); Assert.assertNotNull(mapInfo.getWidgetInfo("layerTree")); Assert.assertEquals("layer1, layer2", ((ClientApplicationInfo.DummyClientWidgetInfo) mapInfo.getWidgetInfo("layerTree")).getDummy()); BoundsLimitOption boundsLimitOption = mapInfo.getViewBoundsLimitOption(); Assert.assertNotNull(info); Assert.assertEquals(BoundsLimitOption.COMPLETELY_WITHIN_MAX_BOUNDS, boundsLimitOption); }
@Test public void testViewBoundsLimitOption() throws Exception { GetMapConfigurationRequest request = new GetMapConfigurationRequest(); request.setApplicationId("vectorsMapWithViewBoundsOption"); request.setMapId("viewBoundsLimitTestMap"); GetMapConfigurationResponse response = (GetMapConfigurationResponse) dispatcher.execute( GetMapConfigurationRequest.COMMAND, request, null, "en"); if (response.isError()) { response.getErrors().get(0).printStackTrace(); } Assert.assertFalse(response.isError()); ClientMapInfo mapInfo = response.getMapInfo(); Assert.assertNotNull(mapInfo); BoundsLimitOption boundsLimitOption = mapInfo.getViewBoundsLimitOption(); Assert.assertNotNull(boundsLimitOption); Assert.assertEquals(BoundsLimitOption.CENTER_WITHIN_MAX_BOUNDS, boundsLimitOption); }
@Test public void testServerSideOnlyInfo() throws Exception { GetMapConfigurationRequest request = new GetMapConfigurationRequest(); request.setApplicationId("appServerSideOnly"); request.setMapId("mapServerSideOnly"); GetMapConfigurationResponse response = (GetMapConfigurationResponse) dispatcher.execute( GetMapConfigurationRequest.COMMAND, request, null, "en"); if (response.isError()) { response.getErrors().get(0).printStackTrace(); } Assert.assertFalse(response.isError()); ClientMapInfo mapInfo = response.getMapInfo(); Assert.assertNotNull(mapInfo); ClientUserDataInfo info = mapInfo.getUserData(); Assert.assertNull(info); Assert.assertNotNull(mapInfo.getWidgetInfo()); Assert.assertNull(mapInfo.getWidgetInfo("appDummy")); Assert.assertNotNull(mapInfo.getWidgetInfo("layerTree")); Assert.assertNull(mapInfo.getWidgetInfo("mapDummy")); Assert.assertEquals(BoundsLimitOption.COMPLETELY_WITHIN_MAX_BOUNDS, mapInfo.getViewBoundsLimitOption()); }