use of com.sldeditor.common.data.SLDData 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.common.data.SLDData in project sldeditor by robward-scisys.
the class VectorReader method createVectorSLDData.
/**
* Creates the vector sld.
*
* @param vectorFile the vector file
* @return the styled layer descriptor
*/
@Override
public SLDDataInterface createVectorSLDData(File vectorFile) {
if (vectorFile == null) {
return null;
}
Map<String, Object> map = null;
try {
map = DataSourceProperties.encodeFilename(vectorFile.toURI().toURL().toString());
} catch (MalformedURLException e) {
ConsoleManager.getInstance().exception(this, e);
return null;
}
StyledLayerDescriptor sld = createSLDData(map, null);
SLDData sldData = null;
if (sld != null) {
File sldFilename = ExternalFilenames.createSLDFilename(vectorFile);
StyleWrapper styleWrapper = new StyleWrapper(sldFilename.getName());
String sldContents = sldWriter.encodeSLD(null, sld);
sldData = new SLDData(styleWrapper, sldContents);
sldData.setSLDFile(sldFilename);
sldData.setReadOnly(false);
}
return sldData;
}
use of com.sldeditor.common.data.SLDData in project sldeditor by robward-scisys.
the class VectorReader method createVectorSLDData.
/*
* (non-Javadoc)
*
* @see com.sldeditor.tool.vector.VectorReaderInterface#createVectorSLDData(com.sldeditor.common.data.DatabaseConnection, java.lang.String)
*/
@Override
public SLDDataInterface createVectorSLDData(DatabaseConnection databaseConnection, String featureClass) {
if ((databaseConnection == null) || (featureClass == null)) {
return null;
}
Map<String, Object> map = DatabaseConnectionManager.getInstance().getDBConnectionParams(databaseConnection);
StyledLayerDescriptor sld = createSLDData(map, featureClass);
SLDData sldData = null;
if (sld != null) {
File sldFilename = null;
StyleWrapper styleWrapper = new StyleWrapper(featureClass);
String sldContents = sldWriter.encodeSLD(null, sld);
sldData = new SLDData(styleWrapper, sldContents);
sldData.setSLDFile(sldFilename);
sldData.setReadOnly(false);
}
return sldData;
}
use of com.sldeditor.common.data.SLDData in project sldeditor by robward-scisys.
the class SLDDataTest method testGetLayerName.
/**
* Test get layer name.
*/
@Test
public void testGetLayerName() {
String styleName = "style";
String styleFilename = styleName + ".sld";
StyleWrapper styleWrapper = new StyleWrapper("workspace", styleFilename);
SLDData data = new SLDData(styleWrapper, null);
String actualLayerName = data.getLayerName();
assertEquals(styleFilename, actualLayerName);
String actualLayerNameWithOutSuffix = data.getLayerNameWithOutSuffix();
assertEquals(styleName, actualLayerNameWithOutSuffix);
}
use of com.sldeditor.common.data.SLDData in project sldeditor by robward-scisys.
the class SLDDataTest method testUpdateSLDContents.
/**
* Test update sld contents.
*/
@Test
public void testUpdateSLDContents() {
String sldContents = "Original sld contents";
SLDData data = new SLDData(null, sldContents);
assertEquals(sldContents, data.getSld());
String updateSldContents = "Updated sld contents";
data.updateSLDContents(updateSldContents);
assertEquals(updateSldContents, data.getSld());
}
Aggregations