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();
}
Aggregations