Search in sources :

Example 76 with ApplicationException

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

the class FormGroupMaintenanceTx method update.

// .//GEN-END:_prevalidateUpdate_1_be
// .//GEN-BEGIN:_update_1_be
/**
 * Updates an existing 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 update(FormGroupMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + input);
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Retrieve the object
        FormGroup domain = load(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Update the domain object
        updateDomain(uow, input, domain, false);
        uow.update(domain);
        // Commit the changes
        uow.commit();
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Successfully updated 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 77 with ApplicationException

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

the class FormGroupMaintenanceComponent method removeFormUsageEntry.

// .//GEN-END:_loadPrevalidateOutDto_2_be
// All the custom code goes here//GEN-FIRST:_custom
// Remove the select FormUsage rows from the grid
public void removeFormUsageEntry(ArrayList arr, GridModel model) throws FrameworkException, ApplicationExceptions {
    for (Iterator itr = model.getRows().iterator(); itr.hasNext(); ) {
        GridModelRow row = (GridModelRow) itr.next();
        for (int j = 0; j < m_relatedObjectFormUsageDto.length; j++) {
            if (m_relatedObjectFormUsageDto[j].getEventName().equals(((String) row.getElement("eventName")))) {
                m_relatedObjectFormUsageDto[j].setFormAlternate(((EditBoxModel) row.getElement("formAlternate")).getValue());
                try {
                    EditBoxModel copiesElement = (EditBoxModel) row.getElement("copies");
                    if (copiesElement == null) {
                        throw new ApplicationExceptions(new ApplicationException("exception.Jaffa.Printing.FormGroupMaintenance.copiesValidation") {
                        });
                    }
                    String copies = copiesElement.getValue();
                    if (copies == null) {
                        throw new ApplicationExceptions(new ApplicationException("exception.Jaffa.Printing.FormGroupMaintenance.copiesValidation") {
                        });
                    }
                    m_relatedObjectFormUsageDto[j].setCopies(Long.valueOf(copies));
                } catch (NumberFormatException ne) {
                    throw new ApplicationExceptions(new ApplicationException("exception.Jaffa.Printing.FormGroupMaintenance.copiesValidation") {
                    });
                }
                break;
            }
        }
    }
    ArrayList relatedFormUsageEntryDto = new ArrayList(Arrays.asList(m_relatedObjectFormUsageDto));
    String tc = null;
    for (int i = 0; i < arr.size(); i++) {
        tc = (String) arr.get(i);
        for (int j = 0; j < relatedFormUsageEntryDto.size(); j++) {
            FormUsageDto usageDto = (FormUsageDto) relatedFormUsageEntryDto.get(j);
            if ((usageDto.getEventName()).equals(tc)) {
                relatedFormUsageEntryDto.remove(j);
                break;
            }
        }
    }
    m_relatedObjectFormUsageDto = (FormUsageDto[]) relatedFormUsageEntryDto.toArray(new FormUsageDto[0]);
    uncacheWidgetModels();
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) org.jaffa.components.maint(org.jaffa.components.maint)

Example 78 with ApplicationException

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

the class FormGroupMaintenanceTx method preprocess.

// .//GEN-END:_updateDomain_3_be
// .//GEN-BEGIN:_preprocessDelete_1_be
/**
 * Preprocess the input for the delete method.
 */
private void preprocess(UOW uow, FormGroupMaintenanceDeleteInDto input) throws FrameworkException, ApplicationExceptions {
    if (input.getFormName() != null) {
        Criteria criteria = new Criteria();
        criteria.setTable(FormDefinitionMeta.getName());
        criteria.addCriteria(FormDefinitionMeta.FORM_NAME, input.getFormName());
        Collection col = uow.query(criteria);
        Iterator itr = col.iterator();
        if (itr.hasNext()) {
            throw new ApplicationExceptions(new ApplicationException("exception.Jaffa.Printing.FormGroupMaintenance.formNameExistInFormDefinitions") {
            });
        }
    }
// .//GEN-LAST:_preprocessDelete_1
// .//GEN-BEGIN:_preprocessDelete_2_be
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) Criteria(org.jaffa.persistence.Criteria)

Example 79 with ApplicationException

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

the class UserMaintenanceTx method update.

// .//GEN-END:_prevalidateUpdate_1_be
// .//GEN-BEGIN:_update_1_be
/**
 * Updates an existing instance of User.
 * @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 UserMaintenanceRetrieveOutDto update(UserMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + input);
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Retrieve the object
        User domain = load(uow, input);
        // Ensure the domain object has not been modified
        domainObjectChangedTest(input.getPerformDirtyReadCheck(), domain, input.getLastUpdatedOn());
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Update the domain object
        updateDomain(uow, input, domain, false);
        uow.update(domain);
        // Commit the changes
        uow.commit();
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Successfully updated the domain object. Now retrieving the object details.");
        // Build the outbound dto by performing a retrieve
        UserMaintenanceRetrieveInDto retrieveInDto = new UserMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setUserName(input.getUserName());
        UserMaintenanceRetrieveOutDto 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 : User(org.jaffa.applications.jaffa.modules.admin.domain.User) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UOW(org.jaffa.persistence.UOW)

Example 80 with ApplicationException

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

the class UserMaintenanceTx method retrieve.

// .//GEN-END:_create_1_be
// .//GEN-BEGIN:_retrieve_1_be
/**
 * Returns the details for User.
 * @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 UserMaintenanceRetrieveOutDto retrieve(UserMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + input);
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Retrieve the object
        User domain = load(uow, input);
        // Convert the domain objects into the outbound dto
        UserMaintenanceRetrieveOutDto output = buildRetrieveOutDto(uow, input, domain);
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Output: " + output);
        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 : User(org.jaffa.applications.jaffa.modules.admin.domain.User) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UOW(org.jaffa.persistence.UOW)

Aggregations

ApplicationException (org.jaffa.exceptions.ApplicationException)125 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)114 FrameworkException (org.jaffa.exceptions.FrameworkException)97 UOW (org.jaffa.persistence.UOW)79 InvocationTargetException (java.lang.reflect.InvocationTargetException)12 FormTemplate (org.jaffa.modules.printing.domain.FormTemplate)11 Criteria (org.jaffa.persistence.Criteria)11 Method (java.lang.reflect.Method)10 Iterator (java.util.Iterator)10 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 GraphMapping (org.jaffa.beans.moulding.mapping.GraphMapping)6 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)6 PrinterDefinition (org.jaffa.modules.printing.domain.PrinterDefinition)6 PrinterOutputType (org.jaffa.modules.printing.domain.PrinterOutputType)6 User (org.jaffa.applications.jaffa.modules.admin.domain.User)5 UserRequest (org.jaffa.applications.jaffa.modules.user.domain.UserRequest)5 UserTimeEntry (org.jaffa.applications.test.modules.time.domain.UserTimeEntry)5 Attachment (org.jaffa.components.attachment.domain.Attachment)5