use of eu.etaxonomy.cdm.database.ICdmDataSource in project cdmlib by cybertaxonomy.
the class DatabaseMappingTest method testGetDatabase.
// ******************* TESTS *****************************/
@Test
@Ignore
public void testGetDatabase() {
ICdmDataSource datasource = mapping.getDatabase();
Assert.assertNotNull("Datasource should not be null", datasource);
String sql = "INSERT INTO " + DatabaseMapping.TABLE_IMPORT_MAPPING + "( task_id, source_namespace, source_id, destination_namespace, destination_id) ";
sql += "VALUES ( 'mappingID', 'ns1', 'source1', 'destNs', 'dest1')";
try {
datasource.executeUpdate(sql);
} catch (SQLException e) {
// maybe it just only exists
logger.warn("Error occurred");
}
}
use of eu.etaxonomy.cdm.database.ICdmDataSource in project cdmlib by cybertaxonomy.
the class DatabaseServiceHibernateImpl method connectToDatabase.
@Override
public boolean connectToDatabase(DatabaseTypeEnum databaseTypeEnum, String server, String database, String username, String password, int port, String filePath, H2Mode mode) throws TermNotFoundException {
ICdmDataSource dataSource = CdmDataSource.NewInstance(databaseTypeEnum, server, database, port, username, password);
CdmPersistentDataSource tmpDataSource = saveDataSource(TMP_DATASOURCE, dataSource);
boolean result = connectToDatasource(tmpDataSource);
CdmPersistentSourceUtils.delete(tmpDataSource);
return result;
}
use of eu.etaxonomy.cdm.database.ICdmDataSource in project cdmlib by cybertaxonomy.
the class TestScriptRemote method testNewConfigControler.
private void testNewConfigControler() {
DbSchemaValidation schema = DbSchemaValidation.VALIDATE;
String server;
String database;
String username;
ICdmDataSource dataSource;
// List<CdmPersistentDataSource> lsDataSources = CdmPersistentDataSource.getAllDataSources();
// System.out.println(lsDataSources);
// dataSource = lsDataSources.get(1);
// DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
// server = "localhost";
// database = "cdm_bupleurum";
// // database = "cdm_production_edaphobase";
// username = "edit";
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
// server = "160.45.63.171";
// database = "cdm_production_flora_malesiana_prospective";
// username = "edit";
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
server = "test.e-taxonomy.eu";
database = "cdm_rem_conf_am";
username = "edit";
dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
// String server = "localhost";
// String database = "testCDM";
// String username = "postgres";
// dataSource = CdmDataSource.NewInstance(DatabaseTypeEnum.PostgreSQL, server, database, DatabaseTypeEnum.PostgreSQL.getDefaultPort(), username, AccountStore.readOrStorePassword(server, database, username, null));
// //SQLServer
// server = "BGBM-PESISQL";
// database = "cdm36";
// int port = 1433;
// username = "cdmupdater";
// dataSource = CdmDataSource.NewSqlServer2012Instance(server, database, port, username, AccountStore.readOrStorePassword(server, database, username, null));
//
// //H2
// String path = "C:\\Users\\a.mueller\\.cdmLibrary\\writableResources\\h2\\LocalH2";
// // String path = "C:\\Users\\pesiimport\\.cdmLibrary\\writableResources\\h2\\LocalH2";
// // String path = "C:\\Users\\a.mueller\\eclipse\\svn\\cdmlib-trunk\\cdmlib-remote-webapp\\src\\test\\resources\\h2";
// username = "sa";
// dataSource = CdmDataSource.NewH2EmbeddedInstance("cdm", username, "", path);
// dataSource = CdmDataSource.NewH2EmbeddedInstance(database, username, "sa");
// server = "160.45.63.201";
// database = "cdm_integration_cichorieae";
// username = "edit";
// dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
CdmApplicationController appCtr = CdmRemoteApplicationController.NewRemoteInstance(dataSource, schema);
try {
doTemporary(appCtr);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// List<UuidAndTitleCache<TaxonBase>> list = appCtr.getTaxonService().getUuidAndTitleCache(null, 10, "Abies alba%");
// System.out.println(list);
// appCtr.getOccurrenceService().findRootUnitDTOs(UUID.fromString("2debf5ee-cb57-40bc-af89-173d1d17cefe"));
// aggregateDDS(appCtr);
// aggregateDistribution(appCtr);
appCtr.close();
System.exit(0);
}
use of eu.etaxonomy.cdm.database.ICdmDataSource in project cdmlib by cybertaxonomy.
the class Cdm2CdmVocabularyImportTest method setUpClass.
@BeforeClass
@Ignore
public static void setUpClass() throws Exception {
// this.startH2Server();
boolean omitTermLoading = true;
// TODO remove user directory
ICdmDataSource dataSource = CdmDataSource.NewH2EmbeddedInstance("testVoc", "sa", "", "C:\\Users\\a.mueller\\tmp\\testVoc");
// int a = dataSource.executeUpdate("CREATE TABLE HIBERNATE_SEQUENCES ("
// + " sequence_name VARCHAR(255), next_val BIGINT )");
// try {
// ResultSet rs = dataSource.executeQuery("SELECT * FROM INFORMATION_SCHEMA.TABLES");
// while(rs.next()){
// for (int i = 1; i<=12; i++){
// System.out.print(";"+rs.getObject(i));
// }
// System.out.println();
// }
// dataSource.executeQuery("select tbl.next_val from hibernate_sequences tbl where tbl.sequence_name='a'");
otherRepository = CdmApplicationController.NewInstance(dataSource, DbSchemaValidation.CREATE, omitTermLoading);
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
System.out.println("started");
TermVocabulary<DefinedTerm> voc = createTestVocabulary(otherRepository);
createTestGraph(otherRepository, voc);
}
use of eu.etaxonomy.cdm.database.ICdmDataSource in project cdmlib by cybertaxonomy.
the class SDDImportExportTest method customDataSource.
/**
* @param loadedDataSource
* @return
*/
private ICdmDataSource customDataSource() {
CdmPersistentDataSource loadedDataSource = null;
// ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance("192.168.2.10", "cdm_test_niels2", 3306, "edit", password, code);
String dataSourceName = "cdm_test2";
String password = CdmUtils.readInputLine("Password: ");
ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance("127.0.0.1", "cdm_test2", 3306, "ljm", password);
// ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance("160.45.63.201", "cdm_test", 3306, "edit", password);
boolean connectionAvailable;
try {
connectionAvailable = dataSource.testConnection();
logger.debug("Is connection avaiable " + connectionAvailable);
Assert.assertTrue("Testdatabase is not available", connectionAvailable);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
} catch (SQLException e1) {
e1.printStackTrace();
}
CdmPersistentDataSource.save(dataSourceName, dataSource);
try {
loadedDataSource = CdmPersistentDataSource.NewInstance(dataSourceName);
// CdmApplicationController.NewInstance(loadedDataSource, DbSchemaValidation.CREATE);
// NomenclaturalCode loadedCode = loadedDataSource.getNomenclaturalCode();
//
// Assert.assertEquals(NomenclaturalCode.ICNAFP, loadedCode);
} catch (DataSourceNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// return loadedDataSource;
return dataSource;
}
Aggregations