Search in sources :

Example 16 with CollectTaxonomy

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

the class SpeciesManager method copyTaxonomy.

@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void copyTaxonomy(CollectSurvey fromSurvey, CollectSurvey toSurvey) {
    List<CollectTaxonomy> taxonomies = taxonomyDao.loadAllBySurvey(fromSurvey);
    for (CollectTaxonomy oldTaxonomy : taxonomies) {
        oldTaxonomy.setSurvey(fromSurvey);
        CollectTaxonomy newTaxonomy = new CollectTaxonomy(oldTaxonomy);
        newTaxonomy.setSurvey(toSurvey);
        taxonomyDao.insert(newTaxonomy);
        copyTaxons(oldTaxonomy, newTaxonomy);
    }
}
Also used : CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with CollectTaxonomy

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

the class SpeciesExportProcess method exportToCSV.

public void exportToCSV(OutputStream out, CollectSurvey survey, int taxonomyId) {
    CsvWriter writer = null;
    try {
        writer = new CsvWriter(out);
        CollectTaxonomy taxonomy = speciesManager.loadTaxonomyById(survey, taxonomyId);
        taxonomyName = taxonomy.getName();
        TaxonSummaries summaries = speciesManager.loadFullTaxonSummariesOld(taxonomy);
        ArrayList<String> colNames = new ArrayList<String>();
        colNames.add(SpeciesFileColumn.NO.getColumnName());
        colNames.add(SpeciesFileColumn.CODE.getColumnName());
        colNames.add(SpeciesFileColumn.FAMILY.getColumnName());
        colNames.add(SpeciesFileColumn.SCIENTIFIC_NAME.getColumnName());
        colNames.add(SpeciesFileColumn.SYNONYMS.getColumnName());
        List<String> vernacularNamesLangCodes = extractVernacularNameLanguageCodes(summaries);
        colNames.addAll(vernacularNamesLangCodes);
        List<String> infoAttributeNames = survey.getReferenceDataSchema().getTaxonomyDefinition(taxonomyName).getAttributeNames();
        colNames.addAll(infoAttributeNames);
        writer.writeHeaders(colNames);
        List<TaxonSummary> items = summaries.getItems();
        for (TaxonSummary item : items) {
            writeTaxonSummary(writer, vernacularNamesLangCodes, infoAttributeNames, item);
        }
    } catch (Exception e) {
        log.error(e);
    } finally {
        IOUtils.closeQuietly(writer);
    }
}
Also used : CsvWriter(org.openforis.commons.io.csv.CsvWriter) TaxonSummary(org.openforis.collect.metamodel.TaxonSummary) ArrayList(java.util.ArrayList) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) TaxonSummaries(org.openforis.collect.metamodel.TaxonSummaries)

Example 18 with CollectTaxonomy

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

the class SpeciesImportProcess method persistTaxa.

protected void persistTaxa() throws SurveyStoreException {
    saveSurvey();
    CollectTaxonomy taxonomy = speciesManager.loadTaxonomyById(survey, taxonomyId);
    speciesManager.insertTaxons(taxonomy, taxonTree, overwriteAll);
}
Also used : CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy)

Example 19 with CollectTaxonomy

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

the class SpeciesImportProcess method init.

@Override
public void init() {
    super.init();
    CollectTaxonomy taxonomy = speciesManager.loadTaxonomyById(survey, taxonomyId);
    taxonomyName = taxonomy.getName();
    lines = new ArrayList<SpeciesLine>();
    validateParameters();
}
Also used : CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy)

Example 20 with CollectTaxonomy

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

the class SpeciesBackupImportJobIntegrationTest method findTaxonByCode.

protected Taxon findTaxonByCode(String code) {
    CollectTaxonomy taxonomy = taxonomyDao.loadByName(survey, TEST_TAXONOMY_NAME);
    List<Taxon> results = taxonDao.findByCode(taxonomy, FAMILY, code, 10);
    assertNotNull(results);
    assertEquals(1, results.size());
    Taxon taxon = results.get(0);
    return taxon;
}
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