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();
}
}
Aggregations