use of org.openforis.collect.manager.speciesimport.SpeciesImportProcess in project collect by openforis.
the class SpeciesImportProcessIntegrationTest method testInvalidColumns.
@Test
public void testInvalidColumns() throws Exception {
SpeciesImportProcess process = importCSVFile(INVALID_MISSING_COLUMNS_TEST_CSV);
SpeciesImportStatus status = process.getStatus();
assertTrue(status.isError());
List<ParsingError> errors = status.getErrors();
assertEquals(1, errors.size());
ParsingError error = errors.get(0);
ErrorType errorType = error.getErrorType();
assertEquals(ErrorType.MISSING_REQUIRED_COLUMNS, errorType);
}
use of org.openforis.collect.manager.speciesimport.SpeciesImportProcess in project collect by openforis.
the class SpeciesImportProcessIntegrationTest method testSpeciesImport.
@Test
public void testSpeciesImport() throws Exception {
SpeciesImportProcess process = importCSVFile(VALID_TEST_CSV);
SpeciesImportStatus status = process.getStatus();
assertTrue(status.isComplete());
assertTrue(status.getSkippedRows().isEmpty());
{
String code = "OLE/CAP/macrocarpa";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(5, code, "Olea capensis subsp. macrocarpa");
expected.setTaxonRank(TaxonRank.SUBSPECIES);
assertEquals(expected, occurrence);
}
{
String code = "OLE/EUR/cuspidata";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(7, code, "Olea europaea subsp. cuspidata");
expected.setTaxonRank(TaxonRank.SUBSPECIES);
assertEquals(expected, occurrence);
}
{
String code = "AFZ/QUA";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(8, code, "Afzelia quanzensis");
expected.setTaxonRank(TaxonRank.SPECIES);
assertEquals(expected, occurrence);
}
{
String code = "ALB/GLA";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(11, code, "Albizia glaberrima");
expected.setTaxonRank(TaxonRank.SPECIES);
assertEquals(expected, occurrence);
}
{
String code = "ALB/SCH/amaniensis";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(12, code, "Albizia schimperiana var. amaniensis");
expected.setTaxonRank(TaxonRank.VARIETY);
assertEquals(expected, occurrence);
}
{
String code = "RUT/CIT/RETxPAR";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(15, code, "Citrus reticulata x Citrus paradisi");
expected.setTaxonRank(TaxonRank.SPECIES);
assertEquals(expected, occurrence);
}
{
String code = "IRI/IRI/GER";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(16, code, "Iris ×germanica");
expected.setTaxonRank(TaxonRank.SPECIES);
assertEquals(expected, occurrence);
}
{
String code = "IRI/IRI/BUI";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(17, code, "Iris x buiana");
expected.setTaxonRank(TaxonRank.SPECIES);
assertEquals(expected, occurrence);
}
}
use of org.openforis.collect.manager.speciesimport.SpeciesImportProcess in project collect by openforis.
the class SpeciesImportProcessIntegrationTest method testExport.
@Test
public void testExport() throws Exception {
SpeciesImportProcess process = importCSVFile(VALID_TEST_CSV);
SpeciesImportStatus status = process.getStatus();
assertTrue(status.isComplete());
CollectTaxonomy taxonomy = taxonomyDao.loadByName(survey, TEST_TAXONOMY_NAME);
TaxonSummaries summaries = speciesManager.loadFullTaxonSummariesOld(taxonomy);
assertNotNull(summaries);
}
use of org.openforis.collect.manager.speciesimport.SpeciesImportProcess in project collect by openforis.
the class SpeciesImportProcessIntegrationTest method testSpeciesImportWithExtraColumns.
@Test
public void testSpeciesImportWithExtraColumns() throws Exception {
SpeciesImportProcess process = importCSVFile(VALID_EXTRA_COLUMNS_TEST_CSV);
SpeciesImportStatus status = process.getStatus();
assertTrue(status.isComplete());
assertTrue(status.getSkippedRows().isEmpty());
{
String code = "AFZ/QUA";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(8, code, "Afzelia quanzensis");
expected.setInfoAttributes(Arrays.asList("TEST 3"));
expected.setTaxonRank(SPECIES);
assertEquals(expected, occurrence);
}
{
String code = "ALB/GLA";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(11, code, "Albizia glaberrima");
expected.setInfoAttributes(Arrays.asList((String) null));
expected.setTaxonRank(SPECIES);
assertEquals(expected, occurrence);
}
{
String code = "ALB/SCH/amaniensis";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(12, code, "Albizia schimperiana var. amaniensis");
expected.setInfoAttributes(Arrays.asList("TEST 1"));
expected.setTaxonRank(VARIETY);
assertEquals(expected, occurrence);
}
}
use of org.openforis.collect.manager.speciesimport.SpeciesImportProcess in project collect by openforis.
the class SpeciesImportService method start.
@Secured("ROLE_ADMIN")
public SpeciesImportStatusProxy start(String tempFileName, CSVFileOptions csvFileOptions, int surveyId, int taxonomyId, boolean overwriteAll) throws DataImportExeption {
if (importProcess == null || !importProcess.getStatus().isRunning()) {
CollectSurvey survey = sessionManager.getActiveDesignerSurvey();
if (survey.getId() != surveyId) {
throw new IllegalStateException("Error importing species list: different survey found in session");
}
File importFile = new File(tempFileName);
importProcess = new SpeciesImportProcess(surveyManager, speciesManager, survey, taxonomyId, importFile, csvFileOptions, overwriteAll);
importProcess.init();
SpeciesImportStatus status = importProcess.getStatus();
if (status != null && !importProcess.getStatus().isError()) {
startProcessThread();
}
}
return getStatus();
}
Aggregations