Search in sources :

Example 21 with DataBase

use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.

the class DatabaseImportHelper method addFileToResolver.

private static void addFileToResolver(MultiDataBaseQueries queries, IFile referencedFile) {
    URI uri = URI.createPlatformResourceURI(referencedFile.getFullPath().toString(), true);
    ResourceSet set = new ResourceSetImpl();
    Resource resource = set.getResource(uri, true);
    for (EObject root : resource.getContents()) {
        if (root instanceof DataBase) {
            queries.registerDatabase((DataBase) root);
        }
    }
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) DataBase(org.obeonetwork.dsl.database.DataBase)

Example 22 with DataBase

use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.

the class GenerateSQLFromDatabaseHandler method copyDatabase.

private DataBase copyDatabase(DataBase database) {
    DataBase newDatabase = DatabaseFactory.eINSTANCE.createDataBase();
    newDatabase.setName(database.getName());
    for (Schema schema : database.getSchemas()) {
        newDatabase.getSchemas().add((Schema) copySchema(schema));
    }
    return newDatabase;
}
Also used : Schema(org.obeonetwork.dsl.database.Schema) DataBase(org.obeonetwork.dsl.database.DataBase)

Example 23 with DataBase

use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.

the class CreationUtils method createDatabase.

public static DataBase createDatabase(String name) {
    DataBase database = DatabaseFactory.eINSTANCE.createDataBase();
    database.setName(name);
    return database;
}
Also used : DataBase(org.obeonetwork.dsl.database.DataBase)

Example 24 with DataBase

use of org.obeonetwork.dsl.database.DataBase 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)

Example 25 with DataBase

use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.

the class TestReverse method testH2Server.

@Test
public void testH2Server() {
    String databaseLocation = getH2DatabaseLocation(this.getClass(), "input");
    DataSource dataSource = new DataSource("appli1", "PUBLIC");
    dataSource.setJdbcUrl("jdbc:h2:tcp://localhost/" + 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)

Aggregations

DataBase (org.obeonetwork.dsl.database.DataBase)26 Schema (org.obeonetwork.dsl.database.Schema)8 Resource (org.eclipse.emf.ecore.resource.Resource)6 Test (org.junit.Test)6 DataSource (org.obeonetwork.dsl.database.reverse.source.DataSource)6 MultiDataBaseQueries (org.obeonetwork.dsl.database.reverse.utils.MultiDataBaseQueries)6 EObject (org.eclipse.emf.ecore.EObject)5 URI (org.eclipse.emf.common.util.URI)3 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)3 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)3 TypesLibrary (org.obeonetwork.dsl.typeslibrary.TypesLibrary)3 ArrayList (java.util.ArrayList)2 IResource (org.eclipse.core.resources.IResource)2 Comparison (org.eclipse.emf.compare.Comparison)2 ISelection (org.eclipse.jface.viewers.ISelection)2 DAnalysisSessionEObject (org.eclipse.sirius.viewpoint.DAnalysisSessionEObject)2 AbstractTable (org.obeonetwork.dsl.database.AbstractTable)2 Table (org.obeonetwork.dsl.database.Table)2 File (java.io.File)1 IOException (java.io.IOException)1