Search in sources :

Example 6 with CollectTaxonomy

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());
    }
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) CollectRecord(org.openforis.collect.model.CollectRecord) TaxonAttribute(org.openforis.idm.model.TaxonAttribute) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) Secured(org.springframework.security.access.annotation.Secured)

Example 7 with CollectTaxonomy

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

Example 8 with CollectTaxonomy

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);
    // }
    }
}
Also used : SpeciesBackupExportTask(org.openforis.collect.io.metadata.species.SpeciesBackupExportTask) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy)

Example 9 with CollectTaxonomy

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;
}
Also used : CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) SpeciesBackupImportJob(org.openforis.collect.io.metadata.species.SpeciesBackupImportJob) File(java.io.File)

Example 10 with CollectTaxonomy

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

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