Search in sources :

Example 1 with TriggerTableException

use of gov.ca.cwds.data.rules.TriggerTableException in project API by ca-cwds.

the class NonLACountyTriggers method createAndUpdateReferralClientCoutyOwnership.

/**
   * @param managed referralClient creates or updates the countyOwnership with the client foreign
   *        key
   */
public void createAndUpdateReferralClientCoutyOwnership(ReferralClient managed) {
    Boolean countyExists = true;
    CountyOwnership countyOwnership = countyOwnershipDao.find(managed.getClientId());
    if (countyOwnership == null) {
        countyExists = false;
        countyOwnership = new CountyOwnership();
        countyOwnership.setEntityId(managed.getClientId());
        countyOwnership.setEntityCode(CLIENT_ENTITY_CODE);
    }
    String methodName = SET_COUNTY + managed.getCountySpecificCode() + FLAG;
    Method method = null;
    try {
        method = countyOwnership.getClass().getMethod(methodName, String.class);
        method.invoke(countyOwnership, SET_FLAG);
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        LOGGER.info("CountyOwnership Unable to Trigger : {}", countyOwnership);
        LOGGER.error(e.getMessage(), e);
        throw new TriggerTableException();
    }
    if (countyExists) {
        countyOwnershipDao.update(countyOwnership);
    } else {
        countyOwnershipDao.create(countyOwnership);
    }
}
Also used : CountyOwnership(gov.ca.cwds.data.persistence.cms.CountyOwnership) Method(java.lang.reflect.Method) TriggerTableException(gov.ca.cwds.data.rules.TriggerTableException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

CountyOwnership (gov.ca.cwds.data.persistence.cms.CountyOwnership)1 TriggerTableException (gov.ca.cwds.data.rules.TriggerTableException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1