private void updateSystemLayers() { LOG.info("Updating systemlayers"); try { Map<String, LayerModel> models = toMap(layerModelService.getLayerModelsInternal()); for (ClientLayerInfo cli : layerMap.values()) { if (!models.containsKey(cli.getId())) { try { LayerModel lm = toLayerModel(cli); layerModelService.saveOrUpdateLayerModelInternal(lm); LOG.info(" - updated layermodel for: " + cli.getLabel()); } catch (Exception e) { LOG.error("Error creating layer, invalid configuration (service not available?): " + cli.getLabel()); } } } } catch (Exception e) { LOG.warn("Error updating system layers: " + e.getMessage()); } }
private List<NamedObject> getClientLayerInfoObject(DynamicLayerConfiguration lc) throws Exception { if (lc == null) { throw new IllegalArgumentException("Need a DynamicLayerConfiguration"); } List<NamedObject> objects = new ArrayList<BeanDefinitionDtoConverterService.NamedObject>(); if (lc.getServerLayerInfo() instanceof VectorLayerInfo) { NamedStyleInfo nsi = ((VectorLayerInfo) lc.getServerLayerInfo()).getNamedStyleInfos().get(0); objects.add(new NamedObjectImpl(nsi, nsi.getName())); } objects.add(new NamedObjectImpl(lc.getClientLayerInfo(), lc.getClientLayerInfo().getId())); return objects; }
private List<NamedObject> getClientLayerInfoObject(DynamicLayerConfiguration lc) throws Exception { if (lc == null) { throw new IllegalArgumentException("Need a DynamicLayerConfiguration"); } List<NamedObject> objects = new ArrayList<BeanDefinitionDtoConverterService.NamedObject>(); if (lc.getServerLayerInfo() instanceof VectorLayerInfo) { NamedStyleInfo nsi = ((VectorLayerInfo) lc.getServerLayerInfo()).getNamedStyleInfos().get(0); objects.add(new NamedObjectImpl(nsi, nsi.getName())); } objects.add(new NamedObjectImpl(lc.getClientLayerInfo(), lc.getClientLayerInfo().getId())); return objects; }
private void updateSystemLayers() { log.info("Updating systemlayers"); try { Map<String, LayerModel> models = toMap(layerModelService.getLayerModelsInternal()); for (ClientLayerInfo cli : layerMap.values()) { if (!models.containsKey(cli.getId())) { try { LayerModel lm = toLayerModel(cli); layerModelService.saveOrUpdateLayerModelInternal(lm); log.info(" - updated layermodel for: " + cli.getLabel()); } catch (Exception e) { log.error("Error creating layer, invalid configuration (service not available?): " + cli.getLabel()); } } } } catch (Exception e) { log.warn("Error updating system layers: " + e.getMessage()); } }
private static void remove(ClientLayerTreeNodeInfo node, ClientLayerInfo layer) { if (node.getLayers() != null) { ClientLayerInfo toRemove = null; for (ClientLayerInfo l : node.getLayers()) { if (l.getId().equals(layer.getId())) { toRemove = l; break; } } if (null != toRemove) { node.getLayers().remove(toRemove); return; } } if (node.getTreeNodes() != null) { for (ClientLayerTreeNodeInfo innernode : node.getTreeNodes()) { remove(innernode, layer); } } }
private static boolean check(ClientLayerTreeNodeInfo node, String layerId) { List<ClientLayerInfo> layers = node.getLayers(); if (layers != null) { for (ClientLayerInfo layer : layers) { if (layer.getId().equals(layerId)) { return true; } } } if (node.getTreeNodes() != null) { for (ClientLayerTreeNodeInfo innernode : node.getTreeNodes()) { if (check(innernode, layerId)) { return true; } } } return false; }
private static boolean checkVisibility(ClientLayerTreeNodeInfo node, String layerId) { List<ClientLayerInfo> layers = node.getLayers(); if (layers != null) { for (ClientLayerInfo layer : layers) { if (layer.getId().equals(layerId) && layer.isVisible()) { return true; } } } if (node.getTreeNodes() != null) { for (ClientLayerTreeNodeInfo innernode : node.getTreeNodes()) { if (checkVisibility(innernode, layerId)) { return true; } } } return false; }
@Override public Map<String, Object> createBeanLayerDefinitionParameters(DynamicLayerConfiguration lc) throws Exception { if (clientLayerInfoMap.containsKey(lc.getClientLayerInfo().getId())) { throw new DeskmanagerException(DeskmanagerException.CLIENT_LAYERID_ALREADY_IN_USE, lc.getClientLayerInfo() .getId()); } if (serverLayerMap.containsKey(lc.getClientLayerInfo().getServerLayerId())) { throw new DeskmanagerException(DeskmanagerException.SERVER_LAYERID_ALREADY_IN_USE, lc.getClientLayerInfo() .getServerLayerId()); } Map<String, Object> params = new HashMap<String, Object>(); params.put(BeanFactory.BEAN_NAME, lc.getClientLayerInfo().getServerLayerId()); if (lc instanceof DynamicVectorLayerConfiguration) { createVectorLayerParams((DynamicVectorLayerConfiguration) lc, params); } else if (lc instanceof DynamicRasterLayerConfiguration) { createRasterLayerParams((DynamicRasterLayerConfiguration) lc, params); } else { return null; } return params; }
@Override public Map<String, Object> createBeanLayerDefinitionParameters(DynamicLayerConfiguration lc) throws Exception { if (clientLayerInfoMap.containsKey(lc.getClientLayerInfo().getId())) { throw new DeskmanagerException(DeskmanagerException.CLIENT_LAYERID_ALREADY_IN_USE, lc.getClientLayerInfo() .getId()); } if (serverLayerMap.containsKey(lc.getClientLayerInfo().getServerLayerId())) { throw new DeskmanagerException(DeskmanagerException.SERVER_LAYERID_ALREADY_IN_USE, lc.getClientLayerInfo() .getServerLayerId()); } Map<String, Object> params = new HashMap<String, Object>(); params.put(BeanFactory.BEAN_NAME, lc.getClientLayerInfo().getServerLayerId()); if (lc instanceof DynamicVectorLayerConfiguration) { createVectorLayerParams((DynamicVectorLayerConfiguration) lc, params); } else if (lc instanceof DynamicRasterLayerConfiguration) { createRasterLayerParams((DynamicRasterLayerConfiguration) lc, params); } else { return null; } return params; }
private Map<String, Object> createBeanClientLayerDefinitionParameters(DynamicLayerConfiguration lc) throws Exception { if (clientLayerInfoMap.containsKey(lc.getClientLayerInfo().getId())) { throw new DeskmanagerException(DeskmanagerException.CLIENT_LAYERID_ALREADY_IN_USE, lc.getClientLayerInfo() .getId()); } if (serverLayerMap.containsKey(lc.getClientLayerInfo().getServerLayerId())) { throw new DeskmanagerException(DeskmanagerException.SERVER_LAYERID_ALREADY_IN_USE, lc.getClientLayerInfo() .getServerLayerId()); } Map<String, Object> params = new HashMap<String, Object>(); params.put(BeanFactory.BEAN_NAME, lc.getClientLayerInfo().getServerLayerId()); if (lc instanceof DynamicVectorLayerConfiguration) { createVectorLayerParams((DynamicVectorLayerConfiguration) lc, params); } else if (lc instanceof DynamicRasterLayerConfiguration) { createRasterLayerParams((DynamicRasterLayerConfiguration) lc, params); } else { return null; } return params; }
private Map<String, Object> createBeanClientLayerDefinitionParameters(DynamicLayerConfiguration lc) throws Exception { if (clientLayerInfoMap.containsKey(lc.getClientLayerInfo().getId())) { throw new DeskmanagerException(DeskmanagerException.CLIENT_LAYERID_ALREADY_IN_USE, lc.getClientLayerInfo() .getId()); } if (serverLayerMap.containsKey(lc.getClientLayerInfo().getServerLayerId())) { throw new DeskmanagerException(DeskmanagerException.SERVER_LAYERID_ALREADY_IN_USE, lc.getClientLayerInfo() .getServerLayerId()); } Map<String, Object> params = new HashMap<String, Object>(); params.put(BeanFactory.BEAN_NAME, lc.getClientLayerInfo().getServerLayerId()); if (lc instanceof DynamicVectorLayerConfiguration) { createVectorLayerParams((DynamicVectorLayerConfiguration) lc, params); } else if (lc instanceof DynamicRasterLayerConfiguration) { createRasterLayerParams((DynamicRasterLayerConfiguration) lc, params); } else { return null; } return params; }
/** * Updates blueprint that has no layers set so that the layers configured in the userApplication are inserted into * the database. * */ @Transactional(rollbackFor = { Exception.class }) private void updateBluePrintMainMapFromUserApplication(Blueprint bp) { UserApplicationInfo uai = getUserApplication(bp.getUserApplicationKey()); if (uai != null) { ClientMapInfo mainMap = null; for (ClientMapInfo map : uai.getApplicationInfo().getMaps()) { if (GdmLayout.MAPMAIN_ID.equals(map.getId())) { mainMap = map; } } Map<String, LayerModel> layerModels = new HashMap<String, LayerModel>(); for (LayerModel lm : layerModelService.getLayerModelsInternal()) { layerModels.put(lm.getClientLayerId(), lm); } for (ClientLayerInfo clientLayer : mainMap.getLayers()) { org.geomajas.plugin.deskmanager.domain.ClientLayer layer = new org.geomajas.plugin.deskmanager.domain.ClientLayer(); layer.setLayerModel(layerModels.get(clientLayer.getId())); bp.getMainMapLayers().add(layer); } } }
/** * Updates blueprint that has no layers set so that the layers configured in the userApplication are inserted into * the database. * */ @Transactional(rollbackFor = { Exception.class }) private void updateBluePrintOverviewMapFromUserApplication(Blueprint bp) { UserApplicationInfo uai = getUserApplication(bp.getUserApplicationKey()); if (uai != null) { ClientMapInfo overviewMap = null; for (ClientMapInfo map : uai.getApplicationInfo().getMaps()) { if (GdmLayout.MAPOVERVIEW_ID.equals(map.getId())) { overviewMap = map; } } Map<String, LayerModel> models = new HashMap<String, LayerModel>(); for (LayerModel model : layerModelService.getLayerModelsInternal()) { models.put(model.getClientLayerId(), model); } for (ClientLayerInfo clientLayer : overviewMap.getLayers()) { org.geomajas.plugin.deskmanager.domain.ClientLayer layer = new org.geomajas.plugin.deskmanager.domain.ClientLayer(); LayerModel model = models.get(clientLayer.getId()); layer.setLayerModel(model); bp.getOverviewMapLayers().add(layer); } } }
private void buildDeskmanagerAuthorizationInfo() { // Set basic authorization info (from configuration) deskmanagerAuthorizationInfo = (DeskmanagerAuthorizationInfo) deskmanagerAuthorizationInfos.get( profile.getRole().toString()).clone(); // Add geodesk specific authorization if (geodeskId != null && !RetrieveRolesRequest.MANAGER_ID.equals(geodeskId) && isGeodeskUseAllowed(geodeskId)) { try { LOG.debug("building deskmanagerAauthorizationInfo"); Geodesk geodesk = geodeskService.getGeodeskByPublicId(geodeskId); ClientApplicationInfo geodeskInfo = applicationContext.getBean(GeodeskConfigurationService.class) .createGeodeskConfiguration(geodesk, true); // Add all layers visible in this geodesk if (geodeskInfo != null) { for (ClientMapInfo map : geodeskInfo.getMaps()) { for (ClientLayerInfo layer : map.getLayers()) { // Add layers if they are public, or the user is not guest. if (!profile.getRole().equals(Role.GUEST) || layerModelService. getLayerModelByClientLayerIdInternal(layer.getId()).isPublic()) { deskmanagerAuthorizationInfo.getVisibleLayersInclude().add(layer.getServerLayerId()); } } } } } catch (GeomajasSecurityException e) { LOG.error("Error building authorization info, insuficcent rights.", e); } } }
/** * Create a new layer that belongs to the given map model, using the given meta-data. * * @param layerInfo * The layer configuration from which to create the layer. * @param viewPort * The view port of the map. * @param eventBus * The map centric event bus. */ public AbstractServerLayer(T layerInfo, ViewPort viewPort, MapEventBus eventBus) { super(layerInfo.getId()); this.layerInfo = layerInfo; this.markedAsVisible = layerInfo.isVisible(); this.title = layerInfo.getLabel(); setViewPort(viewPort); setEventBus(eventBus); eventBus.addViewPortChangedHandler(new LayerScaleVisibilityHandler()); }
protected void renderViewConfig(ViewConfig viewConfig) { themeChange = true; RangeConfig config = getRangeConfigForCurrentScale(viewConfig, mapWidget.getMapModel().getMapView() .getCurrentScale()); if (themeInfo.isHideOtherlayers()) { for (Layer<?> layer : mapWidget.getMapModel().getLayers()) { layer.setVisible(false); } } for (LayerConfig layerConfig : config.getLayerConfigs()) { Layer<?> layer = mapWidget.getMapModel().getLayer(layerConfig.getLayer().getId()); if (layer != null) { layer.setVisible(layerConfig.isVisible()); if (layer instanceof RasterLayer) { ((RasterLayer) layer).setOpacity(layerConfig.getOpacity()); } } else { GWT.log("ThemeWidget: could not find layer: " + layerConfig.getLayer().getId()); } } // LayerShownEvents are run async, we need to deactivate after these. GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { themeChange = false; } public void onFailure(Throwable reason) { } }); }
@Override public void execute(CreateLayerModelRequest request, LayerModelResponse response) throws Exception { if (request.getConfiguration() == null || request.getConfiguration().getClientLayerInfo() == null || request.getConfiguration().getClientLayerInfo().getUserData() == null) { Exception e = new IllegalArgumentException("Error while saving layermodel: configuration is required."); log.error(e.getLocalizedMessage()); throw e; } DeskmanagerClientLayerInfo ud = (DeskmanagerClientLayerInfo) request.getConfiguration().getClientLayerInfo() .getUserData(); ClientLayerInfo cvli = request.getConfiguration().getClientLayerInfo(); LayerModel lm = new LayerModel(); lm.setDynamicLayerConfiguration(request.getConfiguration()); lm.setActive(ud.isActive()); lm.setPublic(ud.isPublic()); lm.setName(cvli.getLabel()); lm.setClientLayerId(cvli.getId()); lm.setDefaultVisible(cvli.isVisible()); lm.setMaxScale(cvli.getMaximumScale()); lm.setMinScale(cvli.getMinimumScale()); lm.setLayerType(request.getConfiguration().getServerLayerInfo().getLayerType()); Territory g = ((DeskmanagerSecurityContext) securityContext).getTerritory(); if (g != null && g.getId() > 0) { // 0 = superuser lm.setOwner(groupService.getById(g.getId())); } layerModelService.saveOrUpdateLayerModel(lm); response.setLayerModel(dtoService.toDto(lm, false/* TODO: , request.getLocale() */)); }
@Override public void execute(CreateLayerModelRequest request, LayerModelResponse response) throws Exception { if (request.getConfiguration() == null || request.getConfiguration().getClientLayerInfo() == null || request.getConfiguration().getClientLayerInfo().getUserData() == null) { Exception e = new IllegalArgumentException("Error while saving layermodel: configuration is required."); LOG.error(e.getLocalizedMessage()); throw e; } DeskmanagerClientLayerInfo ud = (DeskmanagerClientLayerInfo) request.getConfiguration().getClientLayerInfo() .getUserData(); ClientLayerInfo cvli = request.getConfiguration().getClientLayerInfo(); LayerModel lm = new LayerModel(); lm.setDynamicLayerConfiguration(request.getConfiguration()); lm.setActive(ud.isActive()); lm.setPublic(ud.isPublic()); lm.setName(cvli.getLabel()); lm.setClientLayerId(cvli.getId()); lm.setDefaultVisible(cvli.isVisible()); lm.setMaxScale(cvli.getMaximumScale()); lm.setMinScale(cvli.getMinimumScale()); lm.setLayerType(request.getConfiguration().getServerLayerInfo().getLayerType()); Territory g = ((DeskmanagerSecurityContext) securityContext).getTerritory(); if (g != null && g.getId() > 0) { // 0 = superuser lm.setOwner(groupService.getById(g.getId())); } layerModelService.saveOrUpdateLayerModel(lm); response.setLayerModel(dtoService.toDto(lm, false/* TODO: , request.getLocale() */)); }
private LayerModel toLayerModel(ClientLayerInfo cli) { LayerModel lm = new LayerModel(); DeskmanagerClientLayerInfo ecli = layerModelService.getExtraInfo(cli); // Get layerInfo via server layer LayerInfo sli = null; Layer<LayerInfo> layer = serverLayerMap.get(cli.getServerLayerId()); if (null != layer) { sli = layer.getLayerInfo(); } lm.setActive(ecli.isActive()); lm.setClientLayerId(cli.getId()); lm.setName(ecli.getName() == null ? cli.getLabel() : ecli.getName()); lm.setPublic(ecli.isPublic()); lm.setMinScale(cli.getMinimumScale()); lm.setMaxScale(cli.getMaximumScale()); lm.setDefaultVisible(cli.isVisible()); lm.setReadOnly(true); lm.setLayerType(sli.getLayerType()); if (null != layer && LayerType.RASTER.equals(sli.getLayerType())) { lm.setDynamicLayerConfiguration(new DynamicRasterLayerConfiguration()); } else if (null != layer) { lm.setDynamicLayerConfiguration(new DynamicVectorLayerConfiguration()); } return lm; } }
private LayerModel toLayerModel(ClientLayerInfo cli) { LayerModel lm = new LayerModel(); DeskmanagerClientLayerInfo ecli = layerModelService.getExtraInfo(cli); // Get layerInfo via server layer LayerInfo sli = null; Layer<LayerInfo> layer = serverLayerMap.get(cli.getServerLayerId()); if (null != layer) { sli = layer.getLayerInfo(); } lm.setActive(ecli.isActive()); lm.setClientLayerId(cli.getId()); lm.setName(ecli.getName() == null ? cli.getLabel() : ecli.getName()); lm.setPublic(ecli.isPublic()); lm.setMinScale(cli.getMinimumScale()); lm.setMaxScale(cli.getMaximumScale()); lm.setDefaultVisible(cli.isVisible()); lm.setReadOnly(true); lm.setLayerType(sli.getLayerType()); if (null != layer && LayerType.RASTER.equals(sli.getLayerType())) { lm.setDynamicLayerConfiguration(new DynamicRasterLayerConfiguration()); } else if (null != layer) { lm.setDynamicLayerConfiguration(new DynamicVectorLayerConfiguration()); } return lm; } }