use of org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportStatus in project collect by openforis.
the class SamplingDesignImportProcessIntegrationTest method testImport.
@Test
public void testImport() throws Exception {
SamplingDesignImportProcess process = importCSVFile(VALID_TEST_CSV);
SamplingDesignImportStatus status = process.getStatus();
assertTrue(status.isComplete());
assertTrue(status.getSkippedRows().isEmpty());
assertEquals(27, status.getProcessed());
SamplingDesignSummaries samplingDesignSummaries = samplingDesignManager.loadBySurvey(survey.getId(), 0, 30);
assertNotNull(samplingDesignSummaries);
assertEquals(26, samplingDesignSummaries.getTotalCount());
List<SamplingDesignItem> items = samplingDesignSummaries.getRecords();
assertNotNull(findItem(items, -10000d, 100000d, "1_01", "1"));
assertNotNull(findItem(items, 200000d, -2000000d, "1_02", "1"));
assertNotNull(findItem(items, 806090d, 9320050d, "10_114", "7"));
assertNotNull(findItem(items, 805680d, 9305020d, "10_117", "6"));
}
use of org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportStatus in project collect by openforis.
the class SamplingDesignImportProcessIntegrationTest method testFlatImport.
@Test
public void testFlatImport() throws Exception {
SamplingDesignImportProcess process = importCSVFile(VALID_FLAT_TEST_CSV);
SamplingDesignImportStatus status = process.getStatus();
assertTrue(status.isComplete());
assertTrue(status.getSkippedRows().isEmpty());
SamplingDesignSummaries samplingDesignSummaries = samplingDesignManager.loadBySurvey(survey.getId(), 0, 30);
assertNotNull(samplingDesignSummaries);
assertEquals(6, samplingDesignSummaries.getTotalCount());
List<SamplingDesignItem> items = samplingDesignSummaries.getRecords();
{
SamplingDesignItem item = findItem(items, -10000d, 100000d, "1_01");
assertNotNull(item);
assertEquals(Arrays.asList("001", "002"), item.getInfoAttributes().subList(0, 2));
}
assertNotNull(findItem(items, 200000d, -2000000d, "1_02"));
assertNotNull(findItem(items, 806340d, 9320050d, "10_114"));
assertNotNull(findItem(items, 806680d, 9305020d, "10_117"));
assertNotNull(findItem(items, 80.1234d, -6.908d, "10_115"));
}
use of org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportStatus in project collect by openforis.
the class SamplingDesignImportProcessIntegrationTest method testInvalidData.
@Test
public void testInvalidData() throws Exception {
SamplingDesignImportProcess process = importCSVFile(INVALID_TEST_CSV);
SamplingDesignImportStatus status = process.getStatus();
assertTrue(status.isError());
List<ParsingError> errors = status.getErrors();
assertEquals(6, errors.size());
assertTrue(containsError(errors, 3, SamplingDesignFileColumn.LEVEL_2, ErrorType.DUPLICATE_VALUE));
assertTrue(containsError(errors, 4, SamplingDesignFileColumn.LEVEL_2, ErrorType.DUPLICATE_VALUE));
assertTrue(containsError(errors, 14, SamplingDesignFileColumn.LEVEL_2, ErrorType.EMPTY));
assertTrue(containsError(errors, 17, SamplingDesignFileColumn.LEVEL_1, ErrorType.EMPTY));
assertTrue(containsError(errors, 22, SamplingDesignFileColumn.X, ErrorType.EMPTY));
assertTrue(containsError(errors, 23, SamplingDesignFileColumn.Y, ErrorType.EMPTY));
}
use of org.openforis.collect.io.metadata.samplingdesign.SamplingDesignImportStatus in project collect by openforis.
the class SamplingDesignImportService method start.
@Secured("ROLE_ADMIN")
public SamplingDesignImportStatusProxy start(String tempFileName, int surveyId, boolean temporary, boolean overwriteAll) throws DataImportExeption, SurveyImportException {
if (importProcess == null || !importProcess.getStatus().isRunning()) {
File importFile = new File(tempFileName);
CollectSurvey survey = temporary ? surveyManager.loadSurvey(surveyId) : surveyManager.getById(surveyId);
importProcess = new SamplingDesignImportProcess(samplingDesignManager, surveyManager, survey, importFile, overwriteAll);
importProcess.init();
SamplingDesignImportStatus status = importProcess.getStatus();
if (status != null && !importProcess.getStatus().isError()) {
startProcessThread();
}
}
return getStatus();
}
Aggregations