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