Search in sources :

Example 6 with DataQuery

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);
}
Also used : AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) DataQuery(org.openforis.collect.datacleansing.DataQuery) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 7 with DataQuery

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);
}
Also used : DataQuery(org.openforis.collect.datacleansing.DataQuery)

Example 8 with DataQuery

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);
    }
}
Also used : DataQueryExecutorJobInput(org.openforis.collect.datacleansing.DataQueryExecutorJob.DataQueryExecutorJobInput) Response(org.openforis.commons.web.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) ObjectError(org.springframework.validation.ObjectError) DataQueryExecutorJob(org.openforis.collect.datacleansing.DataQueryExecutorJob) DataQuery(org.openforis.collect.datacleansing.DataQuery) CollectSurvey(org.openforis.collect.model.CollectSurvey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 9 with DataQuery

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++;
    }
}
Also used : DataCleansingStepValue(org.openforis.collect.datacleansing.DataCleansingStepValue) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) DataQuery(org.openforis.collect.datacleansing.DataQuery) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 10 with DataQuery

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;
    }
// }
}
Also used : AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) DataQuery(org.openforis.collect.datacleansing.DataQuery) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Aggregations

DataQuery (org.openforis.collect.datacleansing.DataQuery)11 CollectSurvey (org.openforis.collect.model.CollectSurvey)7 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)3 ArrayList (java.util.ArrayList)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 DataQueryGroup (org.openforis.collect.datacleansing.DataQueryGroup)2 Response (org.openforis.commons.web.Response)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 DataCleansingChain (org.openforis.collect.datacleansing.DataCleansingChain)1 DataCleansingMetadata (org.openforis.collect.datacleansing.DataCleansingMetadata)1 DataCleansingStep (org.openforis.collect.datacleansing.DataCleansingStep)1 DataCleansingStepValue (org.openforis.collect.datacleansing.DataCleansingStepValue)1 DataQueryExecutorJob (org.openforis.collect.datacleansing.DataQueryExecutorJob)1 DataQueryExecutorJobInput (org.openforis.collect.datacleansing.DataQueryExecutorJob.DataQueryExecutorJobInput)1 DataQueryType (org.openforis.collect.datacleansing.DataQueryType)1 CSVDataExportJob (org.openforis.collect.io.data.CSVDataExportJob)1 DescendantNodeFilter (org.openforis.collect.io.data.DescendantNodeFilter)1 CSVDataExportParameters (org.openforis.collect.io.data.csv.CSVDataExportParameters)1 RecordFilter (org.openforis.collect.model.RecordFilter)1