Search in sources :

Example 1 with RelatedDomainObjectFoundException

use of org.jaffa.exceptions.RelatedDomainObjectFoundException in project jaffa-framework by jaffa-projects.

the class FormGroupMaintenanceTx method deleteRelatedObjects.

// .//GEN-END:_addRelatedDtosToRetrieveOut_2_be
// .//GEN-BEGIN:_deleteRelatedObjects_1_be
/**
 * Delete the related domain objects if the 'Cascading' constraint is specified. Throw an exception in case 'Restricted' constraint is specified.
 */
private void deleteRelatedObjects(UOW uow, FormGroupMaintenanceDeleteInDto input, FormGroup formGroup) throws FrameworkException, ApplicationExceptions {
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_deleteRelatedObjects_FormUsage_1_be
    if (formGroup.getFormName() != null) {
        Criteria criteria = new Criteria();
        criteria.setTable(FormUsageMeta.getName());
        criteria.addCriteria(FormUsageMeta.FORM_NAME, formGroup.getFormName());
        // .//GEN-END:_deleteRelatedObjects_FormUsage_1_be
        // Add custom code to set the criteria before the query//GEN-FIRST:_deleteRelatedObjects_FormUsage_1
        // .//GEN-LAST:_deleteRelatedObjects_FormUsage_1
        // .//GEN-BEGIN:_deleteRelatedObjects_FormUsage_5_be
        Collection col = uow.query(criteria);
        Iterator itr = col.iterator();
        if (itr.hasNext()) {
            col.clear();
            if (log.isDebugEnabled())
                log.debug("The related formUsage object having 'Restricted Delete Constraint' was found. Delete cannot be performed");
            if (appExps == null)
                appExps = new ApplicationExceptions();
            appExps.add(new RelatedDomainObjectFoundException(FormUsageMeta.getLabelToken()));
        }
    // .//GEN-END:_deleteRelatedObjects_FormUsage_5_be
    // .//GEN-BEGIN:_deleteRelatedObjects_FormUsage_6_be
    }
    // .//GEN-BEGIN:_deleteRelatedObjects_2_be
    if (appExps != null)
        throw appExps;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) Criteria(org.jaffa.persistence.Criteria) RelatedDomainObjectFoundException(org.jaffa.exceptions.RelatedDomainObjectFoundException)

Example 2 with RelatedDomainObjectFoundException

use of org.jaffa.exceptions.RelatedDomainObjectFoundException in project jaffa-framework by jaffa-projects.

the class FormEventMaintenanceTx method deleteRelatedObjects.

// .//GEN-END:_addRelatedDtosToRetrieveOut_2_be
// .//GEN-BEGIN:_deleteRelatedObjects_1_be
/**
 * Delete the related domain objects if the 'Cascading' constraint is specified. Throw an exception in case 'Restricted' constraint is specified.
 */
private void deleteRelatedObjects(UOW uow, FormEventMaintenanceDeleteInDto input, FormEvent formEvent) throws FrameworkException, ApplicationExceptions {
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_deleteRelatedObjects_FormUsage_1_be
    if (formEvent.getEventName() != null) {
        Criteria criteria = new Criteria();
        criteria.setTable(FormUsageMeta.getName());
        criteria.addCriteria(FormUsageMeta.EVENT_NAME, formEvent.getEventName());
        // .//GEN-END:_deleteRelatedObjects_FormUsage_1_be
        // Add custom code to set the criteria before the query//GEN-FIRST:_deleteRelatedObjects_FormUsage_1
        // .//GEN-LAST:_deleteRelatedObjects_FormUsage_1
        // .//GEN-BEGIN:_deleteRelatedObjects_FormUsage_5_be
        Collection col = uow.query(criteria);
        Iterator itr = col.iterator();
        if (itr.hasNext()) {
            col.clear();
            if (log.isDebugEnabled())
                log.debug("The related formUsage object having 'Restricted Delete Constraint' was found. Delete cannot be performed");
            if (appExps == null)
                appExps = new ApplicationExceptions();
            appExps.add(new RelatedDomainObjectFoundException(FormUsageMeta.getLabelToken()));
        }
    // .//GEN-END:_deleteRelatedObjects_FormUsage_5_be
    // .//GEN-BEGIN:_deleteRelatedObjects_FormUsage_6_be
    }
    // .//GEN-BEGIN:_deleteRelatedObjects_2_be
    if (appExps != null)
        throw appExps;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) Criteria(org.jaffa.persistence.Criteria) RelatedDomainObjectFoundException(org.jaffa.exceptions.RelatedDomainObjectFoundException)

Example 3 with RelatedDomainObjectFoundException

use of org.jaffa.exceptions.RelatedDomainObjectFoundException in project jaffa-framework by jaffa-projects.

the class Condition 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) {
        // Stop the deletion !!
        throw new PreDeleteFailedException(null, new RelatedDomainObjectFoundException(AssetMeta.getLabelToken()));
    }
    Item[] itemArray = null;
    try {
        itemArray = getItemArray();
    } catch (FrameworkException e) {
        throw new PreDeleteFailedException(null, e);
    }
    if (itemArray != null && itemArray.length > 0) {
        // Stop the deletion !!
        throw new PreDeleteFailedException(null, new RelatedDomainObjectFoundException(ItemMeta.getLabelToken()));
    }
}
Also used : Item(org.jaffa.persistence.domainobjects.Item) FrameworkException(org.jaffa.exceptions.FrameworkException) Asset(org.jaffa.persistence.domainobjects.Asset) RelatedDomainObjectFoundException(org.jaffa.exceptions.RelatedDomainObjectFoundException)

Example 4 with RelatedDomainObjectFoundException

use of org.jaffa.exceptions.RelatedDomainObjectFoundException 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)

Example 5 with RelatedDomainObjectFoundException

use of org.jaffa.exceptions.RelatedDomainObjectFoundException in project jaffa-framework by jaffa-projects.

the class FormGroup 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 {
    FormUsage[] formUsageArray = null;
    try {
        formUsageArray = getFormUsageArray();
    } catch (FrameworkException e) {
        throw new PreDeleteFailedException(null, e);
    }
    if (formUsageArray != null && formUsageArray.length > 0) {
        // Stop the deletion !!
        throw new PreDeleteFailedException(null, new RelatedDomainObjectFoundException(FormUsageMeta.getLabelToken()));
    }
    FormDefinition[] formDefinitionArray = null;
    try {
        formDefinitionArray = getFormDefinitionArray();
    } catch (FrameworkException e) {
        throw new PreDeleteFailedException(null, e);
    }
    if (formDefinitionArray != null && formDefinitionArray.length > 0) {
        try {
            // Perform cascade deletes
            for (int i = 0; i < formDefinitionArray.length; i++) getUOW().delete(formDefinitionArray[i]);
        } catch (Exception e) {
            throw new PreDeleteFailedException(null, e);
        }
    }
}
Also used : FrameworkException(org.jaffa.exceptions.FrameworkException) FormDefinition(org.jaffa.modules.printing.domain.FormDefinition) 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) FormUsage(org.jaffa.modules.printing.domain.FormUsage)

Aggregations

RelatedDomainObjectFoundException (org.jaffa.exceptions.RelatedDomainObjectFoundException)6 FrameworkException (org.jaffa.exceptions.FrameworkException)4 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)3 DuplicateKeyException (org.jaffa.exceptions.DuplicateKeyException)3 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)2 Criteria (org.jaffa.persistence.Criteria)2 Asset (org.jaffa.persistence.domainobjects.Asset)2 Item (org.jaffa.persistence.domainobjects.Item)2 FormDefinition (org.jaffa.modules.printing.domain.FormDefinition)1 FormUsage (org.jaffa.modules.printing.domain.FormUsage)1 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)1 PrinterDefinition (org.jaffa.modules.printing.domain.PrinterDefinition)1 PartAdditional (org.jaffa.persistence.domainobjects.PartAdditional)1 PartPicture (org.jaffa.persistence.domainobjects.PartPicture)1 PartRemarks (org.jaffa.persistence.domainobjects.PartRemarks)1 PartRemarksPicture (org.jaffa.persistence.domainobjects.PartRemarksPicture)1