use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.
the class TestReverse method testSQLServer.
@Test
public void testSQLServer() {
DataSource dataSource = new DataSource("Northwind", "dbo");
dataSource.setJdbcUrl("jdbc:sqlserver://localhost:1433;databaseName=Northwind");
dataSource.setJdbcUsername("testUser");
dataSource.setJdbcPassword("test");
dataSource.setVendor("SQLServer-2008");
DataBase database = DatabaseReverser.reverse(dataSource, new MultiDataBaseQueries(), null);
DataBase databaseRef = loadModel("resources/sqlserver/outputRef.database", "pathmap://NativeDBTypes/SQLServer-2008");
checkEquality(database, databaseRef);
}
use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.
the class TestReverse method loadModel.
private static DataBase loadModel(String databaseTestPluginRelativePath, String typesLibraryPathmapUri) {
URI uri = URI.createFileURI(databaseTestPluginRelativePath);
DatabaseResourceFactoryImpl databaseResourceFactory = new DatabaseResourceFactoryImpl();
Resource resourceDatabase = databaseResourceFactory.createResource(uri);
TypesLibraryResourceFactoryImpl typesLibraryresourceFactory = new TypesLibraryResourceFactoryImpl();
Resource typeResource = typesLibraryresourceFactory.createResource(URI.createURI(typesLibraryPathmapUri));
ResourceSet rs = new ResourceSetImpl();
rs.getResources().add(resourceDatabase);
rs.getResources().add(typeResource);
try {
Map options = rs.getLoadOptions();
options.put(DatabasePackage.eINSTANCE.getNsURI(), DatabasePackage.eINSTANCE);
options.put(TypesLibraryPackage.eINSTANCE.getNsURI(), TypesLibraryPackage.eINSTANCE);
resourceDatabase.load(options);
} catch (Exception ex) {
ex.printStackTrace();
}
return (DataBase) resourceDatabase.getContents().get(0);
}
use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.
the class TestReverse method testH2Embedded.
@Test
public void testH2Embedded() {
String databaseLocation = getH2DatabaseLocation(this.getClass(), "input");
DataSource dataSource = new DataSource("appli1", "PUBLIC");
dataSource.setJdbcUrl("jdbc:h2:" + databaseLocation);
dataSource.setJdbcUsername("sa");
dataSource.setVendor("H2-1.3");
DataBase database = DatabaseReverser.reverse(dataSource, new MultiDataBaseQueries(), null);
DataBase databaseRef = loadModel("resources/h2/outputRef.database", "pathmap://NativeDBTypes/H2-1.3");
checkEquality(database, databaseRef);
}
use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.
the class AbstractDataBaseBuilder method initialize.
private void initialize(DataSource source, ProgressListener progressListener, Queries queries) throws SQLException {
connection = null;
try {
connection = source.getConnection();
} catch (DataSourceException e) {
throw new SQLException("Unable to connect to database", e.getCause());
}
if (connection != null) {
try {
this.metaData = connection.getMetaData();
} catch (SQLException e) {
JdbcUtils.closeConnection(connection);
throw e;
}
}
this.progressListener = progressListener;
if (this.progressListener == null) {
this.progressListener = new ProgressListener() {
@Override
public void start(int numberOfSteps) {
}
@Override
public void progressTo(int step, String message) {
}
@Override
public void end(String message) {
}
};
}
this.queries = queries;
dataBase = buildDataBase(source.getDatabaseName());
queries.registerDatabase(dataBase);
tableContainer = dataBase;
if (isSet(source.getSchemaName())) {
tableContainer = buildSchema(source.getSchemaName(), (DataBase) tableContainer);
}
setUsedLibraries();
}
use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.
the class AbstractTest method loadModel.
/**
* Returns the DataBase in the specified resource's file name.
*
* @param fileName
* @return
*/
public DataBase loadModel(String fileName) {
Resource resource = resourceSet.getResource(URI.createURI(fileName), true);
int i = 0;
int s = resource.getContents().size();
while (i < s && !(resource.getContents().get(i) instanceof DataBase)) {
i++;
}
if (i < s) {
return (DataBase) resource.getContents().get(i);
} else {
return null;
}
}
Aggregations