use of org.jaffa.exceptions.DomainObjectNotFoundException in project jaffa-framework by jaffa-projects.
the class TransactionEngine method updateTransactionStatusToSatisfied.
/**
* Retrieves the Transaction and update it's status to S.
* NOTE: The processing happens within the scope of the input UOW.
*
* @param uow The UOW.
* @param id the Transaction Id.
* @throws FrameworkException Indicates some system error.
* @throws ApplicationExceptions Indicates application error(s).
*/
public void updateTransactionStatusToSatisfied(UOW uow, String id) throws FrameworkException, ApplicationExceptions {
try {
Transaction transaction = getTransaction(uow, id);
if (transaction == null) {
log.error("Transaction '" + id + "' not found; cannot update it's status to S");
throw new DomainObjectNotFoundException(TransactionMeta.getLabelToken());
} else {
if (log.isDebugEnabled()) {
log.debug("Updating Transaction '" + transaction.getId() + "' to status S");
}
transaction.setStatus(Transaction.Status.S.toString());
getTransactionDAO().save(uow, transaction);
}
} catch (Exception e) {
throw ExceptionHelper.throwAFR(e);
}
}
use of org.jaffa.exceptions.DomainObjectNotFoundException in project jaffa-framework by jaffa-projects.
the class UserTimeEntryMaintenanceTx method load.
// .//GEN-END:_preprocessRetrieve_2_be
// .//GEN-BEGIN:_loadRetrieve_1_be
/**
* Retrieve the domain object.
*/
private UserTimeEntry load(UOW uow, UserTimeEntryMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
UserTimeEntry domain = null;
Criteria criteria = new Criteria();
criteria.setTable(UserTimeEntryMeta.getName());
// .//GEN-END:_loadRetrieve_1_be
// Add custom criteria //GEN-FIRST:_loadRetrieve_1
// .//GEN-LAST:_loadRetrieve_1
// .//GEN-BEGIN:_loadRetrieve_2_be
criteria.addCriteria(UserTimeEntryMeta.USER_NAME, input.getUserName());
criteria.addCriteria(UserTimeEntryMeta.PROJECT_CODE, input.getProjectCode());
criteria.addCriteria(UserTimeEntryMeta.TASK, input.getTask());
criteria.addCriteria(UserTimeEntryMeta.PERIOD_START, input.getPeriodStart());
criteria.addCriteria(UserTimeEntryMeta.PERIOD_END, input.getPeriodEnd());
Iterator itr = uow.query(criteria).iterator();
if (itr.hasNext())
domain = (UserTimeEntry) itr.next();
// .//GEN-BEGIN:_loadRetrieve_3_be
if (domain == null) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new DomainObjectNotFoundException(UserTimeEntryMeta.getLabelToken()));
throw appExps;
}
return domain;
}
use of org.jaffa.exceptions.DomainObjectNotFoundException in project jaffa-framework by jaffa-projects.
the class UserTimeEntryMaintenanceTx method load.
// .//GEN-END:_preprocessUpdate_2_be
// .//GEN-BEGIN:_loadUpdate_1_be
/**
* Retrieve the domain object.
*/
private UserTimeEntry load(UOW uow, UserTimeEntryMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
UserTimeEntry domain = null;
Criteria criteria = new Criteria();
criteria.setTable(UserTimeEntryMeta.getName());
// .//GEN-END:_loadUpdate_1_be
// Add custom criteria //GEN-FIRST:_loadUpdate_1
// .//GEN-LAST:_loadUpdate_1
// .//GEN-BEGIN:_loadUpdate_2_be
criteria.addCriteria(UserTimeEntryMeta.USER_NAME, input.getUserName());
criteria.addCriteria(UserTimeEntryMeta.PROJECT_CODE, input.getProjectCode());
criteria.addCriteria(UserTimeEntryMeta.TASK, input.getTask());
criteria.addCriteria(UserTimeEntryMeta.PERIOD_START, input.getPeriodStart());
criteria.addCriteria(UserTimeEntryMeta.PERIOD_END, input.getPeriodEnd());
criteria.setLocking(Criteria.LOCKING_PARANOID);
Iterator itr = uow.query(criteria).iterator();
if (itr.hasNext())
domain = (UserTimeEntry) itr.next();
// .//GEN-BEGIN:_loadUpdate_3_be
if (domain == null) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new DomainObjectNotFoundException(UserTimeEntryMeta.getLabelToken()));
throw appExps;
}
return domain;
}
use of org.jaffa.exceptions.DomainObjectNotFoundException in project jaffa-framework by jaffa-projects.
the class LookupComponent2 method raiseErrorIfNoRows.
/**
* This method has effect only if the property 'errorIfNoRows' is set to true and if no rows are retrieved by a query.
* In modal mode, null data will be passed to the registered listener, and the FormKey of the calling component will be returned
* In non-modal mode, an ApplicationException will be thrown.
* @return the A null will be returned if the query returned data.
* @throws ApplicationExceptions if in non-modal mode, no rows are returned by the query.
*/
protected FormKey raiseErrorIfNoRows() throws ApplicationExceptions, FrameworkException {
if (m_errorIfNoRows != null && m_errorIfNoRows.booleanValue()) {
int noOfRows = 0;
if (getFinderOutDto() != null) {
try {
Class finderOutDtoClass = getFinderOutDto().getClass();
Method method = finderOutDtoClass.getMethod("getRows", (Class[]) null);
Object rows = method.invoke(getFinderOutDto(), (Object[]) null);
if (rows != null && rows.getClass().isArray())
noOfRows = Array.getLength(rows);
} catch (Exception e) {
String str = "Exception thrown when trying to check if zero rows were retrieved";
log.warn(str, e);
return null;
}
}
if (noOfRows == 0) {
if (isInSelectLookupMode()) {
if (log.isDebugEnabled())
log.debug("Number of rows is 0. Will invoke the SelectLookupListeners");
return performSelectLookup(null, new SelectLookupEvent(this, null));
} else if (isInMultiSelectLookupMode()) {
if (log.isDebugEnabled())
log.debug("Number of rows is 0. Will invoke the MultiSelectLookupListeners");
return performMultiSelectLookup(null, new MultiSelectLookupEvent(this, null));
} else {
if (log.isDebugEnabled())
log.debug("Number of rows is 0. Will throw an exception");
throw new ApplicationExceptions(new DomainObjectNotFoundException("Data"));
}
} else {
if (log.isDebugEnabled())
log.debug("No error raised since rows exceed 0: " + noOfRows);
}
} else {
if (log.isDebugEnabled())
log.debug("No error will be raised since the 'errorIfNoRows' property is not set to true");
}
return null;
}
use of org.jaffa.exceptions.DomainObjectNotFoundException in project jaffa-framework by jaffa-projects.
the class AttachmentMaintenanceTx method load.
// .//GEN-END:_preprocessUpdate_2_be
// .//GEN-BEGIN:_loadUpdate_1_be
/**
* Retrieve the domain object.
*/
private Attachment load(UOW uow, AttachmentMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
Attachment domain = null;
Criteria criteria = new Criteria();
criteria.setTable(AttachmentMeta.getName());
// .//GEN-END:_loadUpdate_1_be
// Add custom criteria //GEN-FIRST:_loadUpdate_1
// .//GEN-LAST:_loadUpdate_1
// .//GEN-BEGIN:_loadUpdate_2_be
criteria.addCriteria(AttachmentMeta.ATTACHMENT_ID, input.getAttachmentId());
criteria.setLocking(Criteria.LOCKING_PARANOID);
Iterator itr = uow.query(criteria).iterator();
if (itr.hasNext())
domain = (Attachment) itr.next();
// .//GEN-BEGIN:_loadUpdate_3_be
if (domain == null) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new DomainObjectNotFoundException(AttachmentMeta.getLabelToken()));
throw appExps;
}
return domain;
}
Aggregations