Search in sources :

Example 1 with RFA1bForm

use of gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1bForm in project cals-api by ca-cwds.

the class RFA1bDao method createForOtherAdult.

public RFA1bForm createForOtherAdult(RFA1bForm dto, Long otherAdultId) {
    RFA1bForm rfa1bFormEntity = super.create(dto);
    RFA1aOtherAdult otherAdult = otherAdultDao.find(otherAdultId);
    otherAdult.setRfa1bForm(rfa1bFormEntity);
    otherAdultDao.update(otherAdult);
    return rfa1bFormEntity;
}
Also used : RFA1bForm(gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1bForm) RFA1aOtherAdult(gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1aOtherAdult)

Example 2 with RFA1bForm

use of gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1bForm in project cals-api by ca-cwds.

the class RFA1bDao method delete.

@Override
public RFA1bForm delete(Serializable id) {
    RFA1bForm entity = this.find(id);
    if (entity != null) {
        Optional.ofNullable(entity.getApplicant()).ifPresent(applicant -> {
            applicant.setRFA1bForm(null);
            applicantDao.update(applicant);
        });
        Optional.ofNullable(entity.getOtherAdult()).ifPresent(otherAdult -> {
            otherAdult.setRfa1bForm(null);
            otherAdultDao.update(otherAdult);
        });
        this.currentSession().delete(entity);
    }
    return entity;
}
Also used : RFA1bForm(gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1bForm)

Example 3 with RFA1bForm

use of gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1bForm in project cals-api by ca-cwds.

the class RFA1bDao method createForApplicant.

public RFA1bForm createForApplicant(RFA1bForm dto, Long applicantId) {
    RFA1bForm rfa1bFormEntity = super.create(dto);
    RFA1aApplicant rfa1aApplicant = applicantDao.find(applicantId);
    rfa1aApplicant.setRFA1bForm(rfa1bFormEntity);
    applicantDao.update(rfa1aApplicant);
    return rfa1bFormEntity;
}
Also used : RFA1bForm(gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1bForm) RFA1aApplicant(gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1aApplicant)

Example 4 with RFA1bForm

use of gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1bForm 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

RFA1bForm (gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1bForm)4 RFA1bDao (gov.ca.cwds.cals.persistence.dao.calsns.RFA1bDao)1 RFA1aApplicant (gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1aApplicant)1 RFA1aOtherAdult (gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1aOtherAdult)1 RFA1bFormDTO (gov.ca.cwds.cals.service.dto.rfa.RFA1bFormDTO)1 RFAApplicantAwareEntityUpdateParams (gov.ca.cwds.cals.web.rest.parameter.RFAApplicantAwareEntityUpdateParams)1 RFAOtherAdultAwareEntityUpdateParams (gov.ca.cwds.cals.web.rest.parameter.RFAOtherAdultAwareEntityUpdateParams)1 ExpectedException (gov.ca.cwds.rest.exception.ExpectedException)1