use of org.jaffa.transaction.daos.TransactionMessageService in project jaffa-framework by jaffa-projects.
the class LockingService method checkOrDeleteLockingTransactions.
/**
* Browses all Transactions looking for the locks, as specified in the transaction-configuration for the input dataBean.
* Calls any specified lock-check filter class if one has been defined
* Throws an ApplicationException, if any matching Transaction is found, and if the input argument 'deleteLockingTransaction' is false.
* Deletes all matching Transactions, if the input argument 'deleteLockingTransaction' is true.
*
* @param uow The UOW.
* @param dataBean Any serializable object.
* @param transactionInfo the corresponding TransactionInfo object, as specified in the configuration file.
* @param deleteLockingTransaction determines if the matching Transactions are to be deleted.
* @throws FrameworkException Indicates some system error.
* @throws ApplicationExceptions Indicates application error(s).
*/
private static void checkOrDeleteLockingTransactions(UOW uow, Object dataBean, TransactionInfo transactionInfo, boolean deleteLockingTransaction, String transactionId) throws FrameworkException, ApplicationExceptions {
// Check if lock checks exists for the message
if (transactionInfo.getLockCheck() != null) {
Filter filterConfig = transactionInfo.getLockCheck().getFilter();
// Load the appropriate class
if (filterConfig != null) {
try {
Class<ILockCheckFilter> filterClass = (Class<ILockCheckFilter>) Class.forName(filterConfig.getClassName());
TransactionMessageService transactionService = TransactionMessageDAOFactory.getTransactionMessageService();
Collection<Transaction> transactions = filterClass.newInstance().getFilteredResults(dataBean, transactionService);
deleteLockCheck(uow, transactions, deleteLockingTransaction, transactionId);
} catch (Exception e) {
throw ExceptionHelper.throwAFR(e);
}
// load the load check parameters directly from the message config
} else if (transactionInfo.getLockCheck().getParam() != null) {
TransactionMessageDAO transactionDAO = TransactionMessageDAOFactory.getTransactionMessageDAO();
// Run this logic for each Param
for (Param param : transactionInfo.getLockCheck().getParam()) {
String value = TransactionEngine.obtainParamValue(param, dataBean);
Collection<Transaction> transactions = transactionDAO.getTransactionsByField(param.getName(), value);
deleteLockCheck(uow, transactions, deleteLockingTransaction, transactionId);
}
}
}
}
Aggregations