Search in sources :

Example 6 with InvalidForeignKeyException

use of org.jaffa.datatypes.exceptions.InvalidForeignKeyException in project jaffa-framework by jaffa-projects.

the class UserRole method findUserObject.

/**
 * Finds the related foreign User 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 findUserObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
    UOW uow = getUOW();
    boolean localUow = false;
    try {
        if (m_userObject == null && getUserName() != null) {
            Criteria criteria = new Criteria();
            criteria.setTable(UserMeta.getName());
            criteria.addCriteria(UserMeta.USER_NAME, getUserName());
            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_userObject = (User) itr.next();
            }
            if (m_userObject == null && (count == null || count.intValue() <= 0))
                throw new InvalidForeignKeyException(UserRoleMeta.META_USER_NAME.getLabelToken(), new Object[] { UserMeta.getLabelToken(), UserMeta.META_USER_NAME.getLabelToken() });
        }
    } finally {
        if (localUow && uow != null)
            uow.rollback();
    }
}
Also used : User(org.jaffa.applications.jaffa.modules.admin.domain.User) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException)

Example 7 with InvalidForeignKeyException

use of org.jaffa.datatypes.exceptions.InvalidForeignKeyException in project jaffa-framework by jaffa-projects.

the class FormDefinition method findPrinterOutputTypeObject.

/**
 * Finds the related foreign PrinterOutputType 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 findPrinterOutputTypeObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
    UOW uow = getUOW();
    boolean localUow = false;
    try {
        if (m_printerOutputTypeObject == null && getOutputType() != null) {
            Criteria criteria = new Criteria();
            criteria.setTable(PrinterOutputTypeMeta.getName());
            criteria.addCriteria(PrinterOutputTypeMeta.OUTPUT_TYPE, getOutputType());
            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_printerOutputTypeObject = (PrinterOutputType) itr.next();
            }
            if (m_printerOutputTypeObject == null && (count == null || count.intValue() <= 0))
                throw new InvalidForeignKeyException(FormDefinitionMeta.META_OUTPUT_TYPE.getLabelToken(), new Object[] { PrinterOutputTypeMeta.getLabelToken(), PrinterOutputTypeMeta.META_OUTPUT_TYPE.getLabelToken() });
        }
    } finally {
        if (localUow && uow != null)
            uow.rollback();
    }
}
Also used : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException)

Example 8 with InvalidForeignKeyException

use of org.jaffa.datatypes.exceptions.InvalidForeignKeyException in project jaffa-framework by jaffa-projects.

the class FormUsage method findFormEventObject.

/**
 * Finds the related foreign FormEvent 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 findFormEventObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
    UOW uow = getUOW();
    boolean localUow = false;
    try {
        if (m_formEventObject == null && getEventName() != null) {
            Criteria criteria = new Criteria();
            criteria.setTable(FormEventMeta.getName());
            criteria.addCriteria(FormEventMeta.EVENT_NAME, getEventName());
            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_formEventObject = (FormEvent) itr.next();
            }
            if (m_formEventObject == null && (count == null || count.intValue() <= 0))
                throw new InvalidForeignKeyException(FormUsageMeta.META_EVENT_NAME.getLabelToken(), new Object[] { FormEventMeta.getLabelToken(), FormEventMeta.META_EVENT_NAME.getLabelToken() });
        }
    } finally {
        if (localUow && uow != null)
            uow.rollback();
    }
}
Also used : FormEvent(org.jaffa.modules.printing.domain.FormEvent) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException)

Example 9 with InvalidForeignKeyException

use of org.jaffa.datatypes.exceptions.InvalidForeignKeyException in project jaffa-framework by jaffa-projects.

the class OutputCommand method findPrinterOutputTypeObject.

/**
 * Finds the related foreign PrinterOutputType 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 findPrinterOutputTypeObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
    UOW uow = getUOW();
    boolean localUow = false;
    try {
        if (m_printerOutputTypeObject == null && getOutputType() != null) {
            Criteria criteria = new Criteria();
            criteria.setTable(PrinterOutputTypeMeta.getName());
            criteria.addCriteria(PrinterOutputTypeMeta.OUTPUT_TYPE, getOutputType());
            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_printerOutputTypeObject = (PrinterOutputType) itr.next();
            }
            if (m_printerOutputTypeObject == null && (count == null || count.intValue() <= 0))
                throw new InvalidForeignKeyException(OutputCommandMeta.META_OUTPUT_TYPE.getLabelToken(), new Object[] { PrinterOutputTypeMeta.getLabelToken(), PrinterOutputTypeMeta.META_OUTPUT_TYPE.getLabelToken() });
        }
    } finally {
        if (localUow && uow != null)
            uow.rollback();
    }
}
Also used : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException)

Example 10 with InvalidForeignKeyException

use of org.jaffa.datatypes.exceptions.InvalidForeignKeyException in project jaffa-framework by jaffa-projects.

the class PrinterDefinition method findPrinterOutputTypeObject.

/**
 * Finds the related foreign PrinterOutputType 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 findPrinterOutputTypeObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
    UOW uow = getUOW();
    boolean localUow = false;
    try {
        if (m_printerOutputTypeObject == null && getOutputType() != null) {
            Criteria criteria = new Criteria();
            criteria.setTable(PrinterOutputTypeMeta.getName());
            criteria.addCriteria(PrinterOutputTypeMeta.OUTPUT_TYPE, getOutputType());
            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_printerOutputTypeObject = (PrinterOutputType) itr.next();
            }
            if (m_printerOutputTypeObject == null && (count == null || count.intValue() <= 0))
                throw new InvalidForeignKeyException(PrinterDefinitionMeta.META_OUTPUT_TYPE.getLabelToken(), new Object[] { PrinterOutputTypeMeta.getLabelToken(), PrinterOutputTypeMeta.META_OUTPUT_TYPE.getLabelToken() });
        }
    } finally {
        if (localUow && uow != null)
            uow.rollback();
    }
}
Also used : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException)

Aggregations

InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)30 Part (org.jaffa.persistence.domainobjects.Part)6 Method (java.lang.reflect.Method)3 PrinterOutputType (org.jaffa.modules.printing.domain.PrinterOutputType)3 Transaction (org.jaffa.transaction.domain.Transaction)3 PropertyDescriptor (java.beans.PropertyDescriptor)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Set (java.util.Set)2 ApplicationException (org.jaffa.exceptions.ApplicationException)2 FrameworkException (org.jaffa.exceptions.FrameworkException)2 FormGroup (org.jaffa.modules.printing.domain.FormGroup)2 Criteria (org.jaffa.persistence.Criteria)2 IPersistent (org.jaffa.persistence.IPersistent)2 Condition (org.jaffa.persistence.domainobjects.Condition)2 JaffaRulesFrameworkException (org.jaffa.rules.JaffaRulesFrameworkException)2 Extension1 (org.jaffa.rules.testmodels.Extension1)2 AccessibleObject (java.lang.reflect.AccessibleObject)1