use of org.hisp.dhis.tracker.report.TrackerTypeReport in project dhis2-core by dhis2.
the class DefaultTrackerObjectsDeletionService method deleteEvents.
@Override
public TrackerTypeReport deleteEvents(TrackerBundle bundle) {
TrackerTypeReport typeReport = new TrackerTypeReport(TrackerType.EVENT);
List<Event> events = bundle.getEvents();
for (int idx = 0; idx < events.size(); idx++) {
String uid = events.get(idx).getEvent();
TrackerObjectReport objectReport = new TrackerObjectReport(TrackerType.EVENT, uid, idx);
ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(uid);
ProgramInstance programInstance = programStageInstance.getProgramInstance();
programStageInstanceService.deleteProgramStageInstance(programStageInstance);
if (programStageInstance.getProgramStage().getProgram().isRegistration()) {
teiService.updateTrackedEntityInstance(programStageInstance.getProgramInstance().getEntityInstance());
programInstance.getProgramStageInstances().remove(programStageInstance);
programInstanceService.updateProgramInstance(programInstance);
}
typeReport.getStats().incDeleted();
typeReport.addObjectReport(objectReport);
}
return typeReport;
}
use of org.hisp.dhis.tracker.report.TrackerTypeReport in project dhis2-core by dhis2.
the class DefaultTrackerObjectsDeletionService method deleteRelationShips.
@Override
public TrackerTypeReport deleteRelationShips(TrackerBundle bundle) {
TrackerTypeReport typeReport = new TrackerTypeReport(TrackerType.RELATIONSHIP);
List<Relationship> relationships = bundle.getRelationships();
for (int idx = 0; idx < relationships.size(); idx++) {
String uid = relationships.get(idx).getRelationship();
TrackerObjectReport objectReport = new TrackerObjectReport(TrackerType.RELATIONSHIP, uid, idx);
org.hisp.dhis.relationship.Relationship relationship = relationshipService.getRelationship(uid);
relationshipService.deleteRelationship(relationship);
typeReport.getStats().incDeleted();
typeReport.addObjectReport(objectReport);
}
return typeReport;
}
Aggregations