use of org.openforis.collect.datacleansing.DataCleansingStepValue 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();
}
use of org.openforis.collect.datacleansing.DataCleansingStepValue in project collect by openforis.
the class DataCleansingStepValidator method validateUpdateValues.
private void validateUpdateValues(DataCleansingStepForm target, Errors errors) {
CollectSurvey survey = getActiveSurvey();
DataQuery query = dataQueryManager.loadById(survey, target.getQueryId());
AttributeDefinition attrDef = query.getAttributeDefinition();
List<DataCleansingStepValue> updateValues = target.getUpdateValues();
int updateValueIndex = 0;
for (DataCleansingStepValue updateValue : updateValues) {
validateCondition(target, errors, updateValue, updateValueIndex == updateValues.size() - 1);
switch(updateValue.getUpdateType()) {
case ATTRIBUTE:
validateUpdateByAttribute(errors, updateValue, attrDef, updateValueIndex);
break;
case FIELD:
validateUpdateByField(errors, attrDef, updateValueIndex, updateValue);
break;
}
updateValueIndex++;
}
}
Aggregations