use of com.helger.genericode.v10.Column in project molgenis-emx2 by molgenis.
the class EvaluateExpressionsTest method testCheckValidationColumnsFailure.
@Test
public void testCheckValidationColumnsFailure() {
Collection<Column> columns = new ArrayList<>();
Column column1 = new Column("columnName1");
column1.setValidation("{columnName2}");
columns.add(column1);
try {
checkForMissingVariablesColumns(columns);
} catch (MolgenisException exception) {
String expectedError = "Validation failed: columns [columnName2] not provided";
assertEquals(expectedError, exception.getMessage());
}
}
use of com.helger.genericode.v10.Column in project molgenis-emx2 by molgenis.
the class EvaluateExpressionsTest method testCheckValidationTurnToBoolIsFalse.
@Test
public void testCheckValidationTurnToBoolIsFalse() {
Map<String, Object> values = new HashMap<>();
Collection<Column> columns = new ArrayList<>();
String validation = "false";
Column column = new Column("name");
column.setValidation(validation);
columns.add(column);
try {
checkValidation(values, columns);
} catch (MolgenisException exception) {
assertEquals("false. Values provided: {}", exception.getMessage());
}
}
use of com.helger.genericode.v10.Column in project molgenis-emx2 by molgenis.
the class Mapper method map.
public static TableMetadata map(Class<?> klazz) {
TableMetadata t = new TableMetadata(klazz.getSimpleName());
Field[] fields = klazz.getDeclaredFields();
for (Field f : fields) {
if (!f.getName().contains("jacoco")) {
Column col = column(f.getName()).setType(TypeUtils.typeOf(f.getType()));
if (f.isAnnotationPresent(ColumnAnnotation.class)) {
ColumnAnnotation cm = f.getAnnotation(ColumnAnnotation.class);
col.setRequired(cm.required());
col.setDescription(cm.description());
}
t.add(col);
}
}
return t;
}
use of com.helger.genericode.v10.Column in project java-bigtable by googleapis.
the class DefaultRowAdapter method createRowFromProto.
/**
* Helper to convert a proto Row to a model Row.
*
* <p>For internal use only.
*/
@InternalApi
public Row createRowFromProto(com.google.bigtable.v2.Row row) {
RowBuilder<Row> builder = createRowBuilder();
builder.startRow(row.getKey());
for (Family family : row.getFamiliesList()) {
for (Column column : family.getColumnsList()) {
for (Cell cell : column.getCellsList()) {
builder.startCell(family.getName(), column.getQualifier(), cell.getTimestampMicros(), cell.getLabelsList(), cell.getValue().size());
builder.cellValue(cell.getValue());
builder.finishCell();
}
}
}
return builder.finishRow();
}
use of com.helger.genericode.v10.Column in project jaxdb by jaxdb.
the class DDLxTest method recreateSchema.
// FIXME: The efficiency of this is TERRIBLE!
public static Schema recreateSchema(final Connection connection, final String ddlxFileName, final boolean unaltered) throws GeneratorExecutionException, IOException, SAXException, SQLException, TransformerException {
final DDLx ddlx = new DDLx(ClassLoader.getSystemClassLoader().getResource(ddlxFileName + ".ddlx"));
final Schema schema = ddlx.getMergedSchema();
if (!unaltered) {
final Dialect dialect = DBVendor.valueOf(connection.getMetaData()).getDialect();
for (final $Table table : schema.getTable()) {
if (table.getColumn() != null) {
for (final $Column column : table.getColumn()) {
if (column instanceof $Decimal) {
final $Decimal decimal = ($Decimal) column;
final int maxPrecision = dialect.decimalMaxPrecision();
decimal.setPrecision$(new $Decimal.Precision$(maxPrecision));
if (decimal.getScale$() != null && decimal.getScale$().text() > maxPrecision)
decimal.setScale$(new $Decimal.Scale$(maxPrecision));
}
}
}
}
}
final URL url = MemoryURLStreamHandler.createURL(schema.toString().getBytes());
Schemas.recreate(connection, url);
return schema;
}
Aggregations