use of org.openforis.collect.datacleansing.DataCleansingMetadata 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;
}
use of org.openforis.collect.datacleansing.DataCleansingMetadata in project collect by openforis.
the class DataCleansingManagerImpl method duplicateMetadata.
@Transactional
@Override
public void duplicateMetadata(CollectSurvey fromSurvey, CollectSurvey toSurvey, User activeUser) {
DataCleansingMetadata metadata = loadMetadata(fromSurvey);
saveMetadata(toSurvey, metadata, false, activeUser);
}
use of org.openforis.collect.datacleansing.DataCleansingMetadata in project collect by openforis.
the class DataCleansingManagerImpl method moveMetadata.
@Transactional
@Override
public void moveMetadata(CollectSurvey fromSurvey, CollectSurvey toSurvey, User activeUser) {
DataCleansingMetadata temporaryMetadata = loadMetadata(fromSurvey);
saveMetadata(toSurvey, temporaryMetadata, false, activeUser);
deleteMetadata(fromSurvey);
}
use of org.openforis.collect.datacleansing.DataCleansingMetadata in project collect by openforis.
the class JsonDataCleansingExportTask method execute.
@Override
protected void execute() throws Throwable {
DataCleansingMetadata metadata = dataCleansingManager.loadMetadata(survey);
if (!metadata.isEmpty()) {
DataCleansingMetadataView metadataView = DataCleansingMetadataView.fromMetadata(metadata);
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(resultFile, metadataView);
}
}
use of org.openforis.collect.datacleansing.DataCleansingMetadata in project collect by openforis.
the class JsonDataCleansingImportTask method execute.
@Override
protected void execute() throws Throwable {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
DataCleansingMetadataView metadataView = objectMapper.readValue(inputFile, DataCleansingMetadataView.class);
DataCleansingMetadata metadata = metadataView.toMetadata(survey);
// TODO handle exceptions
dataCleansingManager.saveMetadata(survey, metadata, true, activeUser);
}
Aggregations