Search in sources :

Example 81 with CollectSurvey

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

Example 82 with CollectSurvey

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

Example 83 with CollectSurvey

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";
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) ServletOutputStream(javax.servlet.ServletOutputStream) CodeListExportProcess(org.openforis.collect.manager.dataexport.codelist.CodeListExportProcess) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 84 with CollectSurvey

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);
        }
    }
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) Listitem(org.zkoss.zul.Listitem) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) Component(org.zkoss.zk.ui.Component) CollectSurvey(org.openforis.collect.model.CollectSurvey) Listen(org.zkoss.zk.ui.select.annotation.Listen)

Example 85 with CollectSurvey

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);
}
Also used : NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Aggregations

CollectSurvey (org.openforis.collect.model.CollectSurvey)329 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)53 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)40 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)38 CollectRecord (org.openforis.collect.model.CollectRecord)30 RecordFilter (org.openforis.collect.model.RecordFilter)27 Transactional (org.springframework.transaction.annotation.Transactional)26 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)25 ArrayList (java.util.ArrayList)23 File (java.io.File)21 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)21 Secured (org.springframework.security.access.annotation.Secured)20 User (org.openforis.collect.model.User)19 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)19 SessionState (org.openforis.collect.web.session.SessionState)18 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)17 Test (org.junit.Test)16 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)15 CodeList (org.openforis.idm.metamodel.CodeList)15 Schema (org.openforis.idm.metamodel.Schema)15