use of eu.etaxonomy.cdm.database.update.SchemaUpdateResult in project cdmlib by cybertaxonomy.
the class TestModelUpdate method updateH2.
private void updateH2(String pathToProject) {
String pathInProject = "src\\test\\resources\\h2";
String path = pathToProject + pathInProject;
ICdmDataSource dataSource = CdmDataSource.NewH2EmbeddedInstance("cdmTest", "sa", "", path);
try {
CdmUpdater updater = new CdmUpdater();
SchemaUpdateResult result = updater.updateToCurrentVersion(dataSource, DefaultProgressMonitor.NewInstance());
System.out.println(result.createReport());
} catch (Exception e) {
e.printStackTrace();
}
// CdmPersistentDataSource.save(dataSource.getName(), dataSource);
CdmApplicationController appCtr;
appCtr = CdmApplicationController.NewInstance(dataSource, DbSchemaValidation.VALIDATE);
appCtr.close();
System.out.println("\nEnd Datasource");
}
use of eu.etaxonomy.cdm.database.update.SchemaUpdateResult in project cdmlib by cybertaxonomy.
the class TestModelUpdate method updateEdaphobasePostgres.
// enable only if needed
@SuppressWarnings("unused")
private void updateEdaphobasePostgres() {
String serverSql = "130.133.70.26";
String database = "cdm_edaphobase";
int port = 5433;
String username = "edaphobase";
String password = AccountStore.readOrStorePassword(database, serverSql, username, null);
ICdmDataSource dataSource = CdmDataSource.NewPostgreSQLInstance(serverSql, database, port, username, password);
try {
CdmUpdater updater = new CdmUpdater();
SchemaUpdateResult result = updater.updateToCurrentVersion(dataSource, DefaultProgressMonitor.NewInstance());
System.out.println(result.createReport());
} catch (Exception e) {
e.printStackTrace();
}
// CdmPersistentDataSource.save(dataSource.getName(), dataSource);
CdmApplicationController appCtr;
appCtr = CdmApplicationController.NewInstance(dataSource, DbSchemaValidation.VALIDATE);
appCtr.close();
System.out.println("\nEnd Datasource");
}
use of eu.etaxonomy.cdm.database.update.SchemaUpdateResult in project cdmlib by cybertaxonomy.
the class TestModelUpdate method testSelectedDb.
private void testSelectedDb() {
DbSchemaValidation schema = DbSchemaValidation.VALIDATE;
DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
String database = (schema == DbSchemaValidation.VALIDATE ? "cdm527" : "cdm529");
// database = "cdm_test1";
CdmDataSource dataSource = getDatasource(dbType, database);
try {
// int n = dataSource.executeUpdate("UPDATE CdmMetaData SET value = '3.1.0.0.201607300000' WHERE propertyname = 0 ");
CdmUpdater updater = new CdmUpdater();
if (schema == DbSchemaValidation.VALIDATE) {
SchemaUpdateResult result = updater.updateToCurrentVersion(dataSource, DefaultProgressMonitor.NewInstance());
String report = result.createReport().toString();
System.out.println(report);
}
} catch (Exception e) {
e.printStackTrace();
}
try {
CdmApplicationController appCtr = CdmApplicationController.NewInstance(dataSource, schema);
if (schema == DbSchemaValidation.CREATE) {
System.out.println("fillData");
appCtr.getCommonService().createFullSampleData();
appCtr.getNameService().list(null, null, null, null, null);
TransactionStatus tx = appCtr.startTransaction(false);
TemporalData td = (TemporalData) appCtr.getDescriptionElementService().find(UUID.fromString("9a1c91c0-fc58-4310-94cb-8c26115985d3"));
td.getFeature().setSupportsCategoricalData(true);
appCtr.getTermService().saveOrUpdate(td.getFeature());
System.out.println(td.getPeriod());
appCtr.commitTransaction(tx);
}
appCtr.close();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Ready");
}
Aggregations