use of org.molgenis.emx2.MolgenisException in project molgenis-emx2 by molgenis.
the class SqlTableMetadata method dropColumn.
@Override
public void dropColumn(String name) {
Column column = getColumn(name);
if (column == null) {
throw new MolgenisException("Drop column " + name + " failed: column does not exist");
}
// if changing 'ref' then check if not refBack exists
checkNotRefback(name, column);
long start = System.currentTimeMillis();
// return silently, idempotent
if (getColumn(name) == null)
return;
getDatabase().tx(db -> sync(dropColumnTransaction(db, getSchemaName(), getTableName(), name)));
log(start, "removed column '" + name + "' from ");
}
use of org.molgenis.emx2.MolgenisException in project molgenis-emx2 by molgenis.
the class Migrations method executeMigrationFile.
static void executeMigrationFile(Database db, String sqlFile, String message) {
try {
String sql = new String(Migrations.class.getResourceAsStream(sqlFile).readAllBytes());
((SqlDatabase) db).getJooq().execute(sql);
logger.debug(message + "(file = " + sqlFile);
} catch (IOException e) {
throw new MolgenisException(e.getMessage());
}
}
use of org.molgenis.emx2.MolgenisException in project molgenis-emx2 by molgenis.
the class OIDCController method handleLoginRequest.
public Object handleLoginRequest(Request request, Response response) {
final SparkWebContext context = new SparkWebContext(request, response);
final var client = securityConfig.getClients().findClient(OIDC_CLIENT_NAME).orElseThrow(() -> new MolgenisException("Expected OIDC client not found in security configuration"));
HttpAction action;
try {
@SuppressWarnings("unchecked") Optional<HttpAction> httpAction = client.getRedirectionAction(context);
if (httpAction.isEmpty()) {
throw new MolgenisException("Expected OIDC redirection action not found");
}
action = httpAction.get();
} catch (final HttpAction e) {
action = e;
}
return SparkHttpActionAdapter.INSTANCE.adapt(action, context);
}
use of org.molgenis.emx2.MolgenisException in project molgenis-emx2 by molgenis.
the class EvaluateExpressionsTest method testCalculateComputedExpressionFailure.
@Test
public void testCalculateComputedExpressionFailure() {
String expression = "5 + YAAARGH";
Row row = new Row();
try {
calculateComputedExpression(expression, row);
} catch (MolgenisException exception) {
assertEquals("Failed to execute expression: " + expression, exception.getMessage());
}
}
use of org.molgenis.emx2.MolgenisException in project molgenis-emx2 by molgenis.
the class EvaluateExpressionsTest method testCheckValidationInvalidExpression.
@Test
public void testCheckValidationInvalidExpression() {
Map<String, Object> values = new HashMap<>();
Collection<Column> columns = new ArrayList<>();
String validation = "this is very invalid";
Column column = new Column("name");
column.setValidation(validation);
columns.add(column);
try {
checkValidation(values, columns);
} catch (MolgenisException exception) {
assertEquals("Cannot execute expression: this is very invalid", exception.getMessage());
}
}
Aggregations