Search in sources :

Example 1 with OfcDataCleansingStepValueRecord

use of org.openforis.collect.persistence.jooq.tables.records.OfcDataCleansingStepValueRecord in project collect by openforis.

the class DataCleansingStepDao method insertStepValues.

public void insertStepValues(int stepId, List<DataCleansingStepValue> values) {
    JooqDSLContext dsl = dsl();
    List<Field<?>> fields = new ArrayList<Field<?>>(Arrays.<Field<?>>asList(OFC_DATA_CLEANSING_STEP_VALUE.STEP_ID, OFC_DATA_CLEANSING_STEP_VALUE.SORT_ORDER, OFC_DATA_CLEANSING_STEP_VALUE.TYPE, OFC_DATA_CLEANSING_STEP_VALUE.CONDITION, OFC_DATA_CLEANSING_STEP_VALUE.FIX_EXPRESSION));
    fields.addAll(Arrays.asList(FIELD_FIX_EXPRESSION_FIELDS));
    InsertValuesStepN<OfcDataCleansingStepValueRecord> insert = dsl.insertInto(OFC_DATA_CLEANSING_STEP_VALUE, fields).values(// add ? placeholders
    Collections.nCopies(fields.size(), "?"));
    BatchBindStep batch = dsl.batch(insert);
    int stepIndex = 0;
    for (DataCleansingStepValue stepValue : values) {
        List<Object> insertValues = new ArrayList<Object>(Arrays.<Object>asList(stepId, stepIndex + 1, String.valueOf(stepValue.getUpdateType().getCode()), stepValue.getCondition(), stepValue.getFixExpression()));
        List<String> fieldFixExpressions = getFieldFixExpressionValues(stepValue);
        insertValues.addAll(fieldFixExpressions);
        batch.bind(insertValues.toArray(new Object[insertValues.size()]));
        stepIndex++;
    }
    batch.execute();
}
Also used : DataCleansingStepValue(org.openforis.collect.datacleansing.DataCleansingStepValue) BatchBindStep(org.jooq.BatchBindStep) ArrayList(java.util.ArrayList) Field(org.jooq.Field) TableField(org.jooq.TableField) OfcDataCleansingStepValueRecord(org.openforis.collect.persistence.jooq.tables.records.OfcDataCleansingStepValueRecord)

Aggregations

ArrayList (java.util.ArrayList)1 BatchBindStep (org.jooq.BatchBindStep)1 Field (org.jooq.Field)1 TableField (org.jooq.TableField)1 DataCleansingStepValue (org.openforis.collect.datacleansing.DataCleansingStepValue)1 OfcDataCleansingStepValueRecord (org.openforis.collect.persistence.jooq.tables.records.OfcDataCleansingStepValueRecord)1