Search in sources :

Example 16 with FormGroup

use of org.jaffa.modules.printing.domain.FormGroup in project jaffa-framework by jaffa-projects.

the class FormUsage method findFormGroupObject.

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

Aggregations

FormGroup (org.jaffa.modules.printing.domain.FormGroup)16 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)9 ApplicationException (org.jaffa.exceptions.ApplicationException)5 FrameworkException (org.jaffa.exceptions.FrameworkException)5 UOW (org.jaffa.persistence.UOW)5 Criteria (org.jaffa.persistence.Criteria)4 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)3 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)2 ValidationException (org.jaffa.datatypes.ValidationException)1 FormGroupFinderOutDto (org.jaffa.modules.printing.components.formgroupfinder.dto.FormGroupFinderOutDto)1 FormGroupFinderOutRowDto (org.jaffa.modules.printing.components.formgroupfinder.dto.FormGroupFinderOutRowDto)1 FormGroupLookupOutDto (org.jaffa.modules.printing.components.formgrouplookup.dto.FormGroupLookupOutDto)1 FormGroupLookupOutRowDto (org.jaffa.modules.printing.components.formgrouplookup.dto.FormGroupLookupOutRowDto)1 FormGroupViewerOutDto (org.jaffa.modules.printing.components.formgroupviewer.dto.FormGroupViewerOutDto)1 FormSelectionMaintenanceOutDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto)1 FormSelectionMaintenanceOutRowDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto)1 FormDefinition (org.jaffa.modules.printing.domain.FormDefinition)1 FormUsage (org.jaffa.modules.printing.domain.FormUsage)1 AtomicCriteria (org.jaffa.persistence.AtomicCriteria)1