Search in sources :

Example 1 with GeoServerWorkspaceNode

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";
}
Also used : GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection)

Example 2 with GeoServerWorkspaceNode

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;
}
Also used : SLDData(com.sldeditor.common.data.SLDData) GeoServerNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode) ArrayList(java.util.ArrayList) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) GeoServerStyleNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode) GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleWrapper(com.sldeditor.common.data.StyleWrapper) GeoServerStyleHeadingNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with GeoServerWorkspaceNode

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());
        }
    }
}
Also used : GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) StyleWrapper(com.sldeditor.common.data.StyleWrapper) GeoServerStyleHeadingNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode) List(java.util.List) GeoServerStyleNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode)

Example 4 with GeoServerWorkspaceNode

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);
}
Also used : SLDData(com.sldeditor.common.data.SLDData) GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleWrapper(com.sldeditor.common.data.StyleWrapper) FSTree(com.sldeditor.datasource.extension.filesystem.node.FSTree) ArrayList(java.util.ArrayList) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) URL(java.net.URL) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Example 5 with GeoServerWorkspaceNode

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());
}
Also used : FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) Test(org.junit.Test)

Aggregations

GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)11 SLDDataInterface (com.sldeditor.common.SLDDataInterface)5 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)5 StyleWrapper (com.sldeditor.common.data.StyleWrapper)5 List (java.util.List)5 NodeInterface (com.sldeditor.common.NodeInterface)3 SLDData (com.sldeditor.common.data.SLDData)3 GeoServerClientInterface (com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 Test (org.junit.Test)3 GeoServerLayer (com.sldeditor.common.data.GeoServerLayer)2 FSTree (com.sldeditor.datasource.extension.filesystem.node.FSTree)2 GeoServerLayerHeadingNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerHeadingNode)2 GeoServerLayerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode)2 GeoServerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode)2 GeoServerStyleHeadingNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode)2 GeoServerStyleNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode)2 GeoServerInput (com.sldeditor.extension.filesystem.geoserver.GeoServerInput)2