use of com.sldeditor.common.DataSourcePropertiesInterface in project sldeditor by robward-scisys.
the class VectorTool method importFile.
/**
* Import file.
*
* @param fileTreeNode the file tree node
*/
protected boolean importFile(FileTreeNode fileTreeNode) {
if (fileTreeNode != null) {
File vectorFile = fileTreeNode.getFile();
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(VectorTool.class, "VectorTool.createSymbol"), vectorFile.getAbsolutePath()));
SLDDataInterface sldData = vectorReader.createVectorSLDData(vectorFile);
DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(DataSourceConnector.class);
try {
String vectorFilename = vectorFile.toURI().toURL().toString();
dsProperties = dsc.getDataSourceProperties(DataSourceProperties.encodeFilename(vectorFilename));
} catch (MalformedURLException exceptionObj) {
ConsoleManager.getInstance().exception(VectorTool.class, exceptionObj);
return false;
}
loadSymbol(dsProperties, sldData, vectorFile);
}
return true;
}
use of com.sldeditor.common.DataSourcePropertiesInterface in project sldeditor by robward-scisys.
the class SLDEditorFileTest method testSLDData.
/**
* Test method for {@link com.sldeditor.datasource.SLDEditorFile#getSLDData()}. Test method for
* {@link com.sldeditor.datasource.SLDEditorFile#fileOpenedSaved()}. Test method for
* {@link com.sldeditor.datasource.SLDEditorFile#getSldEditorFile()}. Test method for
* {@link com.sldeditor.datasource.SLDEditorFile#addSLDEditorFileUpdateListener(com.sldeditor.datasource.SLDEditorDataUpdateInterface)}.
* Test method for {@link com.sldeditor.datasource.SLDEditorFile#renderSymbol()}. Test method
* for
* {@link com.sldeditor.datasource.SLDEditorFile#setSLDData(com.sldeditor.common.SLDDataInterface)}.
* Test method for {@link com.sldeditor.datasource.SLDEditorFile#setSldFile(java.io.File)}. Test
* method for {@link com.sldeditor.datasource.SLDEditorFile#getDataSource()}. Test method for
* {@link com.sldeditor.datasource.SLDEditorFile#setDataSource(com.sldeditor.DataSourcePropertiesInterface)}.
* Test method for
* {@link com.sldeditor.datasource.SLDEditorFile#setSldEditorFile(java.io.File)}.
*/
@Test
public void testSLDData() {
// Start with a blank canvas
SLDEditorFile.destroyInstance();
SelectedSymbol.destroyInstance();
assertNull(SLDEditorFile.getInstance().getSLD());
assertNull(SLDEditorFile.getInstance().getSLDData());
assertNull(SLDEditorFile.getInstance().getSldEditorFile());
assertNull(SLDEditorFile.getInstance().getDataSource());
SLDEditorFile.getInstance().setDataSource(null);
assertNull(SLDEditorFile.getInstance().getDataSource());
SLDEditorFile.getInstance().setSldEditorFile(null);
assertNull(SLDEditorFile.getInstance().getSldEditorFile());
SLDEditorFile.getInstance().setSldFile(null);
assertNull(SLDEditorFile.getInstance().getSLDData());
SLDEditorFile.getInstance().setSLDData(null);
assertNull(SLDEditorFile.getInstance().getSLDData());
DummyDataUpdate dataUpdateListener = new DummyDataUpdate();
SLDEditorFile.getInstance().addSLDEditorFileUpdateListener(dataUpdateListener);
// Set SLDData
StyleWrapper styleWrapper = new StyleWrapper("workspace", "style");
SLDData sldData = new SLDData(styleWrapper, "contents");
SLDEditorFile.getInstance().setSLDData(sldData);
SLDEditorFile.getInstance().fileOpenedSaved();
assertEquals(sldData, SLDEditorFile.getInstance().getSLDData());
assertFalse(dataUpdateListener.dataEditedFlag);
// Sld file
File sldFile = new File("test.txt");
SLDEditorFile.getInstance().setSldFile(sldFile);
assertEquals(sldFile.getAbsolutePath(), SLDEditorFile.getInstance().getSLDData().getSLDFile().getAbsolutePath());
assertFalse(dataUpdateListener.dataEditedFlag);
// Sld editor file
File sldEditorFile = new File("editor.file");
SLDEditorFile.getInstance().setSldEditorFile(sldEditorFile);
assertEquals(sldEditorFile.getAbsolutePath(), SLDEditorFile.getInstance().getSldEditorFile().getAbsolutePath());
assertFalse(dataUpdateListener.dataEditedFlag);
// Data source properties
SLDEditorFile.getInstance().setDataSource(null);
assertFalse(dataUpdateListener.dataEditedFlag);
DataSourcePropertiesInterface noDataSource = DataSourceConnectorFactory.getNoDataSource();
assertEquals(noDataSource.getDebugConnectionString(), SLDEditorFile.getInstance().getDataSource().getDebugConnectionString());
assertFalse(dataUpdateListener.dataEditedFlag);
DataSourcePropertiesInterface fileDSProperties = new DataSourceProperties(new DataSourceConnector());
assertEquals(fileDSProperties.getDebugConnectionString(), SLDEditorFile.getInstance().getDataSource().getDebugConnectionString());
assertFalse(dataUpdateListener.dataEditedFlag);
// Render symbol
SLDEditorFile.getInstance().renderSymbol();
assertTrue(dataUpdateListener.dataEditedFlag);
// File saved
SLDEditorFile.getInstance().fileOpenedSaved();
assertFalse(dataUpdateListener.dataEditedFlag);
assertNull(SLDEditorFile.getInstance().getRuleRenderOptions());
}
use of com.sldeditor.common.DataSourcePropertiesInterface in project sldeditor by robward-scisys.
the class DataSourceConnectorFactoryTest method testGetNoDataSource.
/**
* Test method for {@link com.sldeditor.datasource.connector.DataSourceConnectorFactory#getNoDataSource()}.
*/
@Test
public void testGetNoDataSource() {
DataSourcePropertiesInterface dsp = DataSourceConnectorFactory.getNoDataSource();
assertEquals(DataSourceConnectorEmpty.class, dsp.getDataSourceConnector().getClass());
}
use of com.sldeditor.common.DataSourcePropertiesInterface in project sldeditor by robward-scisys.
the class DataSourceConnectorFactoryTest method testGetDataSourcePropertiesMapOfStringString.
/**
* Test method for {@link com.sldeditor.datasource.connector.DataSourceConnectorFactory#getDataSourceProperties(java.util.Map)}.
*/
@Test
public void testGetDataSourcePropertiesMapOfStringString() {
Map<String, Object> propertyMap = new HashMap<String, Object>();
propertyMap.put("url", "filename.shp");
DataSourcePropertiesInterface dsp = DataSourceConnectorFactory.getDataSourceProperties(propertyMap);
assertEquals(DataSourceConnector.class, dsp.getDataSourceConnector().getClass());
propertyMap.clear();
propertyMap.put("host", "localhost");
propertyMap.put("port", "5432");
propertyMap.put("database", "testdb");
propertyMap.put("user", "testuser");
propertyMap.put("passwd", "pasword123");
propertyMap.put("schema", "public");
propertyMap.put("featureClass", "testfc");
dsp = DataSourceConnectorFactory.getDataSourceProperties(propertyMap);
assertEquals(DataSourceConnector.class, dsp.getDataSourceConnector().getClass());
}
use of com.sldeditor.common.DataSourcePropertiesInterface in project sldeditor by robward-scisys.
the class DataSourceConnectorFactoryTest method testGetDataSourcePropertiesString.
/**
* Test method for {@link com.sldeditor.datasource.connector.DataSourceConnectorFactory#getDataSourceProperties(java.lang.String)}.
*/
@Test
public void testGetDataSourcePropertiesString() {
DataSourcePropertiesInterface dsp = DataSourceConnectorFactory.getDataSourceProperties("filename.shp");
assertEquals(DataSourceConnector.class, dsp.getDataSourceConnector().getClass());
}
Aggregations