use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class BackupRestoreController method getLatestBackupInfo.
@RequestMapping(value = "survey/{surveyId}/backup/latest/info", method = GET)
@ResponseBody
public BackupInfo getLatestBackupInfo(@PathVariable("surveyId") int surveyId) {
CollectSurvey survey = surveyManager.getById(surveyId);
final Date date = backupStorageManager.getLastBackupDate(survey.getName());
RecordFilter filter = new RecordFilter(survey);
filter.setModifiedSince(date);
final int updatedRecordsSinceBackupDateCount = recordManager.countRecords(filter);
return new BackupInfo(date, updatedRecordsSinceBackupDateCount);
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class BackupRestoreController method downloadLatestBackup.
@RequestMapping(value = "survey/{surveyId}/backup/latest.collect-backup", method = GET)
public void downloadLatestBackup(@PathVariable("surveyId") int surveyId, HttpServletResponse response) throws FileNotFoundException, IOException {
CollectSurvey survey = surveyManager.getById(surveyId);
String surveyName = survey.getName();
File file = backupStorageManager.getLastBackupFile(surveyName);
Date date = backupStorageManager.getLastBackupDate(surveyName);
Controllers.writeFileToResponse(response, file, String.format("%s-%s.%s", surveyName, Dates.formatLocalDateTime(date), BACKUP_FILE_EXTENSION), Controllers.ZIP_CONTENT_TYPE);
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class CodeListController method exportCodeList.
protected String exportCodeList(HttpServletResponse response, int surveyId, int codeListId) throws IOException {
CollectSurvey survey = surveyManager.getOrLoadSurveyById(surveyId);
CodeList list = survey.getCodeListById(codeListId);
String fileName = list.getName() + CSV_EXTENSION;
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
response.setContentType(CSV_CONTENT_TYPE);
ServletOutputStream out = response.getOutputStream();
CodeListExportProcess process = new CodeListExportProcess(codeListManager);
process.exportToCSV(out, survey, codeListId);
return "ok";
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class SchemaLayoutVM method listOfNodesDropHandler.
@Listen("onDrop = tree#nodesTree")
public void listOfNodesDropHandler(DropEvent evt) {
Component dragged = evt.getDragged();
if (dragged instanceof Listitem) {
NodeDefinition node = ((Listitem) dragged).getValue();
CollectSurvey survey = getSurvey();
UIOptions uiOpts = survey.getUIOptions();
UITab oldTab = uiOpts.getAssignedTab(node, false);
uiOpts.removeTabAssociation(node);
if (oldTab != null) {
postNodePerTabChangedCommand(oldTab);
}
}
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class RecordIndexManagerIntegrationTest method roundTripTest.
@Test
public void roundTripTest() throws Exception {
CollectSurvey survey = loadSurvey();
String[] gpsModels = new String[] { "GPS MAP 62 S", "GPS MAP 60CSX", "SXBLUEII-L", "GPS MAP 62S" };
createIndex(survey, gpsModels);
NodeDefinition autoCompleteNodeDefn = survey.getSchema().getDefinitionByPath("/cluster/gps_model");
testSingleResultMatching(survey, autoCompleteNodeDefn);
testMultipleResultsFoundWithNonCompleteTerm(survey, autoCompleteNodeDefn);
testMultipleResultsFound(survey, autoCompleteNodeDefn);
// testSingleResultMatchingPhrase(survey, autoCompleteNodeDefn);
testLimitedMultipleResultsFound(survey, autoCompleteNodeDefn);
testNoResultsFound(survey, autoCompleteNodeDefn);
}
Aggregations