use of org.jaffa.persistence.domainobjects.Part in project jaffa-framework by jaffa-projects.
the class CategoryOfInstrument method newPartObject.
/**
* Creates a new Part object and initializes the related fields.
* This will uncache the related Part objects.
* @throws ValidationException if an invalid value is passed.
* @throws FrameworkException Indicates some system error
* @return the related Part object with the initialized related fields.
*/
public Part newPartObject() throws ValidationException, FrameworkException {
m_partCollection = null;
Part part = new Part();
part.setCategoryInstrument(getCategoryInstrument());
// .//GEN-BEGIN:partArray_3_be
return part;
}
use of org.jaffa.persistence.domainobjects.Part in project jaffa-framework by jaffa-projects.
the class Item method findPartObject.
/**
* Finds the related foreign Part 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 findPartObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
UOW uow = getUOW();
boolean localUow = false;
try {
if (m_partObject == null && getPart() != null) {
Criteria criteria = new Criteria();
criteria.setTable(PartMeta.getName());
criteria.addCriteria(PartMeta.PART, getPart());
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_partObject = (Part) itr.next();
}
if (m_partObject == null && (count == null || count.intValue() <= 0))
throw new InvalidForeignKeyException(ItemMeta.META_PART.getLabelToken(), new Object[] { PartMeta.getLabelToken(), PartMeta.META_PART.getLabelToken() });
}
} finally {
if (localUow && uow != null)
uow.rollback();
}
}
use of org.jaffa.persistence.domainobjects.Part in project jaffa-framework by jaffa-projects.
the class PartAdditional method findPartObject.
/**
* Finds the related Part object.
* If checkExistenceOnly is false, then the related 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 related object, as oppposed to fetching all the values for that object.
*/
private void findPartObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
UOW uow = getUOW();
boolean localUow = false;
try {
if (m_partObject == null && getPart() != null) {
Criteria criteria = new Criteria();
criteria.setTable(PartMeta.getName());
criteria.addCriteria(PartMeta.PART, getPart());
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_partObject = (Part) itr.next();
}
if (m_partObject == null && (count == null || count.intValue() <= 0))
throw new InvalidForeignKeyException(PartAdditionalMeta.META_PART.getLabelToken(), new Object[] { PartMeta.getLabelToken(), PartMeta.META_PART.getLabelToken() });
}
} finally {
if (localUow && uow != null)
uow.rollback();
}
}
use of org.jaffa.persistence.domainobjects.Part in project jaffa-framework by jaffa-projects.
the class PartPicture method findPartObject.
/**
* Finds the related Part object.
* If checkExistenceOnly is false, then the related 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 related object, as oppposed to fetching all the values for that object.
*/
private void findPartObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
UOW uow = getUOW();
boolean localUow = false;
try {
if (m_partObject == null && getPart() != null) {
Criteria criteria = new Criteria();
criteria.setTable(PartMeta.getName());
criteria.addCriteria(PartMeta.PART, getPart());
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_partObject = (Part) itr.next();
}
if (m_partObject == null && (count == null || count.intValue() <= 0))
throw new InvalidForeignKeyException(PartPictureMeta.META_PART.getLabelToken(), new Object[] { PartMeta.getLabelToken(), PartMeta.META_PART.getLabelToken() });
}
} finally {
if (localUow && uow != null)
uow.rollback();
}
}
use of org.jaffa.persistence.domainobjects.Part in project jaffa-framework by jaffa-projects.
the class PartRemarksPicture method findPartObject.
/**
* Finds the related Part object.
* If checkExistenceOnly is false, then the related 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 related object, as oppposed to fetching all the values for that object.
*/
private void findPartObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
UOW uow = getUOW();
boolean localUow = false;
try {
if (m_partObject == null && getPart() != null) {
Criteria criteria = new Criteria();
criteria.setTable(PartMeta.getName());
criteria.addCriteria(PartMeta.PART, getPart());
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_partObject = (Part) itr.next();
}
if (m_partObject == null && (count == null || count.intValue() <= 0))
throw new InvalidForeignKeyException(PartRemarksPictureMeta.META_PART.getLabelToken(), new Object[] { PartMeta.getLabelToken(), PartMeta.META_PART.getLabelToken() });
}
} finally {
if (localUow && uow != null)
uow.rollback();
}
}
Aggregations