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