Search in sources :

Example 6 with Part

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;
}
Also used : Part(org.jaffa.persistence.domainobjects.Part)

Example 7 with 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();
    }
}
Also used : Part(org.jaffa.persistence.domainobjects.Part) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException)

Example 8 with Part

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();
    }
}
Also used : Part(org.jaffa.persistence.domainobjects.Part) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException)

Example 9 with Part

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();
    }
}
Also used : Part(org.jaffa.persistence.domainobjects.Part) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException)

Example 10 with Part

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();
    }
}
Also used : Part(org.jaffa.persistence.domainobjects.Part) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException)

Aggregations

Part (org.jaffa.persistence.domainobjects.Part)10 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)6 PartRemarks (org.jaffa.persistence.domainobjects.PartRemarks)2 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 Iterator (java.util.Iterator)1 UOW (org.jaffa.persistence.UOW)1 CategoryOfInstrument (org.jaffa.persistence.domainobjects.CategoryOfInstrument)1 Item (org.jaffa.persistence.domainobjects.Item)1