use of com.sldeditor.extension.filesystem.database.client.DatabaseClientInterface in project sldeditor by robward-scisys.
the class DatabaseConnectionManager method createDatabaseClient.
/**
* Creates the database client.
*
* @param progress the progress
* @param connection the connection
* @return the database client
*/
private DatabaseClientInterface createDatabaseClient(DatabaseReadProgressInterface progress, DatabaseConnection connection) {
for (DatabaseClientInterface client : databaseClientClassList) {
if (client.accept(connection)) {
DatabaseClientInterface newClient = null;
try {
newClient = (DatabaseClientInterface) Class.forName(client.getClass().getName()).newInstance();
newClient.initialise(progress, connection);
return newClient;
} catch (InstantiationException e) {
ConsoleManager.getInstance().exception(DatabaseInput.class, e);
} catch (IllegalAccessException e) {
ConsoleManager.getInstance().exception(DatabaseInput.class, e);
} catch (ClassNotFoundException e) {
ConsoleManager.getInstance().exception(DatabaseInput.class, e);
}
}
}
return null;
}
use of com.sldeditor.extension.filesystem.database.client.DatabaseClientInterface in project sldeditor by robward-scisys.
the class DatabaseInput method connectToDatabase.
/**
* Connect to database.
*
* @param connection the connection
* @return true, if successful
*/
private boolean connectToDatabase(DatabaseConnection connection) {
boolean isConnected = false;
DatabaseConnection dbConnection = DatabaseConnectionManager.getInstance().getMatchingConnection(connection);
if (dbConnection == null) {
addNewConnection(connection);
dbConnection = connection;
}
DatabaseClientInterface client = DatabaseConnectionManager.getInstance().getConnectionMap().get(dbConnection);
if (client != null) {
client.connect();
if (client.isConnected()) {
String message = String.format("%s : %s", Localisation.getString(GeoServerConnectionTool.class, "GeoServerConnectionTool.connected"), dbConnection.getConnectionName());
ConsoleManager.getInstance().information(GeoServerConnectionTool.class, message);
client.retrieveData();
isConnected = true;
} else {
String errorMessage = String.format("%s : %s", Localisation.getString(GeoServerConnectionTool.class, "GeoServerConnectionTool.failedToConnect"), dbConnection.getConnectionName());
ConsoleManager.getInstance().error(GeoServerConnectionTool.class, errorMessage);
}
}
return isConnected;
}
use of com.sldeditor.extension.filesystem.database.client.DatabaseClientInterface in project sldeditor by robward-scisys.
the class DatabaseInput method deleteConnections.
/*
* (non-Javadoc)
*
* @see com.sldeditor.datasource.extension.filesystem.DatabaseConnectUpdateInterface#deleteConnections(java.util.List)
*/
@Override
public void deleteConnections(List<DatabaseConnection> connectionList) {
if (connectionList == null) {
return;
}
List<DefaultMutableTreeNode> overallNodesToRefresh = new ArrayList<DefaultMutableTreeNode>();
String overallNodeName = null;
for (DatabaseConnection connection : connectionList) {
logger.debug("Deleting connection : " + connection.getConnectionName());
DatabaseClientInterface client = DatabaseConnectionManager.getInstance().getConnectionMap().get(connection);
if (client != null) {
disconnectFromDatabase(client);
featureClassMap.remove(connection);
DatabaseConnectionManager.getInstance().removeConnection(connection);
progress.deleteConnection(connection);
DefaultMutableTreeNode overallNode = getRootDatabaseNode(connection);
if (!overallNodesToRefresh.contains(overallNode)) {
overallNodesToRefresh.add(overallNode);
}
overallNodeName = connection.getDatabaseTypeLabel();
}
}
updatePropertyFile();
for (DefaultMutableTreeNode overallNode : overallNodesToRefresh) {
progress.refreshNode(overallNode);
}
progress.setFolder(overallNodeName, null, false);
}
use of com.sldeditor.extension.filesystem.database.client.DatabaseClientInterface in project sldeditor by robward-scisys.
the class VectorTool method importFeatureClass.
/**
* Import feature class.
*
* @param featureClassNode the feature class node
* @return true, if successful
*/
protected boolean importFeatureClass(DatabaseFeatureClassNode featureClassNode) {
if (featureClassNode != null) {
DatabaseClientInterface dbClient = DatabaseConnectionManager.getInstance().getConnectionMap().get(featureClassNode.getConnectionData());
if (dbClient != null) {
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(VectorTool.class, "VectorTool.createSymbol"), featureClassNode.toString()));
SLDDataInterface sldData = vectorReader.createVectorSLDData(featureClassNode.getConnectionData(), featureClassNode.toString());
DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(dbClient.getClass());
dsProperties = dsc.getDataSourceProperties(dbClient.getDBConnectionParams());
dsProperties.setFilename(featureClassNode.toString());
loadSymbol(dsProperties, sldData, featureClassNode.toString(), featureClassNode.getConnectionData().getConnectionName());
}
}
return false;
}
use of com.sldeditor.extension.filesystem.database.client.DatabaseClientInterface in project sldeditor by robward-scisys.
the class VectorTool method setDataSource.
/**
* Sets the data source.
*
* @param featureClassNode the new data source
*/
protected void setDataSource(DatabaseFeatureClassNode featureClassNode) {
DatabaseClientInterface dbClient = DatabaseConnectionManager.getInstance().getConnectionMap().get(featureClassNode.getConnectionData());
if (dbClient != null) {
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(VectorTool.class, "VectorTool.setDataSource"), featureClassNode.toString()));
// Vector file
DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(dbClient.getClass());
dsProperties = dsc.getDataSourceProperties(dbClient.getDBConnectionParams());
dsProperties.setFilename(featureClassNode.toString());
SLDEditorFile.getInstance().setDataSource(dsProperties);
DataSourceInterface dataSource = DataSourceFactory.createDataSource(null);
if (dataSource != null) {
dataSource.connect(featureClassNode.toString(), SLDEditorFile.getInstance(), CheckAttributeFactory.getCheckList());
}
}
}
Aggregations