Search in sources :

Example 91 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class SpeciesDaoIntegrationTest method createAndStoreSurvey.

protected CollectSurvey createAndStoreSurvey() {
    CollectSurvey survey = createSurvey();
    survey.setName("survey_test");
    survey.setUri("http://www.openforis.org/idm/species_dao_it");
    try {
        surveyManager.importModel(survey);
    } catch (SurveyImportException e) {
        throw new RuntimeException(e);
    }
    return survey;
}
Also used : CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 92 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class SpeciesDaoIntegrationTest method testDeleteTaxonByTaxonomy.

@Test
public void testDeleteTaxonByTaxonomy() {
    CollectSurvey survey = createAndStoreSurvey();
    // Create taxonomy
    CollectTaxonomy t = new CollectTaxonomy();
    t.setSurvey(survey);
    t.setName("it_trees");
    taxonomyDao.insert(t);
    CollectTaxonomy t2 = new CollectTaxonomy();
    t2.setSurvey(survey);
    t2.setName("it_bamboos");
    taxonomyDao.insert(t2);
    Taxon family1 = testInsertAndLoadTaxon(t, -1, "JUGLANDACAE", "Juglandaceae", FAMILY, 9, null);
    Taxon genus1 = testInsertAndLoadTaxon(t, -2, "JUG", "Juglans sp.", GENUS, 9, family1);
    testInsertAndLoadTaxon(t, -3, "JUG/REG", "Juglans regia", SPECIES, 9, genus1);
    Taxon family2 = testInsertAndLoadTaxon(t2, -1, "JUGLANDACAE", "Juglandaceae", FAMILY, 9, null);
    Taxon genus2 = testInsertAndLoadTaxon(t2, -2, "JUG", "Juglans sp.", GENUS, 9, family2);
    testInsertAndLoadTaxon(t2, -3, "JUG/REG", "Juglans regia", SPECIES, 9, genus2);
    // verify taxon records present
    List<Taxon> results = taxonDao.findByCode(t, FAMILY, "%", 10);
    assertEquals(3, results.size());
    taxonDao.deleteByTaxonomy(t);
    // verify all taxon records deleted for taxonomy 1
    List<Taxon> results2 = taxonDao.findByCode(t, FAMILY, "%", 10);
    assertTrue(results2 == null || results2.size() == 0);
    // verify all taxon records NOT deleted for taxonomy 2
    List<Taxon> results3 = taxonDao.findByCode(t2, FAMILY, "%", 10);
    assertEquals(3, results3.size());
}
Also used : Taxon(org.openforis.idm.model.species.Taxon) CollectSurvey(org.openforis.collect.model.CollectSurvey) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 93 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class SurveyExportParametersVM method export.

@Command
public void export() {
    rdbExportJob = null;
    surveyBackupJob = null;
    String uri = surveySummary.getUri();
    final CollectSurvey loadedSurvey;
    if (surveySummary.isTemporary() && SurveyType.valueOf(formObject.getType()) == TEMPORARY) {
        loadedSurvey = surveyManager.loadSurvey(surveySummary.getId());
    } else {
        loadedSurvey = surveyManager.getByUri(uri);
    }
    switch(formObject.getOutputFormatEnum()) {
        case EARTH:
            validateSurvey(loadedSurvey, collectEarthSurveyValidator, new SuccessHandler() {

                public void onSuccess() {
                    exportCollectEarthSurvey(loadedSurvey, formObject);
                }
            }, true);
            return;
        case RDB:
            startRDBSurveyExportJob(loadedSurvey, formObject);
            break;
        case MOBILE:
            validateSurvey(loadedSurvey, surveyValidator, new SuccessHandler() {

                public void onSuccess() {
                    startCollectSurveyExportJob(loadedSurvey, formObject);
                }
            }, true);
            break;
        default:
            startCollectSurveyExportJob(loadedSurvey, formObject);
            break;
    }
}
Also used : SuccessHandler(org.openforis.collect.designer.util.SuccessHandler) CollectSurvey(org.openforis.collect.model.CollectSurvey) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Example 94 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class SurveyLanguageVM method applyChanges.

@Command
public void applyChanges() {
    final SessionStatus sessionStatus = getSessionStatus();
    final CollectSurvey survey = sessionStatus.getSurvey();
    final List<String> newLanguageCodes = getSelectedLanguageCodes();
    final List<String> removedLanguages = calculateRemovedLanguages();
    if (removedLanguages.isEmpty()) {
        performLanguageUpdate(survey, newLanguageCodes);
    } else {
        ConfirmParams confirmParams = new ConfirmParams(new MessageUtil.ConfirmHandler() {

            @Override
            public void onOk() {
                performLanguageUpdate(survey, newLanguageCodes);
            }
        }, "survey.language.remove.confirm");
        confirmParams.setOkLabelKey("global.remove_item");
        confirmParams.setMessageArgs(new String[] { StringUtils.join(removedLanguages, ", ") });
        MessageUtil.showConfirm(confirmParams);
    }
}
Also used : ConfirmParams(org.openforis.collect.designer.util.MessageUtil.ConfirmParams) MessageUtil(org.openforis.collect.designer.util.MessageUtil) SessionStatus(org.openforis.collect.designer.session.SessionStatus) CollectSurvey(org.openforis.collect.model.CollectSurvey) Command(org.zkoss.bind.annotation.Command)

Example 95 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class SurveyLanguageVM method calculateRemovedLanguages.

private List<String> calculateRemovedLanguages() {
    final SessionStatus sessionStatus = getSessionStatus();
    CollectSurvey survey = sessionStatus.getSurvey();
    List<String> oldLanguageCodes = survey.getLanguages();
    List<String> newLanguageCodes = getSelectedLanguageCodes();
    List<String> removedLanguages = new ArrayList<String>();
    for (String oldLangCode : oldLanguageCodes) {
        if (!newLanguageCodes.contains(oldLangCode)) {
            removedLanguages.add(Labels.getLabel(oldLangCode));
        }
    }
    return removedLanguages;
}
Also used : SessionStatus(org.openforis.collect.designer.session.SessionStatus) ArrayList(java.util.ArrayList) CollectSurvey(org.openforis.collect.model.CollectSurvey)

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