use of org.hisp.dhis.dxf2.common.ImportSummary in project dhis2-core by dhis2.
the class MetadataSyncPreProcessor method handleAggregateDataPush.
public ImportSummary handleAggregateDataPush(MetadataRetryContext context) {
log.debug("Entering data push");
ImportSummary importSummary = null;
AvailabilityStatus remoteServerAvailable = synchronizationManager.isRemoteServerAvailable();
if (!(remoteServerAvailable.isAvailable())) {
String message = remoteServerAvailable.getMessage();
log.error(message);
context.updateRetryContext(MetadataSyncTask.DATA_PUSH_SUMMARY, remoteServerAvailable.getMessage(), null, null);
throw new MetadataSyncServiceException(message);
}
try {
importSummary = synchronizationManager.executeDataPush();
handleAggregateImportSummary(importSummary, context);
} catch (Exception ex) {
log.error("Exception happened while trying to do data push " + ex.getMessage(), ex);
if (ex instanceof MetadataSyncServiceException) {
throw (MetadataSyncServiceException) ex;
}
context.updateRetryContext(MetadataSyncTask.DATA_PUSH_SUMMARY, ex.getMessage(), null, null);
throw new MetadataSyncServiceException(ex.getMessage(), ex);
}
log.debug("Exiting data push");
return importSummary;
}
use of org.hisp.dhis.dxf2.common.ImportSummary in project dhis2-core by dhis2.
the class MetadataSyncPreProcessor method handleEventImportSummary.
private void handleEventImportSummary(ImportSummaries importSummary, MetadataRetryContext context) {
if (importSummary != null) {
boolean isImportError = false;
StringBuilder summaryDescription = new StringBuilder();
for (ImportSummary summary : importSummary.getImportSummaries()) {
if (ImportStatus.ERROR.equals(summary.getStatus())) {
isImportError = true;
summaryDescription.append(summary.getDescription());
summaryDescription.append("\n");
}
}
if (isImportError) {
log.error("Import Summary description: " + summaryDescription.toString());
context.updateRetryContext(MetadataSyncTask.EVENT_PUSH_SUMMARY, summaryDescription.toString(), null, null);
throw new MetadataSyncServiceException("The Event Data Push was not successful. ");
}
}
}
use of org.hisp.dhis.dxf2.common.ImportSummary in project dhis2-core by dhis2.
the class TrackedEntityInstanceServiceTest method testSavePerson.
@Test
@Ignore
public void testSavePerson() {
TrackedEntityInstance trackedEntityInstance = new TrackedEntityInstance();
// person.setName( "NAME" );
trackedEntityInstance.setOrgUnit(organisationUnitA.getUid());
ImportSummary importSummary = trackedEntityInstanceService.addTrackedEntityInstance(trackedEntityInstance, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
// assertEquals( "NAME", personService.getTrackedEntityInstance( importSummary.getReference() ).getName() );
}
use of org.hisp.dhis.dxf2.common.ImportSummary in project dhis2-core by dhis2.
the class TrackedEntityInstanceServiceTest method testUpdatePerson.
@Test
@Ignore
public void testUpdatePerson() {
TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance(maleA.getUid());
// person.setName( "UPDATED_NAME" );
ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstance(trackedEntityInstance, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
// assertEquals( "UPDATED_NAME", personService.getTrackedEntityInstance( maleA.getUid() ).getName() );
}
use of org.hisp.dhis.dxf2.common.ImportSummary in project dhis2-core by dhis2.
the class RegistrationSingleEventServiceTest method testSavingMultipleEventsShouldOnlyUpdate.
@Test
@Ignore
public void testSavingMultipleEventsShouldOnlyUpdate() {
Enrollment enrollment = createEnrollment(programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
ImportSummary importSummary = enrollmentService.addEnrollment(enrollment, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
importSummary = eventService.addEvent(event, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
EventSearchParams params = new EventSearchParams();
params.setProgram(programA);
params.setOrgUnit(organisationUnitA);
params.setOrgUnitSelectionMode(OrganisationUnitSelectionMode.SELECTED);
assertEquals(1, eventService.getEvents(params).getEvents().size());
event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
importSummary = eventService.addEvent(event, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(1, eventService.getEvents(params).getEvents().size());
event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
importSummary = eventService.addEvent(event, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(1, eventService.getEvents(params).getEvents().size());
}
Aggregations