use of com.sldeditor.common.data.DatabaseConnection in project sldeditor by robward-scisys.
the class DatabaseConnectionManager method getConnectionList.
/**
* Gets the connection list.
*
* @return the connection list
*/
@Override
public List<DatabaseConnection> getConnectionList() {
List<DatabaseConnection> connectionList = new ArrayList<DatabaseConnection>();
List<String> valueList = PropertyManagerFactory.getInstance().getMultipleValues(DATABASE_CONNECTION_FIELD);
for (String connectionString : valueList) {
DatabaseConnection connection = DatabaseConnection.decodeString(connectionString);
if (connection != null) {
connectionList.add(connection);
}
}
return connectionList;
}
use of com.sldeditor.common.data.DatabaseConnection 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.common.data.DatabaseConnection 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.common.data.DatabaseConnection in project sldeditor by robward-scisys.
the class DatabaseInput method populate.
/*
* (non-Javadoc)
*
* @see com.sldeditor.common.filesystem.FileSystemInterface#populate(com.sldeditor.datasource.extension.filesystem.node.FSTree,
* javax.swing.tree.DefaultTreeModel, javax.swing.tree.DefaultMutableTreeNode)
*/
@Override
public void populate(FSTree tree, DefaultTreeModel model, DefaultMutableTreeNode rootNode) {
progress.setTreeModel(tree, model);
if (rootNode != null) {
for (String key : getRootDatabaseNodes().keySet()) {
DatabaseOverallNode node = getRootDatabaseNodes().get(key);
rootNode.add(node);
}
}
for (DatabaseConnection connection : DatabaseConnectionManager.getInstance().getConnectionMap().keySet()) {
addConnectionNode(connection);
}
}
use of com.sldeditor.common.data.DatabaseConnection in project sldeditor by robward-scisys.
the class DatabaseConnectionTool method updateButtonState.
/**
* Update button state.
*/
private void updateButtonState() {
int connected = 0;
int disconnected = 0;
if (databaseConnectState != null) {
for (DatabaseConnection connection : connectionList) {
if (databaseConnectState.isConnected(connection)) {
connected++;
} else {
disconnected++;
}
}
}
boolean connectedEnabled = false;
boolean disconnectedEnabled = false;
if ((connected == 0) || (disconnected == 0)) {
if (connected > 0) {
disconnectedEnabled = true;
} else if (disconnected > 0) {
connectedEnabled = true;
}
}
connectButton.setEnabled(connectedEnabled);
disconnectButton.setEnabled(disconnectedEnabled);
}
Aggregations