use of com.google.spanner.admin.database.v1.Database in project java-docs-samples by GoogleCloudPlatform.
the class App method create.
static void create(DatabaseAdminClient dbAdminClient, DatabaseId db) {
OperationFuture<Database, CreateDatabaseMetadata> op = dbAdminClient.createDatabase(db.getInstanceId().getInstance(), db.getDatabase(), Arrays.asList("CREATE TABLE Players(\n" + " PlayerId INT64 NOT NULL,\n" + " PlayerName STRING(2048) NOT NULL\n" + ") PRIMARY KEY(PlayerId)", "CREATE TABLE Scores(\n" + " PlayerId INT64 NOT NULL,\n" + " Score INT64 NOT NULL,\n" + " Timestamp TIMESTAMP NOT NULL\n" + " OPTIONS(allow_commit_timestamp=true)\n" + ") PRIMARY KEY(PlayerId, Timestamp),\n" + "INTERLEAVE IN PARENT Players ON DELETE NO ACTION"));
try {
// Initiate the request which returns an OperationFuture.
Database dbOperation = op.get();
System.out.println("Created database [" + dbOperation.getId() + "]");
} catch (ExecutionException e) {
// If the operation failed during execution, expose the cause.
throw (SpannerException) e.getCause();
} catch (InterruptedException e) {
// and the thread is interrupted, either before or during the activity.
throw SpannerExceptionFactory.propagateInterrupt(e);
}
}
use of com.google.spanner.admin.database.v1.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());
}
use of com.google.spanner.admin.database.v1.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());
}
use of com.google.spanner.admin.database.v1.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);
}
use of com.google.spanner.admin.database.v1.Database in project molgenis-emx2 by molgenis.
the class OIDCController method handleLoginCallback.
@SuppressWarnings("unchecked")
public Object handleLoginCallback(Request request, Response response) {
final SessionStore<SparkWebContext> sessionStore = FindBest.sessionStore(null, securityConfig, JEESessionStore.INSTANCE);
final SparkWebContext context = new SparkWebContext(request, response, sessionStore);
final HttpActionAdapter<Object, SparkWebContext> adapter = FindBest.httpActionAdapter(null, securityConfig, SparkHttpActionAdapter.INSTANCE);
final CallbackLogic<Object, SparkWebContext> callbackLogic = FindBest.callbackLogic(null, securityConfig, DefaultCallbackLogic.INSTANCE);
callbackLogic.perform(context, securityConfig, adapter, null, false, true, true, OIDC_CLIENT_NAME);
final ProfileManager<OidcProfile> manager = new ProfileManager<>(context);
Optional<OidcProfile> oidcProfile = manager.get(true);
if (oidcProfile.isPresent()) {
String user = oidcProfile.get().getEmail();
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);
} else {
logger.error("OIDC sign in failed, no profile found");
response.status(404);
}
response.redirect("/");
return response;
}
Aggregations