Search in sources :

Example 26 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 OIDCController method handleLoginCallback.

public Object handleLoginCallback(Request request, Response response) {
    final SparkWebContext context = new SparkWebContext(request, response);
    final HttpActionAdapter adapter = FindBest.httpActionAdapter(null, securityConfig, SparkHttpActionAdapter.INSTANCE);
    final CallbackLogic callbackLogic = FindBest.callbackLogic(null, securityConfig, DefaultCallbackLogic.INSTANCE);
    callbackLogic.perform(context, sessionStore, securityConfig, adapter, null, false, OIDC_CLIENT_NAME);
    final ProfileManager manager = new ProfileManager(context, sessionStore);
    Optional<UserProfile> oidcProfile = manager.getProfile();
    if (oidcProfile.isEmpty()) {
        logger.error("OIDC sign in failed, no profile found");
        response.status(500);
        response.redirect("/");
        return response;
    }
    String user = oidcProfile.get().getAttribute("email").toString();
    if (user == null || user.isEmpty()) {
        logger.error("OIDC sign in failed, email claim is empty");
        response.status(500);
        response.redirect("/");
        return response;
    }
    Database database = sessionManager.getSession(request).getDatabase();
    if (!database.hasUser(user)) {
        logger.info("Add new OIDC user({}) to database", user);
        database.addUser(user);
    }
    database.setActiveUser(user);
    logger.info("OIDC sign in for user: {}", user);
    response.status(302);
    response.redirect("/");
    return response;
}
Also used : ProfileManager(org.pac4j.core.profile.ProfileManager) DefaultCallbackLogic(org.pac4j.core.engine.DefaultCallbackLogic) CallbackLogic(org.pac4j.core.engine.CallbackLogic) SparkWebContext(org.pac4j.sparkjava.SparkWebContext) UserProfile(org.pac4j.core.profile.UserProfile) Database(org.molgenis.emx2.Database) HttpActionAdapter(org.pac4j.core.http.adapter.HttpActionAdapter) SparkHttpActionAdapter(org.pac4j.sparkjava.SparkHttpActionAdapter)

Example 27 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 TestMgColumns method setUp.

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

Example 28 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 TestEmx2Settings method setup.

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

Example 29 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 TestGraphqlCrossSchemaRefs method setup.

@BeforeClass
public static void setup() {
    Database database = TestDatabaseFactory.getTestDatabase();
    schema1 = database.dropCreateSchema(schemaName1);
    schema2 = database.dropCreateSchema(schemaName2);
    CrossSchemaReferenceExample.create(schema1, schema2);
    graphql = new GraphqlApiFactory().createGraphqlForSchema(schema2);
}
Also used : Database(org.molgenis.emx2.Database) BeforeClass(org.junit.BeforeClass)

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

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

the class JSqlTest method loadEntitiesJaxSB.

@SuppressWarnings("unchecked")
static int loadEntitiesJaxSB(final Connection connection, final String name) throws ClassNotFoundException, IOException, SAXException, SQLException, TransformerException {
    Database.threadLocal((Class<? extends Schema>) Class.forName(Entities.class.getPackage().getName() + "." + name)).connectPrepared(() -> connection);
    final URL sqlx = ClassLoader.getSystemClassLoader().getResource("jaxdb/" + name + ".sqlx");
    assertNotNull(sqlx);
    final $Database database = ($Database) Bindings.parse(sqlx);
    final DDLx ddlx = new DDLx(ClassLoader.getSystemClassLoader().getResource(name + ".ddlx"));
    Schemas.truncate(connection, ddlx.getMergedSchema().getTable());
    final Batch batch = new Batch();
    final int expectedCount = DBVendor.valueOf(connection.getMetaData()) == DBVendor.ORACLE ? 0 : 1;
    for (final data.Table<?> table : Entities.toEntities(database)) batch.addStatement(INSERT(table), (s, e, c) -> assertEquals(expectedCount, c));
    return batch.execute();
}
Also used : Bindings(org.jaxsb.runtime.Bindings) Connection(java.sql.Connection) DDLx(org.jaxdb.ddlx.DDLx) InMemoryCompiler(org.libj.jci.InMemoryCompiler) TransformerException(javax.xml.transform.TransformerException) Files(java.nio.file.Files) URL(java.net.URL) org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database(org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database) IOException(java.io.IOException) File(java.io.File) SQLException(java.sql.SQLException) GeneratorExecutionException(org.jaxdb.ddlx.GeneratorExecutionException) DML(org.jaxdb.jsql.DML) Schemas(org.jaxdb.ddlx.Schemas) Generator(org.jaxdb.jsql.generator.Generator) SAXException(org.xml.sax.SAXException) DBVendor(org.jaxdb.vendor.DBVendor) Throwing(org.libj.util.function.Throwing) CompilationException(org.libj.jci.CompilationException) Assert(org.junit.Assert) Path(java.nio.file.Path) Assertions.assertNotNull(org.libj.lang.Assertions.assertNotNull) DDLx(org.jaxdb.ddlx.DDLx) org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database(org.jaxdb.www.sqlx_0_5.xLygluGCXAA.$Database) URL(java.net.URL)

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