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;
}
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());
}
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;
}
}
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);
}
}
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;
}
Aggregations