Search in sources :

Example 21 with CollectTaxonomy

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

the class SpeciesBackupImportJobIntegrationTest method findByCode.

protected TaxonOccurrence findByCode(String code) {
    CollectTaxonomy taxonomy = speciesManager.loadTaxonomyByName(survey, TEST_TAXONOMY_NAME);
    TaxonSearchParameters searchParameters = new TaxonSearchParameters();
    searchParameters.setHighestRank(FAMILY);
    List<TaxonOccurrence> occurrences = speciesManager.findByCode(taxonomy, code, 10, searchParameters);
    assertNotNull(occurrences);
    assertEquals(1, occurrences.size());
    TaxonOccurrence occurrence = occurrences.get(0);
    return occurrence;
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) TaxonSearchParameters(org.openforis.collect.manager.TaxonSearchParameters)

Example 22 with CollectTaxonomy

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

the class SurveyManagerIntegrationTest method insertTestTaxonomy.

private void insertTestTaxonomy() {
    CollectTaxonomy taxonomy = new CollectTaxonomy();
    taxonomy.setName("tree");
    taxonomy.setSurvey(survey);
    speciesManager.save(taxonomy);
    Taxon taxon = new Taxon();
    taxon.setTaxonomyId(taxonomy.getId());
    taxon.setCode("ALB/GLA");
    taxon.setScientificName("Albizia glaberrima");
    taxon.setTaxonRank(TaxonRank.GENUS);
    speciesManager.save(taxon);
    {
        TaxonVernacularName vernacularName = new TaxonVernacularName();
        vernacularName.setTaxonSystemId(taxon.getSystemId());
        vernacularName.setVernacularName("Mgerenge");
        vernacularName.setLanguageCode("swh");
        speciesManager.save(vernacularName);
    }
    {
        TaxonVernacularName vernacularName = new TaxonVernacularName();
        vernacularName.setTaxonSystemId(taxon.getSystemId());
        vernacularName.setVernacularName("Mchani");
        vernacularName.setLanguageCode("swh");
        speciesManager.save(vernacularName);
    }
}
Also used : Taxon(org.openforis.idm.model.species.Taxon) TaxonVernacularName(org.openforis.idm.model.species.TaxonVernacularName) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy)

Example 23 with CollectTaxonomy

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

the class SurveyManagerIntegrationTest method publishSurveyTaxonomyTest.

@Test
public void publishSurveyTaxonomyTest() throws SurveyImportException {
    insertTestTaxonomy();
    CollectSurvey temporarySurvey = surveyManager.createTemporarySurveyFromPublished(survey.getUri(), adminUser);
    {
        CollectTaxonomy taxonomy = speciesManager.loadTaxonomyByName(temporarySurvey, "tree");
        assertNotNull(taxonomy);
        TaxonSummaries summaries = speciesManager.loadFullTaxonSummariesOld(taxonomy);
        assertEquals(1, summaries.getTotalCount());
        List<TaxonSummary> taxonSummaryList = summaries.getItems();
        {
            TaxonSummary taxonSummary = taxonSummaryList.get(0);
            assertEquals("Albizia glaberrima", taxonSummary.getScientificName());
            List<String> vernacularLanguages = taxonSummary.getVernacularLanguages();
            assertEquals(Arrays.asList("swh"), vernacularLanguages);
            List<String> vernacularNames = taxonSummary.getVernacularNames("swh");
            assertEquals(Arrays.asList("Mgerenge", "Mchani"), vernacularNames);
        }
    }
}
Also used : TaxonSummary(org.openforis.collect.metamodel.TaxonSummary) CodeList(org.openforis.idm.metamodel.CodeList) List(java.util.List) CollectSurvey(org.openforis.collect.model.CollectSurvey) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) TaxonSummaries(org.openforis.collect.metamodel.TaxonSummaries) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 24 with CollectTaxonomy

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

the class SpeciesDaoIntegrationTest method testInsertAndLoadTaxonomy.

private CollectTaxonomy testInsertAndLoadTaxonomy(String name) {
    CollectSurvey survey = createAndStoreSurvey();
    // Insert
    CollectTaxonomy t1 = new CollectTaxonomy();
    t1.setName(name);
    t1.setSurvey(survey);
    taxonomyDao.insert(t1);
    CollectTaxonomy t = t1;
    // Confirm saved
    CollectTaxonomy t2 = taxonomyDao.loadById(survey, t.getId());
    assertEquals(t.getId(), t2.getId());
    assertEquals(t.getName(), t2.getName());
    return t2;
}
Also used : CollectSurvey(org.openforis.collect.model.CollectSurvey) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy)

Example 25 with CollectTaxonomy

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

the class SpeciesDaoIntegrationTest method testFindCode.

private void testFindCode(String match, int maxResults, int expectedResults) {
    // Create taxonomy
    CollectTaxonomy taxonomy1 = testInsertAndLoadTaxonomy("it_bamboo");
    testUpdateAndLoadTaxonomy(taxonomy1, "it_trees");
    Taxon family1 = testInsertAndLoadTaxon(taxonomy1, -1, "JUGLANDACAE", "Juglandaceae", FAMILY, 9, null);
    Taxon genus1 = testInsertAndLoadTaxon(taxonomy1, -2, "JUG", "Juglans sp.", GENUS, 9, family1);
    testInsertAndLoadTaxon(taxonomy1, -3, "JUG/REG", "Juglans regia", SPECIES, 9, genus1);
    List<Taxon> results = taxonDao.findByCode(taxonomy1, FAMILY, match, maxResults);
    assertEquals(expectedResults, results.size());
    match = match.toUpperCase();
    for (Taxon taxon : results) {
        String code = taxon.getCode();
        code = (code == null) ? "" : code.toUpperCase();
        assertTrue(code.startsWith(match));
    }
}
Also used : Taxon(org.openforis.idm.model.species.Taxon) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy)

Aggregations

CollectTaxonomy (org.openforis.collect.model.CollectTaxonomy)43 Taxon (org.openforis.idm.model.species.Taxon)13 TaxonOccurrence (org.openforis.idm.model.TaxonOccurrence)8 Secured (org.springframework.security.access.annotation.Secured)8 Test (org.junit.Test)7 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)7 TaxonSummaries (org.openforis.collect.metamodel.TaxonSummaries)7 CollectSurvey (org.openforis.collect.model.CollectSurvey)7 ArrayList (java.util.ArrayList)5 TaxonSummary (org.openforis.collect.metamodel.TaxonSummary)5 TaxonVernacularName (org.openforis.idm.model.species.TaxonVernacularName)5 SpeciesImportProcess (org.openforis.collect.manager.speciesimport.SpeciesImportProcess)4 SpeciesImportStatus (org.openforis.collect.manager.speciesimport.SpeciesImportStatus)3 CsvWriter (org.openforis.commons.io.csv.CsvWriter)3 File (java.io.File)2 List (java.util.List)2 SpeciesBackupImportJob (org.openforis.collect.io.metadata.species.SpeciesBackupImportJob)2 TaxonomyDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.TaxonomyDefinition)2 Transactional (org.springframework.transaction.annotation.Transactional)2 HashSet (java.util.HashSet)1