Search in sources :

Example 31 with DomainObjectNotFoundException

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);
    }
}
Also used : Transaction(org.jaffa.transaction.domain.Transaction) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) DomainObjectChangedException(org.jaffa.exceptions.DomainObjectChangedException) FrameworkException(org.jaffa.exceptions.FrameworkException) MessagingException(javax.mail.MessagingException) ApplicationException(org.jaffa.exceptions.ApplicationException) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException)

Example 32 with DomainObjectNotFoundException

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;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) UserTimeEntry(org.jaffa.applications.test.modules.time.domain.UserTimeEntry) Criteria(org.jaffa.persistence.Criteria)

Example 33 with DomainObjectNotFoundException

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;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) UserTimeEntry(org.jaffa.applications.test.modules.time.domain.UserTimeEntry) Criteria(org.jaffa.persistence.Criteria)

Example 34 with DomainObjectNotFoundException

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;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) Method(java.lang.reflect.Method) FrameworkException(org.jaffa.exceptions.FrameworkException) RulesEngineException(org.jaffa.rules.RulesEngineException) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) ParseException(java.text.ParseException)

Example 35 with DomainObjectNotFoundException

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;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) Attachment(org.jaffa.components.attachment.domain.Attachment) Criteria(org.jaffa.persistence.Criteria)

Aggregations

DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)62 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)57 Criteria (org.jaffa.persistence.Criteria)39 FrameworkException (org.jaffa.exceptions.FrameworkException)10 ApplicationException (org.jaffa.exceptions.ApplicationException)9 Method (java.lang.reflect.Method)6 UOW (org.jaffa.persistence.UOW)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 Iterator (java.util.Iterator)5 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)5 IPersistent (org.jaffa.persistence.IPersistent)5 MultipleDomainObjectsFoundException (org.jaffa.exceptions.MultipleDomainObjectsFoundException)4 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)4 PrinterOutputType (org.jaffa.modules.printing.domain.PrinterOutputType)4 HashMap (java.util.HashMap)3 User (org.jaffa.applications.jaffa.modules.admin.domain.User)3 UserRequest (org.jaffa.applications.jaffa.modules.user.domain.UserRequest)3 UserTimeEntry (org.jaffa.applications.test.modules.time.domain.UserTimeEntry)3 GraphMapping (org.jaffa.beans.moulding.mapping.GraphMapping)3