Search in sources :

Example 1 with MultiDataBaseQueries

use of org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries in project InformationSystem by ObeoNetwork.

the class DatabaseImportHelper method importDatabaseIntoModel.

public static boolean importDatabaseIntoModel(DatabaseInfos databaseInfos, String modelFilename, Collection<IFile> referencedFiles) {
    DataSource dataSource = databaseInfos.getDataSource();
    // Override this resolver to resolve external dependencies (i.e.: tables store in another schema)
    MultiDataBaseQueries queries = new MultiDataBaseQueries();
    for (IFile referencedFile : referencedFiles) {
        addFileToResolver(queries, referencedFile);
    }
    ImportRunnable runnable = new ImportRunnable(dataSource, modelFilename, queries);
    try {
        PlatformUI.getWorkbench().getProgressService().run(true, false, runnable);
    } catch (Exception e) {
        Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error while importing database", e));
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error occured while importing database", "An error occured while importing the database. See Error Log view for more details.");
    }
    return runnable.getResult();
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) MultiDataBaseQueries(org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries) DataSource(org.obeonetwork.dsl.database.reverse.source.DataSource)

Example 2 with MultiDataBaseQueries

use of org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries in project InformationSystem by ObeoNetwork.

the class TestReverse method testMySQL.

@Test
public void testMySQL() {
    DataSource dataSource = new DataSource("northwind", null);
    dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/northwind");
    dataSource.setJdbcUsername("root");
    dataSource.setJdbcPassword(null);
    dataSource.setVendor("MySQL-5");
    DataBase database = DatabaseReverser.reverse(dataSource, new MultiDataBaseQueries(), null);
    DataBase databaseRef = loadModel("resources/mysql/outputRef.database", "pathmap://NativeDBTypes/MySQL-5");
    checkEquality(database, databaseRef);
}
Also used : MultiDataBaseQueries(org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries) DataSource(org.obeonetwork.dsl.database.reverse.source.DataSource) DataBase(org.obeonetwork.dsl.database.DataBase) Test(org.junit.Test)

Example 3 with MultiDataBaseQueries

use of org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries 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);
}
Also used : MultiDataBaseQueries(org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries) DataSource(org.obeonetwork.dsl.database.reverse.source.DataSource) DataBase(org.obeonetwork.dsl.database.DataBase) Test(org.junit.Test)

Example 4 with MultiDataBaseQueries

use of org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries 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);
}
Also used : MultiDataBaseQueries(org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries) DataSource(org.obeonetwork.dsl.database.reverse.source.DataSource) DataBase(org.obeonetwork.dsl.database.DataBase) Test(org.junit.Test)

Example 5 with MultiDataBaseQueries

use of org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries in project InformationSystem by ObeoNetwork.

the class TestReverse method testOracle.

@Test
public void testOracle() {
    DataSource dataSource = new DataSource("XE", "NORTHWIND");
    dataSource.setJdbcUrl("jdbc:oracle:thin:northwind/northwind@//localhost:1521/XE");
    dataSource.setJdbcUsername("northwind");
    dataSource.setJdbcPassword("northwind");
    dataSource.setVendor("Oracle-11g");
    DataBase database = DatabaseReverser.reverse(dataSource, new MultiDataBaseQueries(), null);
    DataBase databaseRef = loadModel("resources/oracle/outputRef.database", "pathmap://NativeDBTypes/Oracle-11g");
    checkEquality(database, databaseRef);
}
Also used : MultiDataBaseQueries(org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries) DataSource(org.obeonetwork.dsl.database.reverse.source.DataSource) DataBase(org.obeonetwork.dsl.database.DataBase) Test(org.junit.Test)

Aggregations

DataSource (org.obeonetwork.dsl.database.reverse.source.DataSource)7 MultiDataBaseQueries (org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries)7 Test (org.junit.Test)6 DataBase (org.obeonetwork.dsl.database.DataBase)6 IFile (org.eclipse.core.resources.IFile)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1