Search in sources :

Example 1 with AuditTransactionObject

use of org.jaffa.components.audit.domain.AuditTransactionObject in project jaffa-framework by jaffa-projects.

the class AuditTransaction method newAuditTransactionObjectObject.

/**
 * Creates a new AuditTransactionObject object and initializes the related fields.
 * This will uncache the related AuditTransactionObject objects.
 * @throws ValidationException if an invalid value is passed.
 * @throws FrameworkException Indicates some system error
 * @return the related AuditTransactionObject object with the initialized related fields.
 */
public AuditTransactionObject newAuditTransactionObjectObject() throws ValidationException, FrameworkException {
    m_auditTransactionObjectCollection = null;
    AuditTransactionObject auditTransactionObject = new AuditTransactionObject();
    auditTransactionObject.setTransactionId(getTransactionId());
    // .//GEN-BEGIN:auditTransactionObjectArray_3_be
    return auditTransactionObject;
}
Also used : AuditTransactionObject(org.jaffa.components.audit.domain.AuditTransactionObject)

Example 2 with AuditTransactionObject

use of org.jaffa.components.audit.domain.AuditTransactionObject in project jaffa-framework by jaffa-projects.

the class AuditTransactionField method findAuditTransactionObjectObject.

/**
 * Finds the related foreign AuditTransactionObject object.
 * If checkExistenceOnly is false, then the foreign object will be fetched and assigned to the corresponding member variable of this class.
 * If checkExistenceOnly is true, then a mere existence check is performed for the foreign object, as oppposed to fetching all the values for that object.
 */
private void findAuditTransactionObjectObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
    UOW uow = getUOW();
    boolean localUow = false;
    try {
        if (m_auditTransactionObjectObject == null && getObjectId() != null) {
            Criteria criteria = new Criteria();
            criteria.setTable(AuditTransactionObjectMeta.getName());
            criteria.addCriteria(AuditTransactionObjectMeta.OBJECT_ID, getObjectId());
            if (checkExistenceOnly)
                criteria.addFunction(Criteria.FUNCTION_COUNT, null, Criteria.ID_FUNCTION_COUNT);
            Number count = null;
            if (uow == null || !uow.isActive()) {
                uow = new UOW();
                localUow = true;
            }
            Iterator itr = uow.query(criteria).iterator();
            if (itr.hasNext()) {
                if (checkExistenceOnly)
                    count = (Number) ((Map) itr.next()).get(Criteria.ID_FUNCTION_COUNT);
                else
                    m_auditTransactionObjectObject = (AuditTransactionObject) itr.next();
            }
            if (m_auditTransactionObjectObject == null && (count == null || count.intValue() <= 0))
                throw new InvalidForeignKeyException(AuditTransactionFieldMeta.META_OBJECT_ID.getLabelToken(), new Object[] { AuditTransactionObjectMeta.getLabelToken(), AuditTransactionObjectMeta.META_OBJECT_ID.getLabelToken() });
        }
    } finally {
        if (localUow && uow != null)
            uow.rollback();
    }
}
Also used : InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException) AuditTransactionObject(org.jaffa.components.audit.domain.AuditTransactionObject) AuditTransactionObject(org.jaffa.components.audit.domain.AuditTransactionObject)

Example 3 with AuditTransactionObject

use of org.jaffa.components.audit.domain.AuditTransactionObject in project jaffa-framework by jaffa-projects.

the class AuditLogger method createAuditTransactionObject.

/**
 * Creates an AuditTransactionObject instance, adds it to the UOW and returns it's id.
 */
private String createAuditTransactionObject(String objectName, ChangeType changeType) throws ApplicationExceptions, FrameworkException {
    try {
        AuditTransactionObject ato = new AuditTransactionObject();
        ato.generateKey();
        ato.setTransactionId(m_transactionId);
        ato.setObjectName(objectName);
        ato.setChangeType(changeType == ChangeType.INSERT ? "I" : (changeType == ChangeType.UPDATE ? "U" : "D"));
        m_uow.addSpecial(ato);
        if (log.isDebugEnabled())
            log.debug("Created AuditTransactionObject: " + ato);
        return ato.getObjectId();
    } catch (ValidationException e) {
        if (log.isDebugEnabled())
            log.debug("Exception thrown during creation of AuditTransactionObject", e);
        throw new ApplicationExceptions(e);
    }
}
Also used : ValidationException(org.jaffa.datatypes.ValidationException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) AuditTransactionObject(org.jaffa.components.audit.domain.AuditTransactionObject)

Aggregations

AuditTransactionObject (org.jaffa.components.audit.domain.AuditTransactionObject)3 ValidationException (org.jaffa.datatypes.ValidationException)1 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)1 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)1