Search in sources :

Example 1 with ExpectedException

use of gov.ca.cwds.rest.exception.ExpectedException in project cals-api by ca-cwds.

the class AbstractRFAInternalEntityService method update.

@Override
public T update(Long applicationId, T request) {
    RFA1aForm form = applicationDao.find(applicationId);
    if (form == null) {
        throw new ExpectedException(Constants.ExpectedExceptionMessages.RFA_1A_APPLICATION_NOT_FOUND_BY_ID, NOT_FOUND);
    }
    form.setUpdateDateTime(LocalDateTime.now());
    form.setUpdateUserId(PrincipalUtils.getStaffPersonId());
    configuration.putEntityToTheForm(form, request);
    RFA1aForm updatedForm = applicationDao.update(form);
    return configuration.getEntityFromTheForm(updatedForm);
}
Also used : RFA1aForm(gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1aForm) ExpectedException(gov.ca.cwds.rest.exception.ExpectedException)

Example 2 with ExpectedException

use of gov.ca.cwds.rest.exception.ExpectedException 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 ExpectedException

use of gov.ca.cwds.rest.exception.ExpectedException in project cals-api by ca-cwds.

the class RFA1bService method create.

@Override
public RFA1bFormDTO create(RFAExternalEntityUpdateParameterObject<RFA1bFormDTO> request) {
    RFA1bFormDTO rfa1bFormDTO = find(request);
    if (rfa1bFormDTO != null) {
        throw new ExpectedException(Constants.ExpectedExceptionMessages.RFA_1B_FORM_ALREADY_EXISTS, BAD_REQUEST);
    }
    RFA1bForm rfa1bForm = composeEntity(request);
    RFA1bDao dao = (RFA1bDao) getDao();
    if (request instanceof RFAApplicantAwareEntityUpdateParams) {
        RFAApplicantAwareEntityUpdateParams params = (RFAApplicantAwareEntityUpdateParams) request;
        rfa1bForm = dao.createForApplicant(rfa1bForm, params.getApplicantId());
    } else if (request instanceof RFAOtherAdultAwareEntityUpdateParams) {
        RFAOtherAdultAwareEntityUpdateParams params = (RFAOtherAdultAwareEntityUpdateParams) request;
        rfa1bForm = dao.createForOtherAdult(rfa1bForm, params.getOtherAdultId());
    }
    return extractDTO(rfa1bForm);
}
Also used : RFAApplicantAwareEntityUpdateParams(gov.ca.cwds.cals.web.rest.parameter.RFAApplicantAwareEntityUpdateParams) RFAOtherAdultAwareEntityUpdateParams(gov.ca.cwds.cals.web.rest.parameter.RFAOtherAdultAwareEntityUpdateParams) RFA1bFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1bFormDTO) RFA1bForm(gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1bForm) ExpectedException(gov.ca.cwds.rest.exception.ExpectedException) RFA1bDao(gov.ca.cwds.cals.persistence.dao.calsns.RFA1bDao)

Aggregations

ExpectedException (gov.ca.cwds.rest.exception.ExpectedException)3 RFA1bDao (gov.ca.cwds.cals.persistence.dao.calsns.RFA1bDao)1 RFA1aForm (gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1aForm)1 RFA1bForm (gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1bForm)1 ComplaintReportLic802 (gov.ca.cwds.cals.persistence.model.fas.ComplaintReportLic802)1 RFA1bFormDTO (gov.ca.cwds.cals.service.dto.rfa.RFA1bFormDTO)1 FacilityComplaintParameterObject (gov.ca.cwds.cals.web.rest.parameter.FacilityComplaintParameterObject)1 RFAApplicantAwareEntityUpdateParams (gov.ca.cwds.cals.web.rest.parameter.RFAApplicantAwareEntityUpdateParams)1 RFAOtherAdultAwareEntityUpdateParams (gov.ca.cwds.cals.web.rest.parameter.RFAOtherAdultAwareEntityUpdateParams)1