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);
}
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");
}
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);
}
Aggregations