Search in sources :

Example 96 with ApplicationException

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

the class PrinterOutputTypeMaintenanceTx method delete.

// .//GEN-END:_update_1_be
// .//GEN-BEGIN:_delete_1_be
/**
 * Deletes an existing instance of PrinterOutputType.
 * @param input The key values for the domain object to be deleted.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 */
public void delete(PrinterOutputTypeMaintenanceDeleteInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // create the UOW
        uow = new UOW();
        // invoke the delete passing the UOW
        delete(input, uow);
        // Commit the changes
        uow.commit();
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Successfully deleted the domain object");
    } 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) UOW(org.jaffa.persistence.UOW)

Example 97 with ApplicationException

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

the class PrinterOutputTypeMaintenanceTx method update.

// .//GEN-END:_prevalidateUpdate_1_be
// .//GEN-BEGIN:_update_1_be
/**
 * Updates an existing instance of PrinterOutputType.
 * @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 PrinterOutputTypeMaintenanceRetrieveOutDto update(PrinterOutputTypeMaintenanceUpdateInDto 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
        PrinterOutputType domain = load(uow, input);
        // Ensure the domain object has not been modified
        domainObjectChangedTest(input.getPerformDirtyReadCheck(), domain, input.getLastChangedOn());
        // 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
        PrinterOutputTypeMaintenanceRetrieveInDto retrieveInDto = new PrinterOutputTypeMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setOutputType(input.getOutputType());
        PrinterOutputTypeMaintenanceRetrieveOutDto 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 : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UOW(org.jaffa.persistence.UOW)

Example 98 with ApplicationException

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

the class PrinterOutputTypeMaintenanceTx method retrieve.

// .//GEN-END:_create_1_be
// .//GEN-BEGIN:_retrieve_1_be
/**
 * Returns the details for PrinterOutputType.
 * @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 PrinterOutputTypeMaintenanceRetrieveOutDto retrieve(PrinterOutputTypeMaintenanceRetrieveInDto 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
        PrinterOutputType domain = load(uow, input);
        // Convert the domain objects into the outbound dto
        PrinterOutputTypeMaintenanceRetrieveOutDto 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 : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UOW(org.jaffa.persistence.UOW)

Example 99 with ApplicationException

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

the class PrinterOutputTypeMaintenanceTx method create.

// .//GEN-END:_prevalidateCreate_1_be
// .//GEN-BEGIN:_create_1_be
/**
 * Persists a new instance of PrinterOutputType.
 * @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 PrinterOutputTypeMaintenanceRetrieveOutDto create(PrinterOutputTypeMaintenanceCreateInDto 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);
        // Do not allow a Duplicate record
        duplicateCheck(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Create the domain object
        PrinterOutputType domain = createDomain(uow, input, false);
        uow.add(domain);
        domain = 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.");
        if (input.getOutputType() == null) {
            if (log.isDebugEnabled())
                log.debug("The Key is not set completely. Probably using AutoGenerated keys. Cannot re-retrieve the object details. Returning NULL instead");
            return null;
        }
        // Build the outbound dto by performing a retrieve
        PrinterOutputTypeMaintenanceRetrieveInDto retrieveInDto = new PrinterOutputTypeMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setOutputType(input.getOutputType());
        PrinterOutputTypeMaintenanceRetrieveOutDto 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 : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UOW(org.jaffa.persistence.UOW)

Example 100 with ApplicationException

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

the class DomainDataBean method populate.

public void populate() throws FrameworkException, ApplicationExceptions {
    // Lookup the "findByPK" method for this domain object
    log.debug("Get the findByPK method for " + m_beanClass.getName());
    try {
        for (Method method : m_beanClass.getDeclaredMethods()) {
            if (method.getName().equals("findByPK") && method.getParameterTypes()[0].equals(UOW.class) && method.getParameterTypes().length == m_keys.size() + 1) {
                // We have found a sutable method
                log.debug("Found Method : " + method.toString());
                Object[] args = new Object[method.getParameterTypes().length];
                args[0] = (UOW) null;
                int argCount = 1;
                for (Object arg : m_keys) {
                    log.debug("    Argument " + argCount + " = " + arg);
                    args[argCount++] = arg;
                }
                try {
                    m_domainObject = method.invoke(null, args);
                    log.debug("Found Domain Object : " + m_domainObject);
                } catch (IllegalAccessException e) {
                    log.error("Can't invoke " + method.toString(), e);
                    throw new EngineProcessingException(e.getMessage(), e);
                } catch (InvocationTargetException e) {
                    log.error("Can't invoke " + method.toString(), e);
                    throw new EngineProcessingException(e.getMessage(), e);
                }
                if (m_domainObject == null) {
                    throw new DataNotFoundException(new String[] { "No Method", m_beanClass.getName() });
                }
                return;
            }
        }
        // Error - method not found
        throw new DataNotFoundException("No findByPK method");
    } catch (ApplicationException e) {
        throw new ApplicationExceptions(e);
    }
}
Also used : DataNotFoundException(org.jaffa.modules.printing.services.exceptions.DataNotFoundException) ApplicationException(org.jaffa.exceptions.ApplicationException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) EngineProcessingException(org.jaffa.modules.printing.services.exceptions.EngineProcessingException)

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