Search in sources :

Example 11 with Column

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());
    }
}
Also used : Column(org.molgenis.emx2.Column) ArrayList(java.util.ArrayList) MolgenisException(org.molgenis.emx2.MolgenisException) Test(org.junit.Test)

Example 12 with Column

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());
    }
}
Also used : HashMap(java.util.HashMap) Column(org.molgenis.emx2.Column) ArrayList(java.util.ArrayList) MolgenisException(org.molgenis.emx2.MolgenisException) Test(org.junit.Test)

Example 13 with Column

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;
}
Also used : TableMetadata(org.molgenis.emx2.TableMetadata) Field(java.lang.reflect.Field) Column(org.molgenis.emx2.Column)

Example 14 with Column

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();
}
Also used : Column(com.google.bigtable.v2.Column) Family(com.google.bigtable.v2.Family) Cell(com.google.bigtable.v2.Cell) InternalApi(com.google.api.core.InternalApi)

Example 15 with Column

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;
}
Also used : org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal) Schema(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.Schema) Dialect(org.jaxdb.vendor.Dialect) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column) URL(java.net.URL)

Aggregations

org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column)21 ArrayList (java.util.ArrayList)17 HashMap (java.util.HashMap)11 Column (org.molgenis.emx2.Column)11 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)10 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint)10 Column (com.google.bigtable.v2.Column)9 List (java.util.List)9 Family (com.google.bigtable.v2.Family)8 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint)8 Test (org.junit.Test)8 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Table)7 MolgenisException (org.molgenis.emx2.MolgenisException)6 Map (java.util.Map)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer)4 SqlColumnExecutor.validateColumn (org.molgenis.emx2.sql.SqlColumnExecutor.validateColumn)4 Cell (com.google.bigtable.v2.Cell)3 ResultSet (java.sql.ResultSet)3 ExecutionException (java.util.concurrent.ExecutionException)3