Search in sources :

Example 1 with DataQueryGroup

use of org.openforis.collect.datacleansing.DataQueryGroup in project collect by openforis.

the class DataCleansingManagerImpl method loadMetadata.

@Override
public DataCleansingMetadata loadMetadata(CollectSurvey survey) {
    List<DataQuery> dataQueries = dataQueryManager.loadBySurvey(survey);
    List<DataQueryType> dataQueryTypes = dataTypeManager.loadBySurvey(survey);
    for (DataQuery dataQuery : dataQueries) {
        Integer typeId = dataQuery.getTypeId();
        dataQuery.setType(typeId == null ? null : CollectionUtils.findItem(dataQueryTypes, typeId));
    }
    List<DataQueryGroup> dataQueryGroups = dataQueryGroupManager.loadBySurvey(survey);
    for (DataQueryGroup group : dataQueryGroups) {
        List<DataQuery> queries = group.getQueries();
        List<DataQuery> correctQueries = new ArrayList<DataQuery>(queries.size());
        for (DataQuery dataQuery : queries) {
            correctQueries.add(CollectionUtils.findItem(dataQueries, dataQuery.getId()));
        }
        group.removeAllQueries();
        group.allAllQueries(correctQueries);
    }
    List<DataCleansingStep> cleansingSteps = dataCleansingStepManager.loadBySurvey(survey);
    for (DataCleansingStep step : cleansingSteps) {
        step.setQuery(CollectionUtils.findItem(dataQueries, step.getQueryId()));
    }
    List<DataCleansingChain> cleansingChains = dataCleansingChainManager.loadBySurvey(survey);
    for (DataCleansingChain chain : cleansingChains) {
        List<DataCleansingStep> steps = chain.getSteps();
        List<DataCleansingStep> correctSteps = new ArrayList<DataCleansingStep>(steps.size());
        for (DataCleansingStep step : steps) {
            correctSteps.add(CollectionUtils.findItem(cleansingSteps, step.getId()));
        }
        chain.removeAllSteps();
        chain.addAllSteps(correctSteps);
    }
    DataCleansingMetadata metadata = new DataCleansingMetadata(survey, dataQueryTypes, dataQueries, dataQueryGroups, cleansingSteps, cleansingChains);
    return metadata;
}
Also used : ArrayList(java.util.ArrayList) DataQueryType(org.openforis.collect.datacleansing.DataQueryType) DataQueryGroup(org.openforis.collect.datacleansing.DataQueryGroup) DataCleansingMetadata(org.openforis.collect.datacleansing.DataCleansingMetadata) DataCleansingChain(org.openforis.collect.datacleansing.DataCleansingChain) DataCleansingStep(org.openforis.collect.datacleansing.DataCleansingStep) DataQuery(org.openforis.collect.datacleansing.DataQuery)

Example 2 with DataQueryGroup

use of org.openforis.collect.datacleansing.DataQueryGroup in project collect by openforis.

the class DataQueryGroupValidator method validateTitleUniqueness.

private boolean validateTitleUniqueness(DataQueryGroupForm target, Errors errors) {
    String title = target.getTitle();
    CollectSurvey survey = getActiveSurvey();
    List<DataQueryGroup> items = dataQueryGroupManager.loadBySurvey(survey);
    for (DataQueryGroup item : items) {
        if (!item.getId().equals(target.getId()) && item.getTitle().equalsIgnoreCase(title)) {
            rejectDuplicateValue(errors, TITLE_FIELD);
            return false;
        }
    }
    return true;
}
Also used : CollectSurvey(org.openforis.collect.model.CollectSurvey) DataQueryGroup(org.openforis.collect.datacleansing.DataQueryGroup)

Example 3 with DataQueryGroup

use of org.openforis.collect.datacleansing.DataQueryGroup in project collect by openforis.

the class DataReportManager method initQueryGroup.

private void initQueryGroup(DataReport report) {
    DataQueryGroup queryGroup = queryGroupManager.loadById((CollectSurvey) report.getSurvey(), report.getQueryGroupId());
    report.setQueryGroup(queryGroup);
}
Also used : DataQueryGroup(org.openforis.collect.datacleansing.DataQueryGroup)

Example 4 with DataQueryGroup

use of org.openforis.collect.datacleansing.DataQueryGroup in project collect by openforis.

the class DataReportController method generate.

@RequestMapping(value = "generate.json", method = POST)
@ResponseBody
public Response generate(@RequestParam int queryGroupId, @RequestParam Step recordStep) {
    CollectSurvey survey = sessionManager.getActiveSurvey();
    DataQueryGroup queryGroup = dataQueryGroupManager.loadById(survey, queryGroupId);
    generationJob = collectJobManager.createJob(DataReportGeneratorJob.class);
    generationJob.setQueryGroup(queryGroup);
    generationJob.setRecordStep(recordStep);
    generationJob.setActiveUser(getLoggedUser());
    collectJobManager.start(generationJob);
    return new Response();
}
Also used : DataReportGeneratorJob(org.openforis.collect.datacleansing.DataReportGeneratorJob) PaginatedResponse(org.openforis.collect.web.controller.PaginatedResponse) Response(org.openforis.commons.web.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) CollectSurvey(org.openforis.collect.model.CollectSurvey) DataQueryGroup(org.openforis.collect.datacleansing.DataQueryGroup) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with DataQueryGroup

use of org.openforis.collect.datacleansing.DataQueryGroup in project collect by openforis.

the class DataQueryGroupValidator method validateQueryUniqueness.

private boolean validateQueryUniqueness(DataQueryGroupForm target, Errors errors) {
    CollectSurvey survey = getActiveSurvey();
    List<DataQueryGroup> items = dataQueryGroupManager.loadBySurvey(survey);
    for (DataQueryGroup item : items) {
        if (!item.getId().equals(target.getId())) {
            List<DataQuery> queries = item.getQueries();
            List<Integer> queryIds = CollectionUtils.project(queries, "id");
            if (queryIds.equals(target.getQueryIds())) {
                rejectDuplicateValue(errors, QUERY_IDS_FIELD);
                return false;
            }
        }
    }
    return true;
}
Also used : DataQuery(org.openforis.collect.datacleansing.DataQuery) CollectSurvey(org.openforis.collect.model.CollectSurvey) DataQueryGroup(org.openforis.collect.datacleansing.DataQueryGroup)

Aggregations

DataQueryGroup (org.openforis.collect.datacleansing.DataQueryGroup)5 CollectSurvey (org.openforis.collect.model.CollectSurvey)3 DataQuery (org.openforis.collect.datacleansing.DataQuery)2 ArrayList (java.util.ArrayList)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 DataCleansingChain (org.openforis.collect.datacleansing.DataCleansingChain)1 DataCleansingMetadata (org.openforis.collect.datacleansing.DataCleansingMetadata)1 DataCleansingStep (org.openforis.collect.datacleansing.DataCleansingStep)1 DataQueryType (org.openforis.collect.datacleansing.DataQueryType)1 DataReportGeneratorJob (org.openforis.collect.datacleansing.DataReportGeneratorJob)1 PaginatedResponse (org.openforis.collect.web.controller.PaginatedResponse)1 Response (org.openforis.commons.web.Response)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1