Search in sources :

Example 1 with ComplaintReportLic802

use of gov.ca.cwds.cals.persistence.model.fas.ComplaintReportLic802 in project cals-api by ca-cwds.

the class ComplaintReportLic802Dao method findComplaintsByFacilityNumber.

public List<ComplaintReportLic802> findComplaintsByFacilityNumber(String facilityNumber) {
    Session session = getSessionFactory().getCurrentSession();
    Class<ComplaintReportLic802> entityClass = getEntityClass();
    Query<ComplaintReportLic802> query = session.createNamedQuery(ComplaintReportLic802.FIND_COMPLAINTS_BY_FACILITY_ID, entityClass);
    query.setParameter(ComplaintReportLic802.PARAM_FACILITY_NUMBER, facilityNumber);
    return query.getResultList();
}
Also used : ComplaintReportLic802(gov.ca.cwds.cals.persistence.model.fas.ComplaintReportLic802) Session(org.hibernate.Session)

Example 2 with ComplaintReportLic802

use of gov.ca.cwds.cals.persistence.model.fas.ComplaintReportLic802 in project cals-api by ca-cwds.

the class ComplaintService method find.

@Override
public Response find(Serializable parametersObject) {
    FacilityComplaintParameterObject parameterObject;
    if (parametersObject instanceof FacilityComplaintParameterObject) {
        parameterObject = (FacilityComplaintParameterObject) parametersObject;
        ComplaintReportLic802 complaintReportLic802 = null;
        if (StringUtils.isNumeric(parameterObject.getFacilityId())) {
            complaintReportLic802 = complaintReportLic802Dao.findComplaintByFacilityIdAndComplaintId(parameterObject.getFacilityId(), parameterObject.getComplaintId());
        }
        if (complaintReportLic802 == null) {
            throw new ExpectedException(Constants.ExpectedExceptionMessages.COMPLAINT_NOT_FOUND_BY_ID, NOT_FOUND);
        } else {
            return complaintMapper.entityToDTO(complaintReportLic802);
        }
    }
    throw new IllegalStateException("FacilityComplaintParameterObject is expected here");
}
Also used : FacilityComplaintParameterObject(gov.ca.cwds.cals.web.rest.parameter.FacilityComplaintParameterObject) ExpectedException(gov.ca.cwds.rest.exception.ExpectedException) ComplaintReportLic802(gov.ca.cwds.cals.persistence.model.fas.ComplaintReportLic802)

Example 3 with ComplaintReportLic802

use of gov.ca.cwds.cals.persistence.model.fas.ComplaintReportLic802 in project cals-api by ca-cwds.

the class ComplaintsCollectionService method find.

@Override
public Response find(Serializable facilityNumber) {
    List<ComplaintReportLic802> facilityComplaints = complaintReportLic802Dao.findComplaintsByFacilityNumber(String.valueOf(facilityNumber));
    if (CollectionUtils.isEmpty(facilityComplaints)) {
        return null;
    }
    ComplaintsDTO complaintsDTO = new ComplaintsDTO();
    complaintsDTO.setComplaints(complaintMapper.complaintsListToComplaintsDTOList(facilityComplaints));
    return complaintsDTO;
}
Also used : ComplaintsDTO(gov.ca.cwds.cals.service.dto.ComplaintsDTO) ComplaintReportLic802(gov.ca.cwds.cals.persistence.model.fas.ComplaintReportLic802)

Example 4 with ComplaintReportLic802

use of gov.ca.cwds.cals.persistence.model.fas.ComplaintReportLic802 in project cals-api by ca-cwds.

the class ComplaintReportLic802Dao method findComplaintByFacilityIdAndComplaintId.

public ComplaintReportLic802 findComplaintByFacilityIdAndComplaintId(String facilityId, String complaintId) {
    Session session = getSessionFactory().getCurrentSession();
    Class<ComplaintReportLic802> entityClass = getEntityClass();
    Query<ComplaintReportLic802> query = session.createNamedQuery(ComplaintReportLic802.FIND_COMPLAINTS_BY_FACILITY_ID_AND_COMPLAINT_NUMBER, entityClass);
    query.setParameter(ComplaintReportLic802.PARAM_FACILITY_NUMBER, facilityId);
    query.setParameter(ComplaintReportLic802.PARAM_COMPLAINT_ID, complaintId);
    ComplaintReportLic802 res = null;
    try {
        res = query.getSingleResult();
    } catch (NoResultException e) {
        LOG.warn("There is no result for facilityNumber: {} and complaintId: {}", facilityId, complaintId);
        LOG.debug(e.getMessage(), e);
    }
    return res;
}
Also used : ComplaintReportLic802(gov.ca.cwds.cals.persistence.model.fas.ComplaintReportLic802) NoResultException(javax.persistence.NoResultException) Session(org.hibernate.Session)

Aggregations

ComplaintReportLic802 (gov.ca.cwds.cals.persistence.model.fas.ComplaintReportLic802)4 Session (org.hibernate.Session)2 ComplaintsDTO (gov.ca.cwds.cals.service.dto.ComplaintsDTO)1 FacilityComplaintParameterObject (gov.ca.cwds.cals.web.rest.parameter.FacilityComplaintParameterObject)1 ExpectedException (gov.ca.cwds.rest.exception.ExpectedException)1 NoResultException (javax.persistence.NoResultException)1