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