use of org.hisp.dhis.dxf2.importsummary.ImportSummary in project dhis2-core by dhis2.
the class DefaultDataValueSetService method saveDataValueSet.
@Override
public ImportSummary saveDataValueSet(InputStream in, ImportOptions importOptions, TaskId id) {
try {
in = StreamUtils.wrapAndCheckCompressionFormat(in);
DataValueSet dataValueSet = new StreamingXmlDataValueSet(XMLFactory.getXMLReader(in));
return saveDataValueSet(importOptions, id, dataValueSet);
} catch (Exception ex) {
log.error(DebugUtils.getStackTrace(ex));
notifier.notify(id, ERROR, "Process failed: " + ex.getMessage(), true);
return new ImportSummary(ImportStatus.ERROR, "The import process failed: " + ex.getMessage());
}
}
use of org.hisp.dhis.dxf2.importsummary.ImportSummary in project dhis2-core by dhis2.
the class DefaultDataValueSetService method handleComplete.
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private void handleComplete(DataSet dataSet, Date completeDate, Period period, OrganisationUnit orgUnit, DataElementCategoryOptionCombo attributeOptionCombo, ImportSummary summary) {
if (orgUnit == null) {
summary.getConflicts().add(new ImportConflict(OrganisationUnit.class.getSimpleName(), ERROR_OBJECT_NEEDED_TO_COMPLETE));
return;
}
if (period == null) {
summary.getConflicts().add(new ImportConflict(Period.class.getSimpleName(), ERROR_OBJECT_NEEDED_TO_COMPLETE));
return;
}
period = periodService.reloadPeriod(period);
CompleteDataSetRegistration completeAlready = registrationService.getCompleteDataSetRegistration(dataSet, period, orgUnit, attributeOptionCombo);
String username = currentUserService.getCurrentUsername();
if (completeAlready != null) {
completeAlready.setStoredBy(username);
completeAlready.setDate(completeDate);
registrationService.updateCompleteDataSetRegistration(completeAlready);
} else {
CompleteDataSetRegistration registration = new CompleteDataSetRegistration(dataSet, period, orgUnit, attributeOptionCombo, completeDate, username);
registrationService.saveCompleteDataSetRegistration(registration);
}
summary.setDataSetComplete(DateUtils.getMediumDateString(completeDate));
}
use of org.hisp.dhis.dxf2.importsummary.ImportSummary in project dhis2-core by dhis2.
the class DefaultCompleteDataSetRegistrationExchangeService method saveCompleteDataSetRegistrationsJson.
@Override
public ImportSummary saveCompleteDataSetRegistrationsJson(InputStream in, ImportOptions importOptions, TaskId taskId) {
try {
in = StreamUtils.wrapAndCheckCompressionFormat(in);
CompleteDataSetRegistrations completeDataSetRegistrations = DefaultRenderService.getJsonMapper().readValue(in, CompleteDataSetRegistrations.class);
return saveCompleteDataSetRegistrations(importOptions, taskId, completeDataSetRegistrations);
} catch (Exception ex) {
return handleImportError(taskId, ex);
}
}
use of org.hisp.dhis.dxf2.importsummary.ImportSummary in project dhis2-core by dhis2.
the class DefaultCompleteDataSetRegistrationExchangeService method saveCompleteDataSetRegistrationsXml.
@Override
public ImportSummary saveCompleteDataSetRegistrationsXml(InputStream in, ImportOptions importOptions, TaskId taskId) {
try {
in = StreamUtils.wrapAndCheckCompressionFormat(in);
CompleteDataSetRegistrations completeDataSetRegistrations = new StreamingXmlCompleteDataSetRegistrations(XMLFactory.getXMLReader(in));
return saveCompleteDataSetRegistrations(importOptions, taskId, completeDataSetRegistrations);
} catch (Exception ex) {
return handleImportError(taskId, ex);
}
}
use of org.hisp.dhis.dxf2.importsummary.ImportSummary in project dhis2-core by dhis2.
the class DefaultCompleteDataSetRegistrationExchangeService method finalizeSummary.
private static void finalizeSummary(ImportSummary summary, int totalCount, int importCount, int updateCount, int deleteCount) {
int ignores = totalCount - importCount - updateCount - deleteCount;
summary.setImportCount(new ImportCount(importCount, updateCount, ignores, deleteCount));
summary.setStatus(ImportStatus.SUCCESS);
summary.setDescription("Import process completed successfully");
}
Aggregations