Search in sources :

Example 1 with Rr809Dn

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;
}
Also used : Response(gov.ca.cwds.rest.api.Response) FacilityInspectionDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionDTO) Rr809Dn(gov.ca.cwds.cals.persistence.model.fas.Rr809Dn) ArrayList(java.util.ArrayList) FacilityInspectionsDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO)

Example 2 with Rr809Dn

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;
}
Also used : Rr809Dn(gov.ca.cwds.cals.persistence.model.fas.Rr809Dn) NoResultException(javax.persistence.NoResultException) Session(org.hibernate.Session)

Example 3 with Rr809Dn

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);
}
Also used : Rr809Dn(gov.ca.cwds.cals.persistence.model.fas.Rr809Dn) FacilityInspectionParameterObject(gov.ca.cwds.cals.web.rest.parameter.FacilityInspectionParameterObject)

Example 4 with 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();
}
Also used : Rr809Dn(gov.ca.cwds.cals.persistence.model.fas.Rr809Dn) Session(org.hibernate.Session)

Aggregations

Rr809Dn (gov.ca.cwds.cals.persistence.model.fas.Rr809Dn)4 Session (org.hibernate.Session)2 FacilityInspectionDTO (gov.ca.cwds.cals.service.dto.FacilityInspectionDTO)1 FacilityInspectionsDTO (gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO)1 FacilityInspectionParameterObject (gov.ca.cwds.cals.web.rest.parameter.FacilityInspectionParameterObject)1 Response (gov.ca.cwds.rest.api.Response)1 ArrayList (java.util.ArrayList)1 NoResultException (javax.persistence.NoResultException)1