use of com.sldeditor.common.data.DatabaseConnection in project sldeditor by robward-scisys.
the class DatabaseConnectionFactory method createGeoPackage.
/**
* Creates a new DatabaseConnection object for a GeoPackage.
*
* @return the database connection
*/
public static DatabaseConnection createGeoPackage() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
FileNameExtensionFilter filter = new FileNameExtensionFilter(Localisation.getString(DatabaseConnector.class, "DatabaseConnectorGeoPkg.fileExtension") + " (*." + GEOPACKAGE_FILE_EXTENSION + ")", GEOPACKAGE_FILE_EXTENSION);
list.add(new DatabaseConnectionField(GeoPkgDataStoreFactory.DATABASE, filter));
list.add(new DatabaseConnectionField(GeoPkgDataStoreFactory.USER));
GeoPkgDataStoreFactory factory = new GeoPkgDataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(GeoPkgDataStoreFactory.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;
}
use of com.sldeditor.common.data.DatabaseConnection in project sldeditor by robward-scisys.
the class DatabaseConnectionFactory method createSQLServer.
/**
* Creates a new DatabaseConnection object for SQL Server.
*
* @return the database connection
*/
public static DatabaseConnection createSQLServer() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
list.add(new DatabaseConnectionField(JTDSSqlServerDataStoreFactory.HOST));
list.add(new DatabaseConnectionField(JTDSSqlServerDataStoreFactory.PORT));
list.add(new DatabaseConnectionField(JTDSSqlServerDataStoreFactory.INSTANCE));
list.add(new DatabaseConnectionField(JTDSSqlServerDataStoreFactory.SCHEMA));
list.add(new DatabaseConnectionField(JTDSSqlServerDataStoreFactory.DATABASE));
list.add(new DatabaseConnectionField(JTDSSqlServerDataStoreFactory.USER));
list.add(new DatabaseConnectionField(JTDSSqlServerDataStoreFactory.PASSWD));
list.add(new DatabaseConnectionField(JTDSSqlServerDataStoreFactory.GEOMETRY_METADATA_TABLE));
JDTSSQLServerJNDIDataStoreFactory factory = new JDTSSQLServerJNDIDataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(JTDSSqlServerDataStoreFactory.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(JTDSSqlServerDataStoreFactory.INSTANCE.key), properties.get(JTDSSqlServerDataStoreFactory.DATABASE.key), properties.get(JTDSSqlServerDataStoreFactory.HOST.key), properties.get(JTDSSqlServerDataStoreFactory.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 createPostgres.
/**
* Creates a new DatabaseConnection object for Postgres.
*
* @return the database connection
*/
public static DatabaseConnection createPostgres() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.HOST));
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.PORT));
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.DATABASE));
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.SCHEMA));
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.USER));
list.add(new DatabaseConnectionField(PostgisNGDataStoreFactory.PASSWD));
PostgisNGDataStoreFactory factory = new PostgisNGDataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(PostgisNGDataStoreFactory.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(PostgisNGDataStoreFactory.SCHEMA.key), properties.get(PostgisNGDataStoreFactory.DATABASE.key), properties.get(PostgisNGDataStoreFactory.HOST.key), properties.get(PostgisNGDataStoreFactory.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 getConnection.
/**
* Gets the database connection.
*
* @param filename the filename
* @return the new connection
*/
public static DatabaseConnection getConnection(String filename) {
List<FileHandlerInterface> list = getFileHandlers();
if (filename != null) {
for (FileHandlerInterface handler : list) {
for (String fileExtension : handler.getFileExtensionList()) {
if (filename.endsWith(fileExtension)) {
String dbConnectionType = fileHandlerMap.get(handler);
DatabaseConnection dbConnection = createDefault(dbConnectionType);
Map<String, String> connectionDataMap = new HashMap<String, String>();
connectionDataMap.put(JDBCDataStoreFactory.DATABASE.key, filename);
dbConnection.setConnectionDataMap(connectionDataMap);
return dbConnection;
}
}
}
}
return null;
}
use of com.sldeditor.common.data.DatabaseConnection in project sldeditor by robward-scisys.
the class DatabaseConnectionFactory method createTeradata.
/**
* Creates a new DatabaseConnection object for Teradata.
*
* @return the database connection
*/
public static DatabaseConnection createTeradata() {
List<DatabaseConnectionField> list = new ArrayList<DatabaseConnectionField>();
list.add(new DatabaseConnectionField(TeradataDataStoreFactory.HOST));
list.add(new DatabaseConnectionField(TeradataDataStoreFactory.PORT));
list.add(new DatabaseConnectionField(TeradataDataStoreFactory.DATABASE));
list.add(new DatabaseConnectionField(TeradataDataStoreFactory.USER));
list.add(new DatabaseConnectionField(TeradataDataStoreFactory.SCHEMA));
list.add(new DatabaseConnectionField(TeradataDataStoreFactory.PASSWD));
TeradataDataStoreFactory factory = new TeradataDataStoreFactory();
DatabaseConnection databaseConnection = new DatabaseConnection(TeradataDataStoreFactory.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(TeradataDataStoreFactory.SCHEMA.key), properties.get(TeradataDataStoreFactory.DATABASE.key), properties.get(TeradataDataStoreFactory.HOST.key), properties.get(TeradataDataStoreFactory.PORT.key));
for (int i = 0; i < noOfTimesDuplicated; i++) {
connectionName = duplicatePrefix + connectionName;
}
return connectionName;
}
});
return databaseConnection;
}
Aggregations