Search in sources :

Example 1 with TaxonSummaries

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);
}
Also used : SpeciesImportProcess(org.openforis.collect.manager.speciesimport.SpeciesImportProcess) SpeciesImportStatus(org.openforis.collect.manager.speciesimport.SpeciesImportStatus) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) TaxonSummaries(org.openforis.collect.metamodel.TaxonSummaries) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 2 with TaxonSummaries

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);
}
Also used : CollectSurvey(org.openforis.collect.model.CollectSurvey) TaxonSummaries(org.openforis.collect.metamodel.TaxonSummaries) TaxonSummariesProxy(org.openforis.collect.metamodel.proxy.TaxonSummariesProxy) Secured(org.springframework.security.access.annotation.Secured)

Example 3 with TaxonSummaries

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);
}
Also used : SpeciesBackupImportJob(org.openforis.collect.io.metadata.species.SpeciesBackupImportJob) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) TaxonSummaries(org.openforis.collect.metamodel.TaxonSummaries) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 4 with TaxonSummaries

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);
}
Also used : Taxon(org.openforis.idm.model.species.Taxon) ArrayList(java.util.ArrayList) TaxonSummaries(org.openforis.collect.metamodel.TaxonSummaries) TaxonomyDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.TaxonomyDefinition) TaxonSummary(org.openforis.collect.metamodel.TaxonSummary) TaxonVernacularName(org.openforis.idm.model.species.TaxonVernacularName) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) HashSet(java.util.HashSet)

Example 5 with TaxonSummaries

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);
}
Also used : TaxonSummary(org.openforis.collect.metamodel.TaxonSummary) ArrayList(java.util.ArrayList) TaxonTree(org.openforis.collect.model.TaxonTree) TaxonSummaries(org.openforis.collect.metamodel.TaxonSummaries)

Aggregations

TaxonSummaries (org.openforis.collect.metamodel.TaxonSummaries)10 TaxonSummary (org.openforis.collect.metamodel.TaxonSummary)7 CollectTaxonomy (org.openforis.collect.model.CollectTaxonomy)7 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)3 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)3 CsvWriter (org.openforis.commons.io.csv.CsvWriter)3 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 TaxonTree (org.openforis.collect.model.TaxonTree)2 HashSet (java.util.HashSet)1 List (java.util.List)1 SpeciesBackupImportJob (org.openforis.collect.io.metadata.species.SpeciesBackupImportJob)1 SpeciesImportProcess (org.openforis.collect.manager.speciesimport.SpeciesImportProcess)1 SpeciesImportStatus (org.openforis.collect.manager.speciesimport.SpeciesImportStatus)1 TaxonSummariesProxy (org.openforis.collect.metamodel.proxy.TaxonSummariesProxy)1 CodeList (org.openforis.idm.metamodel.CodeList)1 TaxonomyDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.TaxonomyDefinition)1 Taxon (org.openforis.idm.model.species.Taxon)1 TaxonVernacularName (org.openforis.idm.model.species.TaxonVernacularName)1 Secured (org.springframework.security.access.annotation.Secured)1