public List<Facility> searchFacilitiesByCodeOrNameAndVirtualFacilityFlag( String query, Boolean virtualFacility) { if (virtualFacility == null) { return facilityRepository.searchFacilitiesByCodeOrName(query); } return facilityRepository.searchFacilitiesByCodeOrNameAndVirtualFacilityFlag( query, virtualFacility); }
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); }
public void save(Facility newFacility) { newFacility.validate(); Facility storedFacility = facilityRepository.getById(newFacility.getId()); facilityRepository.save(newFacility); if (!newFacility.equals(storedFacility)) { notify(asList(newFacility)); if (canUpdateVirtualFacilities(newFacility, storedFacility)) { updateAndNotifyForVirtualFacilities(newFacility); } } }
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); }
public List<Facility> getAllForDeliveryZoneAndProgram(Long deliveryZoneId, Long programId) { List<Facility> facilities = facilityRepository.getAllInDeliveryZoneFor(deliveryZoneId, programId); for (Facility facility : facilities) { facility .getSupportedPrograms() .add( programSupportedService.getFilledByFacilityIdAndProgramId( facility.getId(), programId)); } return facilities; }
public Facility getOperativeFacilityByCode(String facilityCode) { Facility facility = getFacilityByCode(facilityCode); Facility parentFacility = null; if (facility.getVirtualFacility()) { parentFacility = facilityRepository.getById(facility.getParentFacilityId()); } if (!facility.isValid(parentFacility)) { throw new DataException("error.facility.inoperative"); } return facility; }
public Facility getFacilityByCode(String facilityCode) { Facility facility; if ((facility = facilityRepository.getByCode(facilityCode)) == null) { throw new DataException(ERROR_FACILITY_CODE_INVALID); } facility.setSupportedPrograms( (List<ProgramSupported>) select( facility.getSupportedPrograms(), new Predicate() { @Override public boolean evaluate(Object o) { return ((ProgramSupported) o).getActive(); } })); return facility; }
private void notify(List<Facility> facilities) { // TODO newFacility doesn't have modifiedDate populated for (Facility facility : facilities) { try { Facility parentFacility = facilityRepository.getById(facility.getParentFacilityId()); FacilityFeedDTO facilityFeedDTO = new FacilityFeedDTO(facility, parentFacility); String content = facilityFeedDTO.getSerializedContents(); eventService.notify( new Event( UUID.randomUUID().toString(), FACILITY_TITLE, DateTime.now(), "", content, FACILITY_CATEGORY)); } catch (URISyntaxException e) { logger.error("Unable to generate facility event", e); } } }
public List<FacilityOperator> getAllOperators() { return facilityRepository.getAllOperators(); }
public List<FacilityType> getAllTypes() { return facilityRepository.getAllTypes(); }
public List<Facility> getAll() { return facilityRepository.getAll(); }
public List<Facility> getAllParentsByModifiedDate(Date modifiedDate) { return facilityRepository.getAllParentsByModifiedDate(modifiedDate); }
public Facility getByCode(Facility facility) { return facilityRepository.getByCode(facility.getCode()); }
@Transactional public void updateEnabledAndActiveFor(Facility facility) { facility = facilityRepository.updateEnabledAndActiveFor(facility); notify(asList(facility)); }
public void updateAndNotifyForVirtualFacilities(Facility parentFacility) { facilityRepository.updateVirtualFacilities(parentFacility); notify(getChildFacilities(parentFacility)); }
public List<Facility> getEnabledWarehouses() { return facilityRepository.getEnabledWarehouses(); }
public Facility getFacilityWithReferenceDataForCode(String facilityCode) { Long facilityId = facilityRepository.getIdForCode(facilityCode); return getById(facilityId); }
public List<Facility> getAllByProgramSupportedModifiedDate(Date dateModified) { return facilityRepository.getAllByProgramSupportedModifiedDate(dateModified); }
public Facility getHomeFacility(Long userId) { return facilityRepository.getHomeFacility(userId); }
public Facility getById(Long id) { Facility facility = facilityRepository.getById(id); facility.setSupportedPrograms(programSupportedService.getAllByFacilityId(id)); return facility; }
public List<Facility> getChildFacilities(Facility facility) { return facilityRepository.getChildFacilities(facility); }
public List<Facility> getAllByRequisitionGroupMemberModifiedDate(Date modifiedDate) { return facilityRepository.getAllByRequisitionGroupMemberModifiedDate(modifiedDate); }
public FacilityType getFacilityTypeByCode(FacilityType facilityType) { return facilityRepository.getFacilityTypeByCode(facilityType); }