use of org.openforis.collect.datacleansing.DataQuery in project collect by openforis.
the class DataCleansingStepValidator method validateCondition.
private void validateCondition(DataCleansingStepForm target, Errors errors, DataCleansingStepValue updateValue, boolean lastRow) {
String condition = updateValue.getCondition();
if (StringUtils.isBlank(condition)) {
return;
}
CollectSurvey survey = getActiveSurvey();
DataQuery query = dataQueryManager.loadById(survey, target.getQueryId());
AttributeDefinition attrDef = query.getAttributeDefinition();
validateBooleanExpression(errors, attrDef.getParentEntityDefinition(), attrDef, UPDATE_VALUES_FIELD, condition);
}
use of org.openforis.collect.datacleansing.DataQuery in project collect by openforis.
the class DataCleansingStepManager method initializeQuery.
private void initializeQuery(DataCleansingStep step) {
DataQuery query = dataQueryManager.loadById((CollectSurvey) step.getSurvey(), step.getQueryId());
step.setQuery(query);
}
use of org.openforis.collect.datacleansing.DataQuery in project collect by openforis.
the class DataQueryController method startTest.
@RequestMapping(value = "start-test.json", method = RequestMethod.POST)
@ResponseBody
public Response startTest(@Validated DataQueryForm form, @RequestParam Step recordStep, BindingResult result) {
List<ObjectError> errors = result.getAllErrors();
if (errors.isEmpty()) {
CollectSurvey survey = sessionManager.getActiveSurvey();
DataQuery query = new DataQuery(survey);
form.copyTo(query);
testJob = collectJobManager.createJob(DataQueryExecutorJob.class);
testJob.setInput(new DataQueryExecutorJobInput(query, recordStep, new MemoryStoreDataQueryResultItemProcessor(query), TEST_MAX_RECORDS));
collectJobManager.start(testJob);
return new Response();
} else {
return new SimpleFormUpdateResponse(errors);
}
}
use of org.openforis.collect.datacleansing.DataQuery 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++;
}
}
use of org.openforis.collect.datacleansing.DataQuery in project collect by openforis.
the class DataCleansingStepValueValidator method validateForm.
@Override
public void validateForm(DataCleansingStepValueForm target, Errors errors) {
CollectSurvey survey = getActiveSurvey();
DataQuery query = dataQueryManager.loadById(survey, target.getQueryId());
AttributeDefinition attrDef = query.getAttributeDefinition();
int index = target.getIndex();
// if (validateUniqueness(target, errors, step)) {
validateCondition(target, errors, attrDef);
switch(target.getUpdateType()) {
case ATTRIBUTE:
validateUpdateByAttribute(errors, target, attrDef, index);
break;
case FIELD:
validateUpdateByField(errors, target, attrDef, index);
break;
}
// }
}
Aggregations