use of gov.ca.cwds.cals.persistence.model.fas.Rr809Dn in project cals-api by ca-cwds.
the class FacilityInspectionCollectionService method find.
@Override
public Response find(Serializable facilityId) {
Response res = null;
final FacilityInspectionsDTO dto = new FacilityInspectionsDTO();
List<Rr809Dn> deficiencies = inspectionDao.findDeficienciesByFacilityNumber(String.valueOf(facilityId));
final List<FacilityInspectionDTO> inspections = new ArrayList<>();
deficiencies.forEach(def -> inspections.add(facilityInspectionMapper.toFacilityInspectionDto(def)));
if (!inspections.isEmpty()) {
dto.setInspections(inspections);
res = dto;
}
return res;
}
use of gov.ca.cwds.cals.persistence.model.fas.Rr809Dn in project cals-api by ca-cwds.
the class InspectionDao method getDeficiencyByFacilityNumberAndId.
public Rr809Dn getDeficiencyByFacilityNumberAndId(Integer facilityNumber, String deficiencyId) {
Session currentSession = getSessionFactory().getCurrentSession();
Query<Rr809Dn> namedQuery = currentSession.createNamedQuery(Rr809Dn.NQ_FIND_BY_FACILITY_NUMBER_AND_DEFICIENCY_ID, Rr809Dn.class);
String facilityNumberText = formatFacilityNumber(facilityNumber);
namedQuery.setParameter("facilityNumberText", facilityNumberText);
namedQuery.setParameter("deficiencyId", deficiencyId);
Rr809Dn res = null;
try {
res = namedQuery.getSingleResult();
} catch (NoResultException e) {
LOG.warn("There is no result for facilityNumberText: {} and deficiencyId {} ", facilityNumberText, deficiencyId);
LOG.debug(e.getMessage(), e);
}
return res;
}
use of gov.ca.cwds.cals.persistence.model.fas.Rr809Dn in project cals-api by ca-cwds.
the class FacilityInspectionService method find.
@Override
public Response find(Serializable params) {
FacilityInspectionParameterObject paramsObj = (FacilityInspectionParameterObject) params;
Rr809Dn rr809Dn = inspectionDao.getDeficiencyByFacilityNumberAndId(paramsObj.getFacilityId(), paramsObj.getInspectionId());
return facilityInspectionMapper.toFacilityInspectionDto(rr809Dn);
}
use of gov.ca.cwds.cals.persistence.model.fas.Rr809Dn in project cals-api by ca-cwds.
the class InspectionDao method findDeficienciesByFacilityNumber.
public List<Rr809Dn> findDeficienciesByFacilityNumber(String facilityNumber) {
Session currentSession = getSessionFactory().getCurrentSession();
Query<Rr809Dn> namedQuery = currentSession.createNamedQuery(Rr809Dn.NQ_FIND_BY_FACILITY_NUMBER, Rr809Dn.class);
namedQuery.setParameter("facilityNumberText", formatFacilityNumber(Integer.valueOf(facilityNumber)));
return namedQuery.list();
}
Aggregations