use of com.sldeditor.common.data.StyleWrapper in project sldeditor by robward-scisys.
the class GeoServerClient method refreshWorkspace.
/**
* Refresh workspace.
*
* @param workspaceName the workspace name
*/
@Override
public void refreshWorkspace(String workspaceName) {
GeoServerRESTManager manager = GeoServerRESTManagerFactory.getManager(connection);
if (manager != null) {
GeoServerRESTReader reader = manager.getReader();
if (reader != null) {
Map<String, List<StyleWrapper>> styleMap = new LinkedHashMap<String, List<StyleWrapper>>();
int count = 1;
List<StyleWrapper> styleList = new ArrayList<StyleWrapper>();
if (workspaceName.compareTo(DEFAULT_WORKSPACE_NAME) == 0) {
count = parseStyleInDefaultWorkspace(reader, count, styleList);
styleMap.put(DEFAULT_WORKSPACE_NAME, styleList);
} else {
// Read styles from workspace
count = parseStyleInWorkspace(reader, styleMap, count, workspaceName);
}
if (parentObj != null) {
parentObj.readStylesComplete(connection, styleMap, true);
}
}
}
}
use of com.sldeditor.common.data.StyleWrapper in project sldeditor by robward-scisys.
the class GeoServerClient method parseStyleInWorkspace.
/**
* Parses the style in workspace.
*
* @param reader the reader
* @param styleMap the style map
* @param count the count
* @param workspaceName the workspace name
* @return the int
*/
private int parseStyleInWorkspace(GeoServerRESTReader reader, Map<String, List<StyleWrapper>> styleMap, int count, String workspaceName) {
List<StyleWrapper> styleList;
if (workspaceName != null) {
RESTStyleList geoServerWorkspaceStyleList = reader.getStyles(workspaceName);
styleList = new ArrayList<StyleWrapper>();
for (String style : geoServerWorkspaceStyleList.getNames()) {
StyleWrapper newStyleWrapper = new StyleWrapper(workspaceName, style);
styleList.add(newStyleWrapper);
if (parentObj != null) {
parentObj.readStylesProgress(connection, count, count);
}
count++;
}
styleMap.put(workspaceName, styleList);
}
return count;
}
use of com.sldeditor.common.data.StyleWrapper in project sldeditor by robward-scisys.
the class GeoServerInput method copyNodes.
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.FileSystemInterface#drop(com.sldeditor.extension.input.NodeInterface, java.util.Map)
*/
@Override
public boolean copyNodes(NodeInterface destinationTreeNode, Map<NodeInterface, List<SLDDataInterface>> droppedDataMap) {
if (droppedDataMap == null) {
return false;
}
if (destinationTreeNode instanceof GeoServerWorkspaceNode) {
GeoServerWorkspaceNode workspaceNode = (GeoServerWorkspaceNode) destinationTreeNode;
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(workspaceNode.getConnection());
if (client == null) {
return false;
} else {
for (NodeInterface key : droppedDataMap.keySet()) {
for (SLDDataInterface sldData : droppedDataMap.get(key)) {
StyleWrapper styleWrapper = sldData.getStyle();
removeStyleFileExtension(styleWrapper);
styleWrapper.setWorkspace(workspaceNode.getWorkspaceName());
client.uploadSLD(styleWrapper, sldData.getSld());
}
}
client.refreshWorkspace(workspaceNode.getWorkspaceName());
}
return true;
}
return false;
}
use of com.sldeditor.common.data.StyleWrapper in project sldeditor by robward-scisys.
the class StyleWrapperTest method test.
@Test
public void test() {
StyleWrapper styleWrapper = new StyleWrapper();
assertNull(styleWrapper.getStyle());
assertNull(styleWrapper.getWorkspace());
String expectedStyle = "test style";
styleWrapper.setStyle(expectedStyle);
assertEquals(styleWrapper.getStyle().compareTo(expectedStyle), 0);
String expectedWorkspace = "test workspace";
styleWrapper.setWorkspace(expectedWorkspace);
assertEquals(styleWrapper.getWorkspace().compareTo(expectedWorkspace), 0);
// Clone
StyleWrapper clone = styleWrapper.clone();
assertTrue(styleWrapper.compareTo(null) != 0);
assertTrue(styleWrapper.compareTo(clone) == 0);
}
use of com.sldeditor.common.data.StyleWrapper in project sldeditor by robward-scisys.
the class GeoServerLayerTest method testGetStyleString.
/**
* Test method for {@link com.sldeditor.common.data.GeoServerLayer#getStyleString()}.
* Test method for {@link com.sldeditor.common.data.GeoServerLayer#setDefaultWorkspaceName(java.lang.String)}.
*/
@Test
public void testGetStyleString() {
GeoServerLayer.setDefaultWorkspaceName(null);
StyleWrapper styleWrapper = new StyleWrapper();
String style = "style";
styleWrapper.setStyle(style);
String workspace = "workspace";
styleWrapper.setWorkspace(workspace);
GeoServerLayer layer = new GeoServerLayer();
layer.setStyle(styleWrapper);
String styleString = layer.getStyleString();
assertTrue(style.compareTo(styleString) == 0);
String defaultWorkspaceName = "Default workspace";
styleWrapper.setWorkspace(defaultWorkspaceName);
layer.setStyle(styleWrapper);
GeoServerLayer.setDefaultWorkspaceName(defaultWorkspaceName);
String styleString2 = layer.getStyleString();
assertTrue(style.compareTo(styleString2) == 0);
styleWrapper.setWorkspace(workspace);
layer.setStyle(styleWrapper);
String styleString3 = layer.getStyleString();
assertEquals(styleString3.compareTo(workspace + ":" + style), 0);
}
Aggregations