Search in sources :

Example 1 with RFA1aFormDTO

use of gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO in project cals-api by ca-cwds.

the class RFA1aFormService method submitApplication.

/**
 * There is using XA Transaction
 */
private void submitApplication(Long formId, RFAApplicationStatus newStatus) throws NotSupportedException, SystemException, DroolsException {
    RFA1aFormDTO expandedFormDTO = getExpandedFormDTO(formId);
    performSubmissionValidation(expandedFormDTO);
    // Start transaction here
    UserTransaction userTransaction = new UserTransactionImp();
    userTransaction.setTransactionTimeout(3600);
    userTransaction.begin();
    PlacementHome storedPlacementHome = null;
    try {
        storedPlacementHome = storePlaceMentHome(expandedFormDTO);
        updateFormAfterPlacementHomeCreation(formId, storedPlacementHome.getIdentifier(), newStatus);
        userTransaction.commit();
    } catch (BusinessValidationException e) {
        userTransaction.rollback();
        LOG.error("Can not create Placement Home because of BusinessValidationException", e);
        throw e;
    } catch (UnauthorizedException e) {
        userTransaction.rollback();
        LOG.error("Can not create Placement Home because of UnauthorizedException", e);
        throw e;
    } catch (Exception e) {
        try {
            userTransaction.rollback();
        } catch (Exception re) {
            LOG.warn(re.getMessage(), re);
        }
        StringBuilder sb = new StringBuilder();
        sb.append(e.getMessage());
        sb.append('\n');
        Throwable cause = e.getCause();
        while (cause != null) {
            sb.append(" Cause: ");
            sb.append(cause.getMessage());
            sb.append('\n');
            cause = cause.getCause();
        }
        LOG.error("Can not create Placement Home: \n", e);
        throw new SystemException(sb.toString());
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) SystemException(javax.transaction.SystemException) PlacementHome(gov.ca.cwds.data.legacy.cms.entity.PlacementHome) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) BusinessValidationException(gov.ca.cwds.rest.exception.BusinessValidationException) UnauthorizedException(org.apache.shiro.authz.UnauthorizedException) UserTransactionImp(com.atomikos.icatch.jta.UserTransactionImp) DataAccessServicesException(gov.ca.cwds.cms.data.access.service.DataAccessServicesException) ExpectedException(gov.ca.cwds.rest.exception.ExpectedException) NotSupportedException(javax.transaction.NotSupportedException) DroolsException(gov.ca.cwds.drools.DroolsException) ConstraintViolationException(javax.validation.ConstraintViolationException) UnauthorizedException(org.apache.shiro.authz.UnauthorizedException) SystemException(javax.transaction.SystemException) BusinessValidationException(gov.ca.cwds.rest.exception.BusinessValidationException)

Example 2 with RFA1aFormDTO

use of gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO in project cals-api by ca-cwds.

the class RFA1aFormService method find.

@UnitOfWork(CALSNS)
@Override
public RFA1aFormDTO find(RFA1aFormsParameterObject parameterObject) {
    RFA1aForm form = rfa1AFormsDao.find(parameterObject.getFormId());
    RFA1aFormDTO formDTO;
    if (parameterObject.isExpanded()) {
        formDTO = rfa1aFomMapper.toExpandedRFA1aFormDTO(form);
    } else {
        formDTO = rfa1aFomMapper.toRFA1aFormDTO(form);
    }
    return formDTO;
}
Also used : RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) RFA1aForm(gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1aForm) UnitOfWork(io.dropwizard.hibernate.UnitOfWork)

Example 3 with RFA1aFormDTO

use of gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO in project cals-api by ca-cwds.

the class RFA1aPDFGenerationService method generatePDF.

public String generatePDF(Long formId) {
    String docId = null;
    RFA1aFormDTO rfa1aFormDTO = rfa1aFormService.find(new RFA1aFormsParameterObject(formId, true));
    if (rfa1aFormDTO != null) {
        docId = generatePDF(rfa1aFormDTO);
    }
    return docId;
}
Also used : RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) RFA1aFormsParameterObject(gov.ca.cwds.cals.web.rest.parameter.RFA1aFormsParameterObject)

Example 4 with RFA1aFormDTO

use of gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO in project cals-api by ca-cwds.

the class RFA1aFormsResource method createApplicationForm.

// @UnitOfWork(CALSNS)
@POST
@Timed
@ApiResponses(value = { @ApiResponse(code = 201, message = "Created"), @ApiResponse(code = 401, message = "Not Authorized"), @ApiResponse(code = 406, message = "Accept Header not supported") })
@ApiOperation(value = "Creates and returns RFA 1A Form", response = RFA1aFormDTO.class)
public Response createApplicationForm(@ApiParam(name = "application", value = "The RFA-1A Application object") @Valid RFA1aFormDTO application) {
    // TODO: remove this temporary fix to support older versions of CALS DS
    if (application == null) {
        application = new RFA1aFormDTO();
        application.setInitialApplication(Boolean.TRUE);
    }
    return resourceDelegate.create(application);
}
Also used : RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 5 with RFA1aFormDTO

use of gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO in project cals-api by ca-cwds.

the class RFA1aCornerCasesSubmitApplicationTest method unChangedSubmitStatusTest.

@Test
public void unChangedSubmitStatusTest() throws Exception {
    if (TestModeUtils.isIntegrationTestsMode()) {
        return;
    }
    RFA1aFormDTO form = formAHelper.createRFA1aForm();
    applicantHelper.postApplicant(form.getId(), applicantHelper.getValidApplicant());
    residenceHelper.putResidence(form.getId(), residenceHelper.getResidenceDTO());
    Response response = statusHelper.submitApplication(form.getId(), FIXTURE_PATH_TO_PRINCIPAL);
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    statusHelper.assertSubmitted(form.getId());
    response = statusHelper.submitApplication(form.getId(), FIXTURE_PATH_TO_PRINCIPAL);
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    statusHelper.assertSubmitted(form.getId());
}
Also used : Response(javax.ws.rs.core.Response) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) Test(org.junit.Test)

Aggregations

RFA1aFormDTO (gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO)59 Test (org.junit.Test)37 ApplicantDTO (gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO)30 WebTarget (javax.ws.rs.client.WebTarget)19 IssueDetails (gov.ca.cwds.rest.exception.IssueDetails)15 Response (javax.ws.rs.core.Response)15 BaseExceptionResponse (gov.ca.cwds.rest.exception.BaseExceptionResponse)12 HashMap (java.util.HashMap)12 MinorChildDTO (gov.ca.cwds.cals.service.dto.rfa.MinorChildDTO)11 ClientErrorException (javax.ws.rs.ClientErrorException)11 Map (java.util.Map)10 Set (java.util.Set)10 StateType (gov.ca.cwds.cals.persistence.model.calsns.dictionaries.StateType)7 ResidenceDTO (gov.ca.cwds.cals.service.dto.rfa.ResidenceDTO)7 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)4 REQUIRED_APPLICANT_DATE_OF_BIRTH (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_DATE_OF_BIRTH)4 REQUIRED_APPLICANT_DRIVER_LICENSE_NUMBER (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_DRIVER_LICENSE_NUMBER)4 REQUIRED_APPLICANT_DRIVER_LICENSE_STATE (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_DRIVER_LICENSE_STATE)4 REQUIRED_APPLICANT_OTHER_NAMES_FIRST_NAME (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_OTHER_NAMES_FIRST_NAME)4 REQUIRED_APPLICANT_OTHER_NAMES_LAST_NAME (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_OTHER_NAMES_LAST_NAME)4