Search in sources :

Example 1 with PartRemarks

use of org.jaffa.persistence.domainobjects.PartRemarks in project jaffa-framework by jaffa-projects.

the class EqualsTest method testEquals.

public void testEquals() {
    try {
        // Create 2 Parts with different keys. The comparison should fail
        Part p1 = new Part();
        p1.setPart("P1");
        p1.setNoun("P1Noun");
        Part p2 = new Part();
        p2.setPart("P2");
        p2.setNoun("P2Noun");
        assertTrue(!p1.equals(p2));
        assertTrue(!p2.equals(p1));
        // Now make the keys the same. The comparison should succeed
        p2.setPart("P1");
        assertTrue(p1.equals(p2));
        assertTrue(p2.equals(p1));
        // Create another domain object with similar keyfield. The comparison should fail.
        PartRemarks pr = new PartRemarks();
        pr.setPart("P1");
        assertTrue(!p1.equals(pr));
        assertTrue(!pr.equals(p1));
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : PartRemarks(org.jaffa.persistence.domainobjects.PartRemarks) Part(org.jaffa.persistence.domainobjects.Part)

Example 2 with PartRemarks

use of org.jaffa.persistence.domainobjects.PartRemarks in project jaffa-framework by jaffa-projects.

the class EqualsTest method testHashCode.

public void testHashCode() {
    try {
        // Create 2 Parts with different keys. The hashCodes should be different
        Part p1 = new Part();
        p1.setPart("P1");
        p1.setNoun("P1Noun");
        Part p2 = new Part();
        p2.setPart("P2");
        p2.setNoun("P2Noun");
        assertTrue(p1.hashCode() != p2.hashCode());
        // Now make the keys the same. The hashCodes should be same
        p2.setPart("P1");
        assertTrue(p1.hashCode() == p2.hashCode());
        // Create another domain object with similar keyfield. The hashCodes should be same.
        PartRemarks pr = new PartRemarks();
        pr.setPart("P1");
        assertTrue(p1.hashCode() == pr.hashCode());
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : PartRemarks(org.jaffa.persistence.domainobjects.PartRemarks) Part(org.jaffa.persistence.domainobjects.Part)

Example 3 with PartRemarks

use of org.jaffa.persistence.domainobjects.PartRemarks in project jaffa-framework by jaffa-projects.

the class Part method newPartRemarksObject.

/**
 * Creates a new PartRemarks object and initializes the related fields.
 * @throws ValidationException if an invalid value is passed.
 * @throws FrameworkException Indicates some system error
 * @return the related PartRemarks object with the initialized related fields.
 */
public PartRemarks newPartRemarksObject() throws ValidationException, FrameworkException {
    PartRemarks partRemarks = new PartRemarks();
    partRemarks.setPart(getPart());
    // .//GEN-BEGIN:partRemarksObject_2_be
    return partRemarks;
}
Also used : PartRemarks(org.jaffa.persistence.domainobjects.PartRemarks)

Example 4 with PartRemarks

use of org.jaffa.persistence.domainobjects.PartRemarks in project jaffa-framework by jaffa-projects.

the class Part method performPreDeleteReferentialIntegrity.

// .//GEN-END:performForeignKeyValidations_1_be
// .//GEN-BEGIN:performPreDeleteReferentialIntegrity_1_be
/**
 * This method is triggered by the UOW, before adding this object to the Delete-Store.
 * This will raise an exception if any associated/aggregated objects exist.
 * This will cascade delete all composite objects.
 * @throws PreDeleteFailedException if any error occurs during the process.
 */
public void performPreDeleteReferentialIntegrity() throws PreDeleteFailedException {
    Asset[] assetArray = null;
    try {
        assetArray = getAssetArray();
    } catch (FrameworkException e) {
        throw new PreDeleteFailedException(null, e);
    }
    if (assetArray != null && assetArray.length > 0) {
        try {
            // Perform cascade deletes
            for (int i = 0; i < assetArray.length; i++) getUOW().delete(assetArray[i]);
        } catch (Exception e) {
            throw new PreDeleteFailedException(null, e);
        }
    }
    Item[] itemArray = null;
    try {
        itemArray = getItemArray();
    } catch (FrameworkException e) {
        throw new PreDeleteFailedException(null, e);
    }
    if (itemArray != null && itemArray.length > 0) {
        try {
            // Perform cascade deletes
            for (int i = 0; i < itemArray.length; i++) getUOW().delete(itemArray[i]);
        } catch (Exception e) {
            throw new PreDeleteFailedException(null, e);
        }
    }
    PartRemarks partRemarksObject = null;
    try {
        partRemarksObject = getPartRemarksObject();
    } catch (FrameworkException e) {
        throw new PreDeleteFailedException(null, e);
    }
    if (partRemarksObject != null) {
        // Stop the deletion !!
        throw new PreDeleteFailedException(null, new RelatedDomainObjectFoundException(PartRemarksMeta.getLabelToken()));
    }
    PartPicture partPictureObject = null;
    try {
        partPictureObject = getPartPictureObject();
    } catch (FrameworkException e) {
        throw new PreDeleteFailedException(null, e);
    }
    if (partPictureObject != null) {
        try {
            // Perform cascade delete
            getUOW().delete(partPictureObject);
        } catch (Exception e) {
            throw new PreDeleteFailedException(null, e);
        }
    }
    PartRemarksPicture partRemarksPictureObject = null;
    try {
        partRemarksPictureObject = getPartRemarksPictureObject();
    } catch (FrameworkException e) {
        throw new PreDeleteFailedException(null, e);
    }
    if (partRemarksPictureObject != null) {
        try {
            // Perform cascade delete
            getUOW().delete(partRemarksPictureObject);
        } catch (Exception e) {
            throw new PreDeleteFailedException(null, e);
        }
    }
    PartAdditional partAdditionalObject = null;
    try {
        partAdditionalObject = getPartAdditionalObject();
    } catch (FrameworkException e) {
        throw new PreDeleteFailedException(null, e);
    }
    if (partAdditionalObject != null) {
        try {
            // Perform cascade delete
            getUOW().delete(partAdditionalObject);
        } catch (Exception e) {
            throw new PreDeleteFailedException(null, e);
        }
    }
}
Also used : FrameworkException(org.jaffa.exceptions.FrameworkException) PartRemarksPicture(org.jaffa.persistence.domainobjects.PartRemarksPicture) RelatedDomainObjectFoundException(org.jaffa.exceptions.RelatedDomainObjectFoundException) FrameworkException(org.jaffa.exceptions.FrameworkException) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException) DuplicateKeyException(org.jaffa.exceptions.DuplicateKeyException) RelatedDomainObjectFoundException(org.jaffa.exceptions.RelatedDomainObjectFoundException) Item(org.jaffa.persistence.domainobjects.Item) PartRemarks(org.jaffa.persistence.domainobjects.PartRemarks) Asset(org.jaffa.persistence.domainobjects.Asset) PartAdditional(org.jaffa.persistence.domainobjects.PartAdditional) PartPicture(org.jaffa.persistence.domainobjects.PartPicture)

Aggregations

PartRemarks (org.jaffa.persistence.domainobjects.PartRemarks)4 Part (org.jaffa.persistence.domainobjects.Part)2 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)1 DuplicateKeyException (org.jaffa.exceptions.DuplicateKeyException)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1 RelatedDomainObjectFoundException (org.jaffa.exceptions.RelatedDomainObjectFoundException)1 Asset (org.jaffa.persistence.domainobjects.Asset)1 Item (org.jaffa.persistence.domainobjects.Item)1 PartAdditional (org.jaffa.persistence.domainobjects.PartAdditional)1 PartPicture (org.jaffa.persistence.domainobjects.PartPicture)1 PartRemarksPicture (org.jaffa.persistence.domainobjects.PartRemarksPicture)1