use of org.openforis.collect.model.CollectTaxonomy in project collect by openforis.
the class SpeciesService method findByVernacularName.
@Secured("ROLE_ENTRY")
public List<TaxonOccurrenceProxy> findByVernacularName(String taxonomyName, int nodeId, String searchString, int maxResults, TaxonSearchParameters parameters) {
CollectTaxonomy taxonomy = loadTaxonomyByActiveSurvey(taxonomyName);
CollectRecord activeRecord = sessionManager.getActiveRecord();
Node<? extends NodeDefinition> attr = activeRecord.getNodeByInternalId(nodeId);
if (attr instanceof TaxonAttribute) {
List<TaxonOccurrence> list = speciesManager.findByVernacularName(taxonomy, (TaxonAttribute) attr, searchString, maxResults, parameters);
return Proxies.fromList(list, TaxonOccurrenceProxy.class);
} else {
throw new IllegalArgumentException("TaxonAttribute expected, found: " + attr.getClass().getName());
}
}
use of org.openforis.collect.model.CollectTaxonomy in project collect by openforis.
the class SpeciesService method deleteTaxonomy.
@Secured("ROLE_ADMIN")
public void deleteTaxonomy(TaxonomyProxy proxy) {
CollectSurvey survey = sessionManager.getActiveDesignerSurvey();
Integer taxonomyId = proxy.getId();
CollectTaxonomy taxonomy = speciesManager.loadTaxonomyById(survey, taxonomyId);
speciesManager.delete(taxonomy);
deleteReferencingAttributes(taxonomy);
}
use of org.openforis.collect.model.CollectTaxonomy in project collect by openforis.
the class SurveyBackupJob method addSpeciesExportTask.
private void addSpeciesExportTask() {
List<CollectTaxonomy> taxonomies = speciesManager.loadTaxonomiesBySurvey(survey);
for (CollectTaxonomy taxonomy : taxonomies) {
// if ( speciesManager.hasTaxons(taxonomy.getId()) ) {
SpeciesBackupExportTask task = createTask(SpeciesBackupExportTask.class);
task.setSpeciesManager(speciesManager);
task.setOutputStream(zipOutputStream);
task.setSurvey(survey);
task.setTaxonomyId(taxonomy.getId());
String entryName = String.format(SPECIES_ENTRY_FORMAT, taxonomy.getName());
task.addStatusChangeListener(new ZipEntryCreatorTaskStatusChangeListener(zipOutputStream, entryName));
addTask(task);
// }
}
}
use of org.openforis.collect.model.CollectTaxonomy in project collect by openforis.
the class SpeciesBackupImportJobIntegrationTest method importCSVFile.
private SpeciesBackupImportJob importCSVFile(String fileName) throws Exception {
File file = getTestFile(fileName);
CollectTaxonomy taxonomy = new CollectTaxonomy();
taxonomy.setSurvey(survey);
taxonomy.setName(TEST_TAXONOMY_NAME);
speciesManager.save(taxonomy);
SpeciesBackupImportJob job = jobManager.createJob(SpeciesBackupImportJob.class);
job.setFile(file);
job.setSurvey(survey);
job.setTaxonomyName(TEST_TAXONOMY_NAME);
jobManager.start(job, false);
return job;
}
use of org.openforis.collect.model.CollectTaxonomy in project collect by openforis.
the class SpeciesBackupImportJobIntegrationTest method testExport.
@Test
public void testExport() throws Exception {
SpeciesBackupImportJob job = importCSVFile(VALID_TEST_CSV);
assertTrue(job.isCompleted());
CollectTaxonomy taxonomy = taxonomyDao.loadByName(survey, TEST_TAXONOMY_NAME);
TaxonSummaries summaries = speciesManager.loadFullTaxonSummariesOld(taxonomy);
assertNotNull(summaries);
}
Aggregations