use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class MetadataImportServiceTest method testCorrectStatusOnImportErrorsATOMIC.
@Test
public void testCorrectStatusOnImportErrorsATOMIC() throws IOException {
createUserAndInjectSecurityContext(true);
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/dataset_with_sections.json").getInputStream(), RenderFormat.JSON);
MetadataImportParams params = new MetadataImportParams();
params.setImportMode(ObjectBundleMode.COMMIT);
params.setImportStrategy(ImportStrategy.CREATE);
params.setObjects(metadata);
ImportReport report = importService.importMetadata(params);
assertEquals(Status.ERROR, report.getStatus());
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class MetadataImportServiceTest method testCorrectStatusOnImportNoErrors.
@Test
public void testCorrectStatusOnImportNoErrors() throws IOException {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/dataset_with_sections.json").getInputStream(), RenderFormat.JSON);
MetadataImportParams params = new MetadataImportParams();
params.setImportMode(ObjectBundleMode.COMMIT);
params.setImportStrategy(ImportStrategy.CREATE);
params.setObjects(metadata);
ImportReport report = importService.importMetadata(params);
assertEquals(Status.OK, report.getStatus());
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class WebMessageUtils method importReport.
public static WebMessage importReport(ImportReport importReport) {
WebMessage webMessage = new WebMessage();
webMessage.setResponse(new ImportReportWebMessageResponse(importReport));
webMessage.setStatus(importReport.getStatus());
if (webMessage.getStatus() != Status.OK) {
webMessage.setMessage("One more more errors occurred, please see full details in import report.");
webMessage.setStatus(Status.WARNING);
webMessage.setHttpStatus(HttpStatus.CONFLICT);
}
return webMessage;
}
Aggregations