use of com.sldeditor.common.data.GeoServerLayer in project sldeditor by robward-scisys.
the class GeoServerClient method parseLayerList.
/**
* Parses the layer list.
*
* @param reader the reader
* @param existingWorkspaceList the existing workspace list
* @param workspaceName the workspace name
*/
private void parseLayerList(GeoServerRESTReader reader, List<String> existingWorkspaceList, String workspaceName) {
Thread t1 = new Thread(new Runnable() {
public void run() {
List<String> workspaceList = null;
if (workspaceName == null) {
workspaceList = existingWorkspaceList;
// Add the default workspace last
workspaceList.add(null);
}
Map<String, List<GeoServerLayer>> layerMap = new LinkedHashMap<String, List<GeoServerLayer>>();
RESTLayerList layers = reader.getLayers();
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 = null;
for (String workspaceNameToTest : workspaceList) {
if (reader.existsLayer(workspaceNameToTest, layerName, true)) {
if (workspaceNameToTest == null) {
workspace = DEFAULT_WORKSPACE_NAME;
} else {
workspace = workspaceNameToTest;
}
break;
}
}
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<GeoServerLayer>();
layerMap.put(workspace, layerList);
}
layerList.add(geoServerlayer);
if (parentObj != null) {
parentObj.readLayersProgress(connection, count, total);
}
}
count++;
}
if (parentObj != null) {
parentObj.readLayersComplete(connection, layerMap);
}
}
});
t1.start();
}
use of com.sldeditor.common.data.GeoServerLayer in project sldeditor by robward-scisys.
the class GeoServerLayerUpdateTool method extractWorkspaceLayers.
private void extractWorkspaceLayers(GeoServerWorkspaceNode workspaceNode) {
for (int layerIndex = 0; layerIndex < workspaceNode.getChildCount(); layerIndex++) {
TreeNode childTreeNode = workspaceNode.getChildAt(layerIndex);
if (childTreeNode instanceof GeoServerLayerNode) {
GeoServerLayerNode layerNode = (GeoServerLayerNode) childTreeNode;
GeoServerLayer layer = layerNode.getLayer();
layerList.add(layer);
}
}
}
use of com.sldeditor.common.data.GeoServerLayer in project sldeditor by robward-scisys.
the class GeoServerLayerTest method testGetStyle.
/**
* Test method for {@link com.sldeditor.common.data.GeoServerLayer#getStyle()}.
* Test method for {@link com.sldeditor.common.data.GeoServerLayer#setStyle(com.sldeditor.common.data.StyleWrapper)}.
*/
@Test
public void testGetStyle() {
StyleWrapper styleWrapper = new StyleWrapper();
styleWrapper.setStyle("style");
styleWrapper.setStyle("workspace");
GeoServerLayer layer = new GeoServerLayer();
layer.setStyle(styleWrapper);
assertEquals(styleWrapper, layer.getStyle());
}
use of com.sldeditor.common.data.GeoServerLayer in project sldeditor by robward-scisys.
the class GeoServerInputTest method testGetStyleMap.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#getStyleMap(com.sldeditor.common.data.GeoServerConnection)}.
*/
@Test
public void testGetStyleMap() {
GeoServerInput input = new GeoServerInput(null);
GeoServerInput.overrideGeoServerClientClass(DummyGeoServerClient.class);
// Add some GeoServer connections
GeoServerConnection connection1 = new GeoServerConnection();
connection1.setConnectionName("test connection 1");
input.addNewConnection(connection1);
GeoServerConnection connection2 = new GeoServerConnection();
connection2.setConnectionName("test connection 2");
input.addNewConnection(connection2);
// Try a null objects
Map<String, List<StyleWrapper>> actualStyleMap = input.getStyleMap(null);
assertNull(actualStyleMap);
actualStyleMap = input.getStyleMap(connection2);
assertNull(actualStyleMap);
Map<String, List<StyleWrapper>> expectedStyleMap = new HashMap<String, List<StyleWrapper>>();
// CHECKSTYLE:OFF
StyleWrapper[] styleWrappers = { new StyleWrapper("workspace", "style1"), new StyleWrapper("workspace", "style2") };
// CHECKSTYLE:ON
expectedStyleMap.put("style1", Arrays.asList(styleWrappers));
Map<String, List<GeoServerLayer>> expectedLayerMap = new HashMap<String, List<GeoServerLayer>>();
// CHECKSTYLE:OFF
GeoServerLayer[] geoServerLayers = { new GeoServerLayer("workspace", "style1"), new GeoServerLayer("workspace", "style2") };
// CHECKSTYLE:ON
expectedLayerMap.put("style1", Arrays.asList(geoServerLayers));
input.populateComplete(connection1, expectedStyleMap, expectedLayerMap);
actualStyleMap = input.getStyleMap(connection1);
assertEquals(expectedStyleMap, actualStyleMap);
}
use of com.sldeditor.common.data.GeoServerLayer in project sldeditor by robward-scisys.
the class GeoServerReadProgressTest method testGeoServerReadProgress.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.geoserver.GeoServerReadProgress#GeoServerReadProgress(com.sldeditor.common.filesystem.FileSystemInterface, com.sldeditor.extension.filesystem.geoserver.GeoServerParseCompleteInterface)}.
*/
@Test
public void testGeoServerReadProgress() {
DummyProgressComplete complete = new DummyProgressComplete();
GeoServerReadProgress progress = new GeoServerReadProgress(null, complete);
GeoServerOverallNode geoServerRootNode = new GeoServerOverallNode(null);
GeoServerConnection connection = new GeoServerConnection();
connection.setConnectionName("test connection 1");
GeoServerNode node = new GeoServerNode(null, connection);
geoServerRootNode.add(node);
progress.addNewConnectionNode(connection, node);
progress.startPopulating(null);
progress.startPopulating(connection);
progress.readLayersProgress(null, 0, 0);
assertFalse(complete.completed);
progress.readLayersProgress(connection, 0, 5);
progress.readLayersProgress(connection, 1, 5);
progress.readLayersProgress(connection, 2, 5);
progress.readLayersProgress(connection, 3, 5);
progress.readLayersProgress(connection, 4, 5);
progress.readLayersProgress(connection, 5, 5);
assertFalse(complete.completed);
progress.readLayersProgress(connection, 6, 5);
assertFalse(complete.completed);
progress.readStylesProgress(null, 0, 0);
progress.readStylesProgress(connection, 0, 3);
progress.readStylesProgress(connection, 1, 3);
progress.readStylesProgress(connection, 2, 3);
progress.readStylesProgress(connection, 3, 3);
progress.readStylesProgress(connection, 4, 3);
assertFalse(complete.completed);
Map<String, List<GeoServerLayer>> completedLayersMap = new HashMap<String, List<GeoServerLayer>>();
Map<String, List<StyleWrapper>> completedStyleMap = new HashMap<String, List<StyleWrapper>>();
progress.readLayersComplete(connection, completedLayersMap);
progress.readStylesComplete(connection, completedStyleMap, false);
assertTrue(complete.completed);
}
Aggregations