Search in sources :

Example 1 with DataQueryType

use of org.openforis.collect.datacleansing.DataQueryType 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 DataQueryType

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

the class DataQueryTypeManager method delete.

@Override
public void delete(DataQueryType obj) {
    DataQueryType errorType = loadById((CollectSurvey) obj.getSurvey(), obj.getId());
    checkNotInUse(errorType);
    super.delete(errorType);
}
Also used : DataQueryType(org.openforis.collect.datacleansing.DataQueryType)

Example 3 with DataQueryType

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

the class DataQueryTypeValidator method validateCodeUniqueness.

private boolean validateCodeUniqueness(DataQueryTypeForm target, Errors errors) {
    CollectSurvey survey = getActiveSurvey();
    DataQueryType existingItem = dataQueryTypeManager.loadByCode(survey, target.getCode());
    if (existingItem != null && !existingItem.getId().equals(target.getId())) {
        rejectDuplicateValue(errors, CODE_FIELD);
        return false;
    } else {
        return true;
    }
}
Also used : DataQueryType(org.openforis.collect.datacleansing.DataQueryType) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 4 with DataQueryType

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

the class DataQueryManager method initializeType.

private void initializeType(DataQuery q) {
    Integer typeId = q.getTypeId();
    DataQueryType type = typeId == null ? null : dataQueryTypeManager.loadById((CollectSurvey) q.getSurvey(), typeId);
    q.setType(type);
}
Also used : DataQueryType(org.openforis.collect.datacleansing.DataQueryType) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Aggregations

DataQueryType (org.openforis.collect.datacleansing.DataQueryType)4 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 ArrayList (java.util.ArrayList)1 DataCleansingChain (org.openforis.collect.datacleansing.DataCleansingChain)1 DataCleansingMetadata (org.openforis.collect.datacleansing.DataCleansingMetadata)1 DataCleansingStep (org.openforis.collect.datacleansing.DataCleansingStep)1 DataQuery (org.openforis.collect.datacleansing.DataQuery)1 DataQueryGroup (org.openforis.collect.datacleansing.DataQueryGroup)1