it.geosolutions.geoserver.rest.decoder.RESTLayer Java Examples

The following examples show how to use it.geosolutions.geoserver.rest.decoder.RESTLayer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeoServerClient.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Parses the layer.
 *
 * @param reader the reader
 * @param localWorkspaceList the local workspace list
 * @param layerMap the layer map
 * @param layers the layers
 */
private void parseLayer(
        GeoServerRESTReader reader,
        List<String> localWorkspaceList,
        Map<String, List<GeoServerLayer>> layerMap,
        RESTLayerList layers) {
    int count = 1;
    int total = layers.size();

    for (NameLinkElem featureTypeName : layers) {
        @SuppressWarnings("deprecation")
        RESTLayer layer = reader.getLayer(featureTypeName.getName());

        if (layer != null) {
            String layerName = layer.getName();
            String workspace = getLayerWorkspace(reader, localWorkspaceList, layerName);
            GeoServerLayer geoServerlayer = new GeoServerLayer();
            geoServerlayer.setLayerWorkspace(workspace);
            geoServerlayer.setLayerName(layerName);
            geoServerlayer.setConnection(connection);

            StyleWrapper styleWrapper = new StyleWrapper();
            styleWrapper.setStyle(layer.getDefaultStyle());

            String styleWorkspace = layer.getDefaultStyleWorkspace();
            styleWrapper.setWorkspace(
                    (styleWorkspace == null) ? DEFAULT_WORKSPACE_NAME : styleWorkspace);

            geoServerlayer.setStyle(styleWrapper);

            List<GeoServerLayer> layerList = layerMap.get(workspace);

            if (layerList == null) {
                layerList = new ArrayList<>();
                layerMap.put(workspace, layerList);
            }
            layerList.add(geoServerlayer);

            if (parentObj != null) {
                parentObj.readLayersProgress(connection, count, total);
            }
        }

        count++;
    }
}