use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode in project sldeditor by robward-scisys.
the class GeoServerInput method getDestinationText.
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.FileSystemInterface#getDestinationText(com.sldeditor.extension.input.NodeInterface)
*/
@Override
public String getDestinationText(NodeInterface destinationTreeNode) {
if (destinationTreeNode instanceof GeoServerWorkspaceNode) {
GeoServerWorkspaceNode destinationNode = (GeoServerWorkspaceNode) destinationTreeNode;
GeoServerConnection connection = destinationNode.getConnection();
return String.format("GeoServer %s / Workspace %s", connection.getConnectionName(), destinationNode.getWorkspaceName());
}
return "Unknown";
}
use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode in project sldeditor by robward-scisys.
the class GeoServerInput method getSLDContents.
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.FileSystemInterface#getSLDContents(com.sldeditor.extension.input.NodeInterface)
*/
@Override
public SelectedFiles getSLDContents(NodeInterface node) {
if (node instanceof GeoServerStyleNode) {
GeoServerStyleNode styleNode = (GeoServerStyleNode) node;
GeoServerConnection connectionData = styleNode.getConnectionData();
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connectionData);
if (client != null) {
String sldContent = client.getStyle(styleNode.getStyle());
SLDDataInterface sldData = new SLDData(styleNode.getStyle(), sldContent);
sldData.setConnectionData(connectionData);
sldData.setReadOnly(false);
List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
sldDataList.add(sldData);
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setSldData(sldDataList);
selectedFiles.setDataSource(false);
selectedFiles.setConnectionData(connectionData);
return selectedFiles;
}
} else if (node instanceof GeoServerWorkspaceNode) {
GeoServerWorkspaceNode workspaceNode = (GeoServerWorkspaceNode) node;
GeoServerConnection connectionData = workspaceNode.getConnection();
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connectionData);
List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
if (workspaceNode.isStyle()) {
Map<String, List<StyleWrapper>> styleMap = getStyleMap(connectionData);
if ((client != null) && (styleMap != null)) {
for (StyleWrapper style : styleMap.get(workspaceNode.getWorkspaceName())) {
String sldContent = client.getStyle(style);
SLDDataInterface sldData = new SLDData(style, sldContent);
sldData.setConnectionData(connectionData);
sldData.setReadOnly(false);
sldDataList.add(sldData);
}
}
}
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setSldData(sldDataList);
selectedFiles.setDataSource(false);
selectedFiles.setConnectionData(connectionData);
return selectedFiles;
} else if (node instanceof GeoServerStyleHeadingNode) {
GeoServerStyleHeadingNode styleHeadingNode = (GeoServerStyleHeadingNode) node;
GeoServerConnection connectionData = styleHeadingNode.getConnection();
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connectionData);
List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
Map<String, List<StyleWrapper>> styleMap = getStyleMap(connectionData);
if ((client != null) && (styleMap != null)) {
for (String workspaceName : styleMap.keySet()) {
for (StyleWrapper style : styleMap.get(workspaceName)) {
String sldContent = client.getStyle(style);
SLDDataInterface sldData = new SLDData(style, sldContent);
sldData.setConnectionData(connectionData);
sldData.setReadOnly(false);
sldDataList.add(sldData);
}
}
}
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setSldData(sldDataList);
selectedFiles.setDataSource(false);
selectedFiles.setConnectionData(connectionData);
return selectedFiles;
} else if (node instanceof GeoServerNode) {
GeoServerNode geoServerNode = (GeoServerNode) node;
GeoServerConnection connectionData = geoServerNode.getConnection();
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setDataSource(false);
selectedFiles.setConnectionData(connectionData);
return selectedFiles;
}
return null;
}
use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode in project sldeditor by robward-scisys.
the class GeoServerReadProgress method populateStyles.
/**
* Populate styles.
*
* @param connection the connection
* @param geoServerNode the geo server node
*/
private void populateStyles(GeoServerConnection connection, GeoServerNode geoServerNode) {
removeNode(geoServerNode, STYLES_NODE_TITLE);
GeoServerStyleHeadingNode styleNode = new GeoServerStyleHeadingNode(this.handler, connection, STYLES_NODE_TITLE);
geoServerNode.add(styleNode);
Map<String, List<StyleWrapper>> styleMap = geoServerStyleMap.get(connection);
for (String workspaceName : styleMap.keySet()) {
List<StyleWrapper> styleList = styleMap.get(workspaceName);
GeoServerWorkspaceNode workspaceNode = new GeoServerWorkspaceNode(this.handler, connection, workspaceName, true);
// It is key to invoke this on the TreeModel, and NOT DefaultMutableTreeNode
treeModel.insertNodeInto(workspaceNode, styleNode, styleNode.getChildCount());
for (StyleWrapper styleWrapper : styleList) {
GeoServerStyleNode childNode = new GeoServerStyleNode(this.handler, connection, styleWrapper);
// It is key to invoke this on the TreeModel, and NOT DefaultMutableTreeNode
treeModel.insertNodeInto(childNode, workspaceNode, workspaceNode.getChildCount());
}
}
}
use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode in project sldeditor by robward-scisys.
the class GeoServerInputTest method testDeleteNodes.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#deleteNodes(com.sldeditor.common.NodeInterface, java.util.List)}.
*/
@Test
public void testDeleteNodes() {
GeoServerInput input = new GeoServerInput(null);
GeoServerInput.overrideGeoServerClientClass(DummyGeoServerClient.class);
FSTree tree = new FSTree();
DefaultMutableTreeNode rootNode;
rootNode = new DefaultMutableTreeNode("Root");
DefaultTreeModel model = new DefaultTreeModel(rootNode);
input.populate(tree, model, rootNode);
URL url = SLDFileHandlerTest.class.getResource("/sld/point_attribute.sld");
List<SLDDataInterface> sldDataList = input.open(url);
assertNull(sldDataList);
GeoServerConnection connection1 = new GeoServerConnection();
connection1.setConnectionName("test connection 1");
// Add some GeoServer connections
input.addNewConnection(connection1);
// Try null parameters
assertFalse(input.copyNodes(null, null));
// Try with valid parameters
// CHECKSTYLE:OFF
GeoServerWorkspaceNode workspaceTreeNode = new GeoServerWorkspaceNode(input, connection1, "test workspace", false);
// CHECKSTYLE:ON
// Create test data
List<SLDDataInterface> sldToDeleteList = new ArrayList<SLDDataInterface>();
StyleWrapper styleWrapper = new StyleWrapper("workspace", "layer1");
SLDData sldData = new SLDData(styleWrapper, "sld contents");
sldData.setConnectionData(connection1);
sldToDeleteList.add(sldData);
input.deleteNodes(null, null);
input.deleteNodes(workspaceTreeNode, null);
input.deleteNodes(null, sldToDeleteList);
// Try with valid parameters
input.deleteNodes(workspaceTreeNode, sldToDeleteList);
}
use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode in project sldeditor by robward-scisys.
the class GeoServerWorkspaceNodeTest method testGeoServerLayerNode.
/**
* Test method for
* {@link com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode#GeoServerStyleNode(com.sldeditor.common.filesystem.FileSystemInterface)}.
*/
@Test
public void testGeoServerLayerNode() {
FileSystemInterface fileHandler = new DummyFileSystemInput();
GeoServerConnection connection = new GeoServerConnection();
connection.setConnectionName("test connection");
connection.setUserName("test user name");
String workspaceName = "workspace";
GeoServerWorkspaceNode node = new GeoServerWorkspaceNode(fileHandler, connection, workspaceName, true);
assertEquals(fileHandler, node.getHandler());
assertEquals(connection, node.getConnection());
assertEquals(workspaceName, node.getWorkspaceName());
assertEquals(DataFlavourManager.GEOSERVER_WORKSPACE_DATAITEM_FLAVOUR, node.getDataFlavour());
assertNull(node.getDestinationText());
}
Aggregations