Search in sources :

Example 56 with RecordFilter

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

Example 57 with RecordFilter

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);
}
Also used : CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) CoordinateOperations(org.openforis.idm.geospatial.CoordinateOperations) CollectSurvey(org.openforis.collect.model.CollectSurvey) RecordCoordinatesKmlGeneratorJob(org.openforis.collect.model.RecordCoordinatesKmlGeneratorJob) RecordFilter(org.openforis.collect.model.RecordFilter) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 58 with RecordFilter

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);
}
Also used : CollectSurvey(org.openforis.collect.model.CollectSurvey) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) RecordFilter(org.openforis.collect.model.RecordFilter) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 59 with RecordFilter

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;
}
Also used : User(org.openforis.collect.model.User) UserInGroup(org.openforis.collect.model.UserInGroup) CollectRecordSummary(org.openforis.collect.model.CollectRecordSummary) CollectSurvey(org.openforis.collect.model.CollectSurvey) RecordAccessControlManager(org.openforis.collect.manager.RecordAccessControlManager) RecordFilter(org.openforis.collect.model.RecordFilter)

Example 60 with RecordFilter

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;
}
Also used : HashMap(java.util.HashMap) CollectSurvey(org.openforis.collect.model.CollectSurvey) Date(java.util.Date) RecordFilter(org.openforis.collect.model.RecordFilter)

Aggregations

RecordFilter (org.openforis.collect.model.RecordFilter)66 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)33 CollectSurvey (org.openforis.collect.model.CollectSurvey)27 CollectRecord (org.openforis.collect.model.CollectRecord)14 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 Date (java.util.Date)10 User (org.openforis.collect.model.User)10 SessionState (org.openforis.collect.web.session.SessionState)7 Transactional (org.springframework.transaction.annotation.Transactional)7 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 File (java.io.File)5 HashMap (java.util.HashMap)5 CSVDataExportParameters (org.openforis.collect.io.data.csv.CSVDataExportParameters)5 Step (org.openforis.collect.model.CollectRecord.Step)5 IOException (java.io.IOException)4 SurveyBackupJob (org.openforis.collect.io.SurveyBackupJob)4 CSVDataExportJob (org.openforis.collect.io.data.CSVDataExportJob)4 Schema (org.openforis.idm.metamodel.Schema)4 Test (org.junit.Test)3