Search in sources :

Example 1 with ApplicationExceptions

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

the class FormGroupMaintenanceTx method create.

// .//GEN-END:_prevalidateCreate_1_be
// .//GEN-BEGIN:_create_1_be
/**
 * Persists a new instance of FormGroup.
 * @param input The new values for the domain object.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details.
 */
public FormGroupMaintenanceRetrieveOutDto create(FormGroupMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + (input != null ? input.toString() : null));
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Do not allow a Duplicate record
        duplicateCheck(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Create the domain object
        FormGroup domain = createDomain(uow, input, false);
        uow.add(domain);
        // Perform post create processing
        postCreate(uow, input, domain, false);
        // Commit the changes
        uow.commit();
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Successfully created the domain object. Now retrieving the object details.");
        // Build the outbound dto by performing a retrieve
        FormGroupMaintenanceRetrieveInDto retrieveInDto = new FormGroupMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setFormName(input.getFormName());
        FormGroupMaintenanceRetrieveOutDto output = retrieve(retrieveInDto);
        return output;
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) FormGroup(org.jaffa.modules.printing.domain.FormGroup) UOW(org.jaffa.persistence.UOW)

Example 2 with ApplicationExceptions

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

the class FormGroupMaintenanceTx method prevalidateCreate.

// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_prevalidateCreate_1_be
/**
 * This method is used to perform prevalidations before creating a new instance of FormGroup.
 * @param input The new values for the domain object.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details.
 */
public FormGroupMaintenancePrevalidateOutDto prevalidateCreate(FormGroupMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + (input != null ? input.toString() : null));
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Do not allow a Duplicate record
        duplicateCheck(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Create the domain object
        FormGroup domain = createDomain(uow, input, true);
        // Perform post create processing
        postCreate(uow, input, domain, true);
        // Build the outbound dto
        FormGroupMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Output: " + (output != null ? output.toString() : null));
        return output;
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) FormGroup(org.jaffa.modules.printing.domain.FormGroup) UOW(org.jaffa.persistence.UOW)

Example 3 with ApplicationExceptions

use of org.jaffa.exceptions.ApplicationExceptions 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 4 with ApplicationExceptions

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

the class FormGroupMaintenanceTx method load.

// .//GEN-END:_preprocessDelete_2_be
// .//GEN-BEGIN:_loadDelete_1_be
/**
 * Retrieve the domain object.
 */
private FormGroup load(UOW uow, FormGroupMaintenanceDeleteInDto input) throws FrameworkException, ApplicationExceptions {
    FormGroup domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(FormGroupMeta.getName());
    // .//GEN-END:_loadDelete_1_be
    // Add custom criteria//GEN-FIRST:_loadDelete_1
    // .//GEN-LAST:_loadDelete_1
    // .//GEN-BEGIN:_loadDelete_2_be
    criteria.addCriteria(FormGroupMeta.FORM_NAME, input.getFormName());
    criteria.setLocking(Criteria.LOCKING_PARANOID);
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (FormGroup) itr.next();
    // .//GEN-BEGIN:_loadDelete_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(FormGroupMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) FormGroup(org.jaffa.modules.printing.domain.FormGroup) Criteria(org.jaffa.persistence.Criteria)

Example 5 with ApplicationExceptions

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

the class FormGroupMaintenanceTx method retrieve.

// .//GEN-END:_create_1_be
// .//GEN-BEGIN:_retrieve_1_be
/**
 * Returns the details for FormGroup.
 * @param input The criteria based on which an object will be retrieved.
 * @throws ApplicationExceptions This will be thrown if the criteria contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details. A null indicates, the object was not found.
 */
public FormGroupMaintenanceRetrieveOutDto retrieve(FormGroupMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + (input != null ? input.toString() : null));
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Retrieve the object
        FormGroup domain = load(uow, input);
        // Convert the domain objects into the outbound dto
        FormGroupMaintenanceRetrieveOutDto output = buildRetrieveOutDto(uow, input, domain);
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Output: " + (output != null ? output.toString() : null));
        return output;
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) FormGroup(org.jaffa.modules.printing.domain.FormGroup) UOW(org.jaffa.persistence.UOW)

Aggregations

ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)575 FrameworkException (org.jaffa.exceptions.FrameworkException)307 FormKey (org.jaffa.presentation.portlet.FormKey)205 ApplicationException (org.jaffa.exceptions.ApplicationException)116 GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)104 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)103 UOW (org.jaffa.persistence.UOW)82 Criteria (org.jaffa.persistence.Criteria)66 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)59 MandatoryFieldException (org.jaffa.datatypes.exceptions.MandatoryFieldException)23 ValidationException (org.jaffa.datatypes.ValidationException)21 Iterator (java.util.Iterator)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 Method (java.lang.reflect.Method)15 FormTemplate (org.jaffa.modules.printing.domain.FormTemplate)15 DuplicateKeyException (org.jaffa.exceptions.DuplicateKeyException)14 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)11 MalformedURLException (java.net.MalformedURLException)10 UserRequest (org.jaffa.applications.jaffa.modules.user.domain.UserRequest)10 PrinterDefinition (org.jaffa.modules.printing.domain.PrinterDefinition)10