use of org.openforis.collect.metamodel.TaxonSummaries in project collect by openforis.
the class SpeciesImportProcessIntegrationTest method testExport.
@Test
public void testExport() throws Exception {
SpeciesImportProcess process = importCSVFile(VALID_TEST_CSV);
SpeciesImportStatus status = process.getStatus();
assertTrue(status.isComplete());
CollectTaxonomy taxonomy = taxonomyDao.loadByName(survey, TEST_TAXONOMY_NAME);
TaxonSummaries summaries = speciesManager.loadFullTaxonSummariesOld(taxonomy);
assertNotNull(summaries);
}
use of org.openforis.collect.metamodel.TaxonSummaries in project collect by openforis.
the class SpeciesService method loadTaxonSummaries.
@Secured("ROLE_ADMIN")
public TaxonSummariesProxy loadTaxonSummaries(int taxonomyId, int offset, int maxRecords) {
CollectSurvey survey = getActiveSurvey();
TaxonSummaries summaries = speciesManager.loadTaxonSummaries(survey, taxonomyId, offset, maxRecords);
return new TaxonSummariesProxy(summaries);
}
use of org.openforis.collect.metamodel.TaxonSummaries 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);
}
use of org.openforis.collect.metamodel.TaxonSummaries in project collect by openforis.
the class SpeciesManager method loadTaxonSummaries.
public TaxonSummaries loadTaxonSummaries(CollectSurvey survey, int taxonomyId, int offset, int maxRecords) {
CollectTaxonomy taxonomy = loadTaxonomyById(survey, taxonomyId);
String taxonomyName = taxonomy.getName();
int totalCount = taxonDao.countTaxons(taxonomy);
Set<String> vernacularNamesLanguageCodes = new HashSet<String>();
List<TaxonSummary> items = new ArrayList<TaxonSummary>();
TaxonomyDefinition taxonDefinition = survey.getReferenceDataSchema().getTaxonomyDefinition(taxonomyName);
if (totalCount > 0) {
List<Taxon> taxons = taxonDao.loadTaxons(taxonomy, offset, maxRecords);
for (Taxon taxon : taxons) {
List<TaxonVernacularName> vernacularNames = taxonVernacularNameDao.findByTaxon(taxon.getSystemId());
TaxonSummary summary = new TaxonSummary(taxonDefinition, taxon, vernacularNames, null);
List<String> itemVernLangCodes = summary.getVernacularLanguages();
vernacularNamesLanguageCodes.addAll(itemVernLangCodes);
items.add(summary);
}
}
List<String> sortedVernacularNamesLanguageCodes = new ArrayList<String>(vernacularNamesLanguageCodes);
Collections.sort(sortedVernacularNamesLanguageCodes);
List<String> infoAttributeNames = taxonDefinition.getAttributeNames();
return new TaxonSummaries(totalCount, items, sortedVernacularNamesLanguageCodes, infoAttributeNames);
}
use of org.openforis.collect.metamodel.TaxonSummaries in project collect by openforis.
the class SpeciesManager method loadFullTaxonSummaries.
public TaxonSummaries loadFullTaxonSummaries(CollectTaxonomy taxonomy) {
TaxonTree tree = loadTaxonTree(taxonomy);
List<TaxonSummary> summaries = tree.toSummaries(TaxonRank.FAMILY, true);
List<String> sortedVernacularNamesLanguageCodes = new ArrayList<String>(tree.getVernacularLanguageCodes());
Collections.sort(sortedVernacularNamesLanguageCodes);
List<String> infoAttributeNames = taxonomy.getSurvey().getReferenceDataSchema().getTaxonomyDefinition(taxonomy.getName()).getAttributeNames();
return new TaxonSummaries(summaries.size(), summaries, sortedVernacularNamesLanguageCodes, infoAttributeNames);
}
Aggregations