use of org.hisp.dhis.trackedentity.TrackedEntityProgramOwnerOrgUnit in project dhis2-core by dhis2.
the class ProgramOwnerSupplier method preheatAdd.
@Override
public void preheatAdd(TrackerImportParams params, TrackerPreheat preheat) {
final Map<String, TrackedEntityInstance> preheatedTrackedEntities = preheat.getTrackedEntities().getOrDefault(TrackerIdScheme.UID, new HashMap<>());
final Map<String, ProgramInstance> preheatedEnrollments = preheat.getEnrollments().getOrDefault(TrackerIdScheme.UID, new HashMap<>());
Set<Long> teiIds = new HashSet<>();
params.getEnrollments().stream().forEach(en -> {
TrackedEntityInstance tei = preheatedTrackedEntities.get(en.getTrackedEntity());
if (tei != null) {
teiIds.add(tei.getId());
}
});
params.getEvents().stream().forEach(ev -> {
ProgramInstance pi = preheatedEnrollments.get(ev.getEnrollment());
if (pi != null && pi.getEntityInstance() != null) {
teiIds.add(pi.getEntityInstance().getId());
}
});
List<TrackedEntityProgramOwnerOrgUnit> tepos = trackedEntityProgramOwnerStore.getTrackedEntityProgramOwnerOrgUnits(teiIds);
tepos = tepos.stream().map(tepo -> new TrackedEntityProgramOwnerOrgUnit(tepo.getTrackedEntityInstanceId(), tepo.getProgramId(), OrganisationUnitMapper.INSTANCE.map(tepo.getOrganisationUnit()))).collect(Collectors.toList());
preheat.addProgramOwners(tepos);
}
use of org.hisp.dhis.trackedentity.TrackedEntityProgramOwnerOrgUnit in project dhis2-core by dhis2.
the class TrackerPreheat method addProgramOwner.
public void addProgramOwner(String teiUid, String programUid, OrganisationUnit orgUnit) {
if (!programOwner.containsKey(teiUid)) {
programOwner.put(teiUid, new HashMap<>());
}
if (!programOwner.get(teiUid).containsKey(programUid)) {
TrackedEntityProgramOwnerOrgUnit tepo = new TrackedEntityProgramOwnerOrgUnit(teiUid, programUid, orgUnit);
programOwner.get(teiUid).put(programUid, tepo);
}
}
Aggregations