use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataCleansingChainExectutorTask method countTotalItems.
@Override
protected long countTotalItems() {
RecordFilter recordsFilter = createRecordsFilter();
int count = recordManager.countRecords(recordsFilter);
return count;
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class GeoDataController method createCoordinateValuesKML.
@RequestMapping(value = "survey/{surveyId}/data/coordinatesvalues.kml", method = GET, produces = KML_CONTENT_TYPE)
public void createCoordinateValuesKML(@PathVariable("surveyId") int surveyId, @RequestParam int stepNum, @RequestParam int coordinateAttributeId, HttpServletResponse response) throws Exception {
CollectSurvey survey = surveyManager.getById(surveyId);
CoordinateAttributeDefinition nodeDef = (CoordinateAttributeDefinition) survey.getSchema().getDefinitionById(coordinateAttributeId);
RecordCoordinatesKmlGeneratorJob job = new RecordCoordinatesKmlGeneratorJob();
job.setRecordManager(recordManager);
RecordFilter filter = new RecordFilter(survey);
job.setRecordFilter(filter);
job.setNodeDefinition(nodeDef);
job.setOutput(response.getOutputStream());
CoordinateOperations coordinateOperations = survey.getContext().getCoordinateOperations();
coordinateOperations.registerSRS(survey.getSpatialReferenceSystems());
job.setCoordinateOperations(coordinateOperations);
jobManager.start(job, false);
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class RecordController method downloadCsvExportResult.
@RequestMapping(value = "survey/{surveyId}/data/records/csvexportresult.zip", method = GET)
public void downloadCsvExportResult(HttpServletResponse response) throws FileNotFoundException, IOException {
File file = csvDataExportJob.getOutputFile();
RecordFilter recordFilter = csvDataExportJob.getParameters().getRecordFilter();
CollectSurvey survey = recordFilter.getSurvey();
String surveyName = survey.getName();
Controllers.writeFileToResponse(response, file, String.format("collect-csv-data-export-%s-%s.zip", surveyName, Dates.formatLocalDateTime(new Date())), Controllers.ZIP_CONTENT_TYPE);
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class RecordController method canDeleteRecords.
private boolean canDeleteRecords(int surveyId, Set<Integer> recordIds) {
CollectSurvey survey = surveyManager.getById(surveyId);
RecordFilter filter = new RecordFilter(survey);
filter.setRecordIds(recordIds);
List<CollectRecordSummary> recordSummaries = recordManager.loadSummaries(filter);
User loggedUser = sessionManager.getLoggedUser();
RecordAccessControlManager recordAccessControlManager = new RecordAccessControlManager();
UserInGroup userInSurveyGroup = userGroupManager.findUserInGroupOrDescendants(survey.getUserGroup(), loggedUser);
boolean canDeleteRecords = userInSurveyGroup != null && recordAccessControlManager.canDeleteRecords(loggedUser, userInSurveyGroup.getRole(), recordSummaries);
return canDeleteRecords;
}
use of org.openforis.collect.model.RecordFilter in project collect by openforis.
the class DataExportService method getLastBackupInfo.
public Map<String, Object> getLastBackupInfo(String surveyName) {
final Date date = backupStorageManager.getLastBackupDate(surveyName);
CollectSurvey survey = surveyManager.get(surveyName);
RecordFilter filter = new RecordFilter(survey);
filter.setModifiedSince(date);
final int updatedRecordsSinceBackupDateCount = recordManager.countRecords(filter);
@SuppressWarnings("serial") Map<String, Object> map = new HashMap<String, Object>() {
{
put("date", date);
put("updatedRecordsSinceBackup", updatedRecordsSinceBackupDateCount);
}
};
return map;
}
Aggregations