use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class RecordController method downloadValidationReportResult.
@RequestMapping(value = "survey/{surveyId}/data/records/validationreport.csv", method = GET)
public void downloadValidationReportResult(HttpServletResponse response) throws FileNotFoundException, IOException {
File file = validationReportJob.getOutputFile();
CollectSurvey survey = validationReportJob.getInput().getRecordFilter().getSurvey();
String surveyName = survey.getName();
Controllers.writeFileToResponse(response, file, String.format("collect-validation-report-%s-%s.csv", surveyName, Dates.formatDate(new Date())), Controllers.CSV_CONTENT_TYPE);
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class RecordController method startValidationResportJob.
@RequestMapping(value = "survey/{surveyId}/data/records/validationreport", method = POST)
@ResponseBody
public JobProxy startValidationResportJob(@PathVariable("surveyId") int surveyId) {
User user = sessionManager.getLoggedUser();
Locale locale = sessionManager.getSessionState().getLocale();
CollectSurvey survey = surveyManager.getById(surveyId);
EntityDefinition rootEntityDef = survey.getSchema().getFirstRootEntityDefinition();
ValidationReportJob job = jobManager.createJob(ValidationReportJob.class);
Input input = new Input();
input.setLocale(locale);
input.setReportType(ReportType.CSV);
RecordFilter recordFilter = createRecordFilter(survey, user, userGroupManager, rootEntityDef.getId(), false);
input.setRecordFilter(recordFilter);
job.setInput(input);
this.validationReportJob = job;
jobManager.start(job);
return new JobProxy(job);
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class RecordStatsGenerator method generate.
public RecordsStats generate(int surveyId, Date[] period) {
final RecordsStats stats = new RecordsStats(period);
CollectSurvey survey = surveyManager.getById(surveyId);
recordManager.visitSummaries(new RecordFilter(survey), null, new Visitor<CollectRecordSummary>() {
public void visit(CollectRecordSummary s) {
for (Entry<Step, StepSummary> entry : s.getStepSummaries().entrySet()) {
Step step = entry.getKey();
StepSummary stepSummary = entry.getValue();
if (stepSummary.getCreationDate() != null) {
PointStats pointStats = stats.getOrCreateDailyStats(stepSummary.getCreationDate());
switch(step) {
case ENTRY:
pointStats.incrementCreated();
break;
case CLEANSING:
pointStats.incrementEntered();
break;
case ANALYSIS:
pointStats.incrementCleansed();
break;
}
}
}
if (s.getModifiedDate() != null) {
PointStats pointStats = stats.getOrCreateDailyStats(s.getModifiedDate());
pointStats.incrementModified();
}
}
}, true);
stats.finalize();
return stats;
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class SaikuController method generateRepository.
@RequestMapping(value = "datasources/{surveyName}/generate", method = POST)
@ResponseBody
public JobProxy generateRepository(@PathVariable String surveyName, @RequestParam String language) throws CollectRdbException, SQLException {
CollectSurvey survey = surveyManager.get(surveyName);
ReportingRepositoriesGeneratorJob job = jobManager.createJob(ReportingRepositoriesGeneratorJob.class);
job.setInput(new Input(language));
job.setSurvey(survey);
jobManager.startSurveyJob(job);
return new JobProxy(job);
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class SamplingPointsController method loadSamplingPointBounds.
@RequestMapping(value = "survey/{surveyId}/sampling_point_bounds.json", method = GET)
@ResponseBody
public Bounds loadSamplingPointBounds(@PathVariable int surveyId) {
CollectSurvey survey = surveyManager.loadSurvey(surveyId);
CollectSurveyContext surveyContext = survey.getContext();
CoordinateOperations coordinateOperations = surveyContext.getCoordinateOperations();
SamplingDesignSummaries samplingDesignSummaries = samplingDesignManager.loadBySurvey(survey.getId());
List<SamplingDesignItem> samplingDesignItems = samplingDesignSummaries.getRecords();
Bounds bounds = new Bounds();
for (SamplingDesignItem item : samplingDesignItems) {
Coordinate coordinate = new Coordinate(item.getX(), item.getY(), item.getSrsId());
LngLatAlt lngLatAlt = createLngLatAlt(coordinateOperations, coordinate);
if (lngLatAlt != null) {
if (bounds.topLeft == null) {
bounds.topLeft = bounds.topRight = bounds.bottomLeft = bounds.bottomRight = lngLatAlt;
} else {
if (lngLatAlt.getLatitude() < bounds.topLeft.getLatitude() && lngLatAlt.getLongitude() < bounds.topLeft.getLongitude()) {
bounds.topLeft = lngLatAlt;
} else if (lngLatAlt.getLatitude() < bounds.topRight.getLatitude() && lngLatAlt.getLongitude() > bounds.topRight.getLongitude()) {
bounds.topRight = lngLatAlt;
} else if (lngLatAlt.getLatitude() > bounds.bottomRight.getLatitude() && lngLatAlt.getLongitude() > bounds.bottomRight.getLongitude()) {
bounds.bottomRight = lngLatAlt;
} else if (lngLatAlt.getLatitude() > bounds.bottomLeft.getLatitude() && lngLatAlt.getLongitude() > bounds.bottomLeft.getLongitude()) {
bounds.bottomLeft = lngLatAlt;
}
}
}
}
return bounds;
}
Aggregations