use of com.sldeditor.common.data.DatabaseConnection in project sldeditor by robward-scisys.
the class DatabaseConnectionTool method connect.
/**
* Connect.
*/
protected void connect() {
if (databaseConnectState != null) {
connectButton.setEnabled(false);
disconnectButton.setEnabled(false);
databaseConnectState.connect(connectionList);
for (DatabaseConnection connection : connectionList) {
if (!databaseConnectState.isConnected(connection)) {
connectButton.setEnabled(true);
}
}
}
}
use of com.sldeditor.common.data.DatabaseConnection in project sldeditor by robward-scisys.
the class DatabaseConnectionTool method setSelectedItems.
/*
* (non-Javadoc)
*
* @see com.sldeditor.tool.ToolInterface#setSelectedItems(java.util.List, java.util.List)
*/
@Override
public void setSelectedItems(List<NodeInterface> nodeTypeList, List<SLDDataInterface> sldDataList) {
connectionList.clear();
if (nodeTypeList != null) {
for (NodeInterface node : nodeTypeList) {
if (node instanceof DatabaseNode) {
DatabaseNode databaseNode = (DatabaseNode) node;
connectionList.add(databaseNode.getConnection());
} else if (node instanceof FileTreeNode) {
FileTreeNode fileNode = (FileTreeNode) node;
if (fileNode.getFileCategory() == FileTreeNodeTypeEnum.DATABASE) {
DatabaseConnection databaseConnection = DatabaseConnectionFactory.getConnection(fileNode.getFile().getAbsolutePath());
connectionList.add(databaseConnection);
}
}
}
}
updateButtonState();
}
use of com.sldeditor.common.data.DatabaseConnection in project sldeditor by robward-scisys.
the class DatabaseConnectionFactory method createDB2.
/**
* Creates a new DatabaseConnection object for DB2.
*
* @return the database connection
*/
public static DatabaseConnection createDB2() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
list.add(new DatabaseConnectionField(DB2NGDataStoreFactory.HOST));
list.add(new DatabaseConnectionField(DB2NGDataStoreFactory.PORT));
Param TABSCHEMA = new Param("tabschema", String.class, "Schema", false);
list.add(new DatabaseConnectionField(TABSCHEMA));
list.add(new DatabaseConnectionField(DB2NGDataStoreFactory.DATABASE));
list.add(new DatabaseConnectionField(DB2NGDataStoreFactory.USER));
list.add(new DatabaseConnectionField(DB2NGDataStoreFactory.PASSWD));
DB2NGDataStoreFactory factory = new DB2NGDataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(DB2NGDataStoreFactory.DBTYPE, factory.getDisplayName(), true, list, new DatabaseConnectionName() {
@Override
public String getConnectionName(String duplicatePrefix, int noOfTimesDuplicated, Map<String, String> properties) {
String connectionName = String.format("%s/%s@%s:%s", properties.get("tabschema"), properties.get(JDBCDataStoreFactory.DATABASE.key), properties.get(JDBCDataStoreFactory.HOST.key), properties.get(JDBCDataStoreFactory.PORT.key));
for (int i = 0; i < noOfTimesDuplicated; i++) {
connectionName = duplicatePrefix + connectionName;
}
return connectionName;
}
});
return databaseConnection;
}
use of com.sldeditor.common.data.DatabaseConnection in project sldeditor by robward-scisys.
the class DatabaseConnectionFactory method createMySQL.
/**
* Creates a new DatabaseConnection object for MySQL.
*
* @return the database connection
*/
public static DatabaseConnection createMySQL() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
list.add(new DatabaseConnectionField(MySQLDataStoreFactory.HOST));
list.add(new DatabaseConnectionField(MySQLDataStoreFactory.PORT));
list.add(new DatabaseConnectionField(MySQLDataStoreFactory.DATABASE));
list.add(new DatabaseConnectionField(MySQLDataStoreFactory.STORAGE_ENGINE));
list.add(new DatabaseConnectionField(MySQLDataStoreFactory.USER));
list.add(new DatabaseConnectionField(MySQLDataStoreFactory.PASSWD));
MySQLDataStoreFactory factory = new MySQLDataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(MySQLDataStoreFactory.DBTYPE, factory.getDisplayName(), true, list, new DatabaseConnectionName() {
@Override
public String getConnectionName(String duplicatePrefix, int noOfTimesDuplicated, Map<String, String> properties) {
String connectionName = String.format("%s@%s:%s", properties.get(MySQLDataStoreFactory.DATABASE.key), properties.get(MySQLDataStoreFactory.HOST.key), properties.get(MySQLDataStoreFactory.PORT.key));
for (int i = 0; i < noOfTimesDuplicated; i++) {
connectionName = duplicatePrefix + connectionName;
}
return connectionName;
}
});
return databaseConnection;
}
use of com.sldeditor.common.data.DatabaseConnection in project sldeditor by robward-scisys.
the class DatabaseConnectionFactory method createH2.
/**
* Creates a new DatabaseConnection object for H2.
*
* @return the database connection
*/
public static DatabaseConnection createH2() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
list.add(new DatabaseConnectionField(H2DataStoreFactory.DATABASE));
list.add(new DatabaseConnectionField(H2DataStoreFactory.USER));
H2DataStoreFactory factory = new H2DataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(H2DataStoreFactory.DBTYPE, factory.getDisplayName(), false, list, new DatabaseConnectionName() {
@Override
public String getConnectionName(String duplicatePrefix, int noOfTimesDuplicated, Map<String, String> properties) {
String connectionName = Localisation.getString(DatabaseConnectionFactory.class, "common.notSet");
String databaseName = properties.get(JDBCDataStoreFactory.DATABASE.key);
if (databaseName != null) {
File f = new File(databaseName);
if (f.isFile()) {
connectionName = f.getName();
}
}
for (int i = 0; i < noOfTimesDuplicated; i++) {
connectionName = duplicatePrefix + connectionName;
}
return connectionName;
}
});
return databaseConnection;
}
Aggregations