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());
}
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());
}
};
}
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);
}
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
}
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());
}
Aggregations