Search in sources :

Example 16 with PlacementHome

use of gov.ca.cwds.data.legacy.cms.entity.PlacementHome 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 17 with PlacementHome

use of gov.ca.cwds.data.legacy.cms.entity.PlacementHome in project api-core by ca-cwds.

the class PlacementHomeDao method findByFacilityId.

public PlacementHome findByFacilityId(String facilityId) {
    Session session = getSessionFactory().getCurrentSession();
    Class<PlacementHome> entityClass = getEntityClass();
    Query<PlacementHome> query = session.createNamedQuery(entityClass.getSimpleName() + ".find", entityClass);
    query.setParameter("facilityId", facilityId);
    PlacementHome placementHome = null;
    try {
        placementHome = query.getSingleResult();
    } catch (NoResultException e) {
        LOG.warn("There is no result for facilityId = {}", facilityId);
        LOG.debug(e.getMessage(), e);
    }
    return placementHome;
}
Also used : PlacementHome(gov.ca.cwds.data.legacy.cms.entity.PlacementHome) NoResultException(javax.persistence.NoResultException) Session(org.hibernate.Session)

Example 18 with PlacementHome

use of gov.ca.cwds.data.legacy.cms.entity.PlacementHome in project api-core by ca-cwds.

the class PlacementHomeCreateAuthorizerTest method initPlacementHome.

private PlacementHome initPlacementHome() {
    final PlacementHome placementHome = new PlacementHome();
    placementHome.setIdentifier("id");
    placementHome.setLicensrCd("CT");
    placementHome.setFacilityType(Short.valueOf("1416"));
    return placementHome;
}
Also used : PlacementHome(gov.ca.cwds.data.legacy.cms.entity.PlacementHome)

Example 19 with PlacementHome

use of gov.ca.cwds.data.legacy.cms.entity.PlacementHome in project api-core by ca-cwds.

the class BaseDocToolRulesPlacementHomeTest method prepareSuccessfulPlacementHomeEntityAwareDTO.

private PlacementHomeEntityAwareDTO prepareSuccessfulPlacementHomeEntityAwareDTO() {
    PlacementHomeEntityAwareDTO placementHomeEntityAwareDTO = new PlacementHomeEntityAwareDTO();
    PlacementHome placementHome = new PlacementHome();
    placementHome.setAgeToNo((short) 23);
    placementHome.setZipNo("11111");
    placementHome.setLaPZipno("11111");
    placementHome.setpZipNo("11111");
    placementHome.setPyeFstnm("PyeFstnm");
    placementHome.setPyeLstnm("PyeLstnm");
    placementHome.setPstreetNm("PstreetNm");
    placementHome.setpCityNm("pCityNm");
    placementHome.setPayeeStateCode((short) 1);
    SubstituteCareProvider substituteCareProvider = new SubstituteCareProvider();
    substituteCareProvider.setZipNo("11111");
    placementHome.setPrimarySubstituteCareProvider(substituteCareProvider);
    placementHomeEntityAwareDTO.setEntity(placementHome);
    return placementHomeEntityAwareDTO;
}
Also used : PlacementHomeEntityAwareDTO(gov.ca.cwds.cms.data.access.dto.PlacementHomeEntityAwareDTO) PlacementHome(gov.ca.cwds.data.legacy.cms.entity.PlacementHome) SubstituteCareProvider(gov.ca.cwds.data.legacy.cms.entity.SubstituteCareProvider)

Example 20 with PlacementHome

use of gov.ca.cwds.data.legacy.cms.entity.PlacementHome in project api-core by ca-cwds.

the class R00195Test method testNALicensrCd.

@Test
public void testNALicensrCd() throws DroolsException {
    final PlacementHome placementHome = placementHomeEntityAwareDTO.getEntity();
    placementHome.setFacilityType(null);
    placementHome.setLicensrCd(null);
    businessValidationService.runDataProcessing(placementHomeEntityAwareDTO, principal, PlacementHomeDroolsConfiguration.DATA_PROCESSING_INSTANCE);
    assert placementHome.getLicensrCd().equals("NA");
}
Also used : PlacementHome(gov.ca.cwds.data.legacy.cms.entity.PlacementHome) Test(org.junit.Test)

Aggregations

PlacementHome (gov.ca.cwds.data.legacy.cms.entity.PlacementHome)29 Test (org.junit.Test)24 OtherAdultsInPlacementHome (gov.ca.cwds.data.legacy.cms.entity.OtherAdultsInPlacementHome)18 OtherChildrenInPlacementHome (gov.ca.cwds.data.legacy.cms.entity.OtherChildrenInPlacementHome)18 DroolsException (gov.ca.cwds.drools.DroolsException)2 BusinessValidationException (gov.ca.cwds.rest.exception.BusinessValidationException)2 PerryAccount (gov.ca.cwds.security.realm.PerryAccount)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 UserTransactionImp (com.atomikos.icatch.jta.UserTransactionImp)1 RFA1aFormDTO (gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO)1 PlacementHomeEntityAwareDTO (gov.ca.cwds.cms.data.access.dto.PlacementHomeEntityAwareDTO)1 DataAccessServicesException (gov.ca.cwds.cms.data.access.service.DataAccessServicesException)1 BaseDocToolRulesPlacementHomeTest (gov.ca.cwds.cms.data.access.service.impl.placementHome.BaseDocToolRulesPlacementHomeTest)1 PlacementHomeDroolsConfiguration (gov.ca.cwds.cms.data.access.service.rules.PlacementHomeDroolsConfiguration)1 SubstituteCareProvider (gov.ca.cwds.data.legacy.cms.entity.SubstituteCareProvider)1 ExpectedException (gov.ca.cwds.rest.exception.ExpectedException)1 NoResultException (javax.persistence.NoResultException)1 NotSupportedException (javax.transaction.NotSupportedException)1 SystemException (javax.transaction.SystemException)1 UserTransaction (javax.transaction.UserTransaction)1