Search in sources :

Example 6 with TaxonSummary

use of org.openforis.collect.metamodel.TaxonSummary in project collect by openforis.

the class SpeciesManager method loadFullTaxonSummariesOld.

public TaxonSummaries loadFullTaxonSummariesOld(CollectTaxonomy taxonomy) {
    TaxonTree tree = loadTaxonTree(taxonomy);
    List<TaxonSummary> summaries = tree.toSummaries(TaxonRank.GENUS, false);
    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)

Example 7 with TaxonSummary

use of org.openforis.collect.metamodel.TaxonSummary in project collect by openforis.

the class SpeciesBackupExportTask method execute.

@Override
protected void execute() throws Throwable {
    CsvWriter writer = new CsvWriter(outputStream);
    CollectTaxonomy taxonomy = speciesManager.loadTaxonomyById(survey, taxonomyId);
    TaxonSummaries summaries = speciesManager.loadFullTaxonSummaries(taxonomy);
    List<String> vernacularNamesLangCodes = getNotEmptyValues(summaries.getVernacularNamesLanguageCodes());
    // consider Latin vernacular name as synonym
    vernacularNamesLangCodes.remove(LATIN_LANG_CODE);
    this.vernacularNamesLangCodes = vernacularNamesLangCodes;
    // write headers
    writeHeaders(writer);
    for (TaxonSummary item : summaries.getItems()) {
        writeTaxonSummary(writer, item);
    }
    writer.flush();
}
Also used : CsvWriter(org.openforis.commons.io.csv.CsvWriter) TaxonSummary(org.openforis.collect.metamodel.TaxonSummary) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) TaxonSummaries(org.openforis.collect.metamodel.TaxonSummaries)

Example 8 with TaxonSummary

use of org.openforis.collect.metamodel.TaxonSummary in project collect by openforis.

the class SpeciesExportTask method execute.

@Override
protected void execute() throws Throwable {
    CsvWriter writer = new CsvWriter(outputStream);
    CollectTaxonomy taxonomy = speciesManager.loadTaxonomyById(survey, taxonomyId);
    TaxonSummaries summaries = speciesManager.loadFullTaxonSummariesOld(taxonomy);
    List<String> vernacularNamesLangCodes = getNotEmptyValues(summaries.getVernacularNamesLanguageCodes());
    // consider Latin vernacular name as synonym
    vernacularNamesLangCodes.remove(LATIN_LANG_CODE);
    // write headers
    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());
    colNames.addAll(vernacularNamesLangCodes);
    colNames.addAll(infoAttributeNames);
    writer.writeHeaders(colNames);
    for (TaxonSummary item : summaries.getItems()) {
        writeTaxonSummary(writer, vernacularNamesLangCodes, infoAttributeNames, item);
    }
    writer.flush();
}
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)

Aggregations

TaxonSummary (org.openforis.collect.metamodel.TaxonSummary)8 TaxonSummaries (org.openforis.collect.metamodel.TaxonSummaries)7 ArrayList (java.util.ArrayList)6 CollectTaxonomy (org.openforis.collect.model.CollectTaxonomy)5 CsvWriter (org.openforis.commons.io.csv.CsvWriter)3 TaxonTree (org.openforis.collect.model.TaxonTree)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Test (org.junit.Test)1 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)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