Esempio n. 1
0
 public List<Facility> getUserSupervisedFacilities(Long userId, Long programId, Right... rights) {
   List<SupervisoryNode> supervisoryNodes =
       supervisoryNodeService.getAllSupervisoryNodesInHierarchyBy(userId, programId, rights);
   List<RequisitionGroup> requisitionGroups =
       requisitionGroupService.getRequisitionGroupsBy(supervisoryNodes);
   return facilityRepository.getFacilitiesBy(programId, requisitionGroups);
 }
Esempio n. 2
0
  public List<Facility> getForUserAndRights(Long userId, Right... rights) {
    List<SupervisoryNode> supervisoryNodesInHierarchy =
        supervisoryNodeService.getAllSupervisoryNodesInHierarchyBy(userId, rights);
    List<RequisitionGroup> requisitionGroups =
        requisitionGroupService.getRequisitionGroupsBy(supervisoryNodesInHierarchy);
    final Set<Facility> userFacilities =
        new HashSet<>(facilityRepository.getAllInRequisitionGroups(requisitionGroups));
    final Facility homeFacility = facilityRepository.getHomeFacilityForRights(userId, rights);

    if (homeFacility != null) userFacilities.add(homeFacility);

    return new ArrayList<>(userFacilities);
  }