Search in sources :

Example 16 with org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database

use of org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database in project molgenis-emx2 by molgenis.

the class TestSettingsAndMembersLoading method testExcelTypesCast.

@Test
public void testExcelTypesCast() {
    Database database = TestDatabaseFactory.getTestDatabase();
    Schema schema = database.dropCreateSchema(TestSettingsAndMembersLoading.class.getSimpleName());
    ClassLoader classLoader = getClass().getClassLoader();
    Path path = new File(classLoader.getResource("settings_and_members.xlsx").getFile()).toPath();
    new ImportExcelTask(path, schema, true).run();
    assertEquals("key1", schema.getTable("table1").getMetadata().getSettings().get(0).key());
    assertEquals("value1", schema.getTable("table1").getMetadata().getSettings().get(0).value());
    assertEquals("key2", schema.getMetadata().getSettings().get(0).key());
    assertEquals("value2", schema.getMetadata().getSettings().get(0).value());
    assertEquals(1, schema.getMembers().size());
    assertEquals("anonymous", schema.getMembers().get(0).getUser());
    assertEquals("Viewer", schema.getMembers().get(0).getRole());
    database.dropSchema(schema.getName());
}
Also used : Path(java.nio.file.Path) Schema(org.molgenis.emx2.Schema) Database(org.molgenis.emx2.Database) File(java.io.File) Test(org.junit.Test)

Example 17 with org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database

use of org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database in project molgenis-emx2 by molgenis.

the class MolgenisSessionManager method createSessionListener.

/**
 * takes care of creating and destroying session attributes when Jetty creates/destroys sessions
 */
private EventListener createSessionListener() {
    MolgenisSessionManager _this = this;
    return new HttpSessionListener() {

        public void sessionCreated(HttpSessionEvent httpSessionEvent) {
            logger.info("Initializing session");
            // create private database wrapper to session
            Database database = new SqlDatabase(false);
            // set default use to "anonymous"
            database.setActiveUser("anonymous");
            // create session and add to sessions lists so we can also access all active
            // sessions
            MolgenisSession molgenisSession = new MolgenisSession(database);
            sessions.put(httpSessionEvent.getSession().getId(), molgenisSession);
            logger.info("session created: " + httpSessionEvent.getSession().getId());
            // create listener
            database.setListener(new MolgenisSessionManagerDatabaseListener(_this, molgenisSession));
        }

        public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
            // remove from session pool
            sessions.remove(httpSessionEvent.getSession().getId());
            logger.info("session destroyed: " + httpSessionEvent.getSession().getId());
        }
    };
}
Also used : HttpSessionListener(javax.servlet.http.HttpSessionListener) HttpSessionEvent(javax.servlet.http.HttpSessionEvent) Database(org.molgenis.emx2.Database) SqlDatabase(org.molgenis.emx2.sql.SqlDatabase) SqlDatabase(org.molgenis.emx2.sql.SqlDatabase)

Example 18 with org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database

use of org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database in project molgenis-emx2 by molgenis.

the class InitTestDatabaseAndRunNonParallelTests method createDatabase.

@BeforeClass
public static void createDatabase() {
    // we want this run only once and NOT parallel for total test suite
    // AND we want run all other tests in parallel
    // so tests are in molgenis-emx2-sql-it ('integration test')
    // and 'init' only happence once, here
    Database db = new SqlDatabase(true);
    assertTrue(db.getDatabaseVersion() > 0);
}
Also used : Database(org.molgenis.emx2.Database) BeforeClass(org.junit.BeforeClass)

Example 19 with org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database

use of org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database in project molgenis-emx2 by molgenis.

the class Benchmark method testCopyInAndOut.

public void testCopyInAndOut() {
    Database database = TestDatabaseFactory.getTestDatabase();
    Schema schema = database.dropCreateSchema(Benchmark.class.getSimpleName());
    int aSize = 50;
    int bSize = 100000;
    Table a = schema.create(table("TableA").add(column("ID").setPkey()));
    List<String> values = new ArrayList<>();
    Table b = schema.create(table("TableB").add(column("ID").setPkey()).add(column("ref").setType(REF_ARRAY).setRefTable("TableA")));
    // Table c =
    // schema.create(
    // table("TableC")
    // .add(column("ID").setPkey())
    // .add(column("ref").setType(MREF).setRefTable("TableA")));
    StopWatch.start("benchmark started");
    List<Row> aRows = new ArrayList<>();
    for (int i = 0; i < aSize; i++) {
        aRows.add(new Row().set("ID", "row" + i));
        values.add("row" + i);
    }
    StopWatch.start("benchmark1");
    a.insert(aRows);
    StopWatch.print("inserted primary", aSize);
    aRows.clear();
    List<Row> bRows = new ArrayList<>();
    for (int i = 0; i < bSize; i++) {
        bRows.add(new Row().set("ID", "row" + i).set("ref", values));
    }
    StopWatch.start("benchmark2 started");
    b.insert(bRows);
    StopWatch.print("inserted ref_array", bSize);
    bRows.clear();
// List<Row> cRows = new ArrayList<>();
// for (int i = 0; i < bSize; i++) {
// cRows.add(new Row().set("ID", "row" + i).set("ref", values));
// }
// StopWatch.start("benchmark3 started");
// c.insert(cRows);
// StopWatch.print("inserted mref", bSize);
// cRows.clear();
// StopWatch.print("inserted mref", bSize);
// ref_array
}
Also used : Table(org.molgenis.emx2.Table) Schema(org.molgenis.emx2.Schema) Database(org.molgenis.emx2.Database) ArrayList(java.util.ArrayList) Row(org.molgenis.emx2.Row)

Example 20 with org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database

use of org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database in project molgenis-emx2 by molgenis.

the class TestEmx2Roles method setup.

@BeforeClass
public static void setup() {
    Database database = TestDatabaseFactory.getTestDatabase();
    schema = database.dropCreateSchema(TestEmx2Roles.class.getSimpleName());
}
Also used : Database(org.molgenis.emx2.Database) BeforeClass(org.junit.BeforeClass)

Aggregations

Database (com.google.spanner.admin.database.v1.Database)21 Test (org.junit.Test)20 Database (org.molgenis.emx2.Database)14 ArrayList (java.util.ArrayList)11 AbstractMessage (com.google.protobuf.AbstractMessage)10 ByteString (com.google.protobuf.ByteString)8 Operation (com.google.longrunning.Operation)7 RestoreDatabaseRequest (com.google.spanner.admin.database.v1.RestoreDatabaseRequest)7 BeforeClass (org.junit.BeforeClass)6 Schema (org.molgenis.emx2.Schema)6 CreateDatabaseRequest (com.google.spanner.admin.database.v1.CreateDatabaseRequest)4 InstanceName (com.google.spanner.admin.database.v1.InstanceName)4 ListDatabasesPagedResponse (com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabasesPagedResponse)3 CreateDatabaseMetadata (com.google.spanner.admin.database.v1.CreateDatabaseMetadata)3 RestoreDatabaseMetadata (com.google.spanner.admin.database.v1.RestoreDatabaseMetadata)3 GeneratorExecutionException (org.jaxdb.ddlx.GeneratorExecutionException)3 BackupName (com.google.spanner.admin.database.v1.BackupName)2 DatabaseName (com.google.spanner.admin.database.v1.DatabaseName)2 GetDatabaseRequest (com.google.spanner.admin.database.v1.GetDatabaseRequest)2 org.jaxdb.jsql.data (org.jaxdb.jsql.data)2