Search in sources :

Example 16 with DomainObjectNotFoundException

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

the class UserRequestMaintenanceTx method load.

// .//GEN-END:_preprocessRetrieve_2_be
// .//GEN-BEGIN:_loadRetrieve_1_be
/**
 * Retrieve the domain object.
 */
private UserRequest load(UOW uow, UserRequestMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
    UserRequest domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(UserRequestMeta.getName());
    // .//GEN-END:_loadRetrieve_1_be
    // Add custom criteria //GEN-FIRST:_loadRetrieve_1
    // .//GEN-LAST:_loadRetrieve_1
    // .//GEN-BEGIN:_loadRetrieve_2_be
    criteria.addCriteria(UserRequestMeta.REQUEST_ID, input.getRequestId());
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (UserRequest) itr.next();
    // .//GEN-BEGIN:_loadRetrieve_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(UserRequestMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) Criteria(org.jaffa.persistence.Criteria) UserRequest(org.jaffa.applications.jaffa.modules.user.domain.UserRequest)

Example 17 with DomainObjectNotFoundException

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

the class UserRequestMaintenanceTx method load.

// .//GEN-END:_preprocessUpdate_2_be
// .//GEN-BEGIN:_loadUpdate_1_be
/**
 * Retrieve the domain object.
 */
private UserRequest load(UOW uow, UserRequestMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    UserRequest domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(UserRequestMeta.getName());
    // .//GEN-END:_loadUpdate_1_be
    // Add custom criteria //GEN-FIRST:_loadUpdate_1
    // .//GEN-LAST:_loadUpdate_1
    // .//GEN-BEGIN:_loadUpdate_2_be
    criteria.addCriteria(UserRequestMeta.REQUEST_ID, input.getRequestId());
    criteria.setLocking(Criteria.LOCKING_PARANOID);
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (UserRequest) itr.next();
    // .//GEN-BEGIN:_loadUpdate_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(UserRequestMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) Criteria(org.jaffa.persistence.Criteria) UserRequest(org.jaffa.applications.jaffa.modules.user.domain.UserRequest)

Example 18 with DomainObjectNotFoundException

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

the class UserRequestViewerComponent method doInquiry.

// .//GEN-END:_display_2_be
// .//GEN-BEGIN:_inquiry_1_be
private void doInquiry() throws ApplicationExceptions, FrameworkException {
    UserRequestViewerInDto inputDto = new UserRequestViewerInDto();
    // .//GEN-END:_inquiry_1_be
    // Add custom code before building the input dto //GEN-FIRST:_inquiry_1
    // .//GEN-LAST:_inquiry_1
    // .//GEN-BEGIN:_inquiry_2_be
    inputDto.setRequestId(m_requestId);
    inputDto.setHeaderDto(createHeaderDto());
    // create the Tx
    if (m_tx == null)
        m_tx = (IUserRequestViewer) Factory.createObject(IUserRequestViewer.class);
    // .//GEN-END:_inquiry_2_be
    // Add custom code before invoking the Tx //GEN-FIRST:_inquiry_2
    // .//GEN-LAST:_inquiry_2
    // .//GEN-BEGIN:_inquiry_3_be
    // now get the details
    m_outputDto = m_tx.read(inputDto);
    // uncache the widgets
    getUserSession().getWidgetCache(getComponentId()).clear();
    // throw an exception if the output is null
    if (m_outputDto == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(UserRequestMeta.getLabelToken()));
        throw appExps;
    }
}
Also used : IUserRequestViewer(org.jaffa.applications.jaffa.modules.user.components.userrequestviewer.IUserRequestViewer) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) UserRequestViewerInDto(org.jaffa.applications.jaffa.modules.user.components.userrequestviewer.dto.UserRequestViewerInDto)

Example 19 with DomainObjectNotFoundException

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

the class FormDelivery method sendToPrinter.

/**
 * Send the generated document to the specified printer
 * @param printerId Printer name, should be defined in PrinterDefinitions
 * @param copies Number of copies to print
 * @param document Source file to print
 * @throws ApplicationExceptions Thrown if any funtional issue ocurred when executing
 * @throws FrameworkException Thrown if any framework issue ocurred when executing
 */
public static void sendToPrinter(String printerId, int copies, File document) throws FrameworkException, ApplicationExceptions {
    UOW uow = new UOW();
    try {
        // Read the printer definition
        PrinterDefinition printer = PrinterDefinition.findByPK(uow, printerId);
        if (printer == null) {
            log.error("Unknown printer in print request : " + printerId);
            throw new ApplicationExceptions(new DomainObjectNotFoundException(PrinterDefinitionMeta.getLabelToken()));
        }
        PrinterOutputType outputType = printer.getPrinterOutputTypeObject();
        // See if this is direct printing
        if (Boolean.TRUE.equals(outputType.getDirectPrinting())) {
            printDirect(printer, document, copies);
        } else {
            // Find an external command line that will print this document
            String commandLine = null;
            String os = System.getProperty("os.name");
            for (OutputCommand command : outputType.getOutputCommandArray()) {
                if (Pattern.matches(command.getOsPattern(), os)) {
                    commandLine = command.getCommandLine();
                    break;
                }
            }
            if (commandLine == null) {
                log.error("Can't find matching command line for Output Type " + outputType.getOutputType() + " on OS " + os);
                throw new ApplicationExceptions(new DomainObjectNotFoundException(OutputCommandMeta.getLabelToken()));
            }
            // Now try and print the document with the command
            printViaCommand(printer, document, copies, commandLine);
        }
    } catch (ApplicationException e) {
        ApplicationExceptions aes = new ApplicationExceptions();
        aes.add(e);
        throw aes;
    } finally {
        if (uow != null)
            // This UOW should have not been used for updates!!!
            uow.rollback();
    }
}
Also used : PrinterDefinition(org.jaffa.modules.printing.domain.PrinterDefinition) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) ApplicationException(org.jaffa.exceptions.ApplicationException) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) OutputCommand(org.jaffa.modules.printing.domain.OutputCommand) UOW(org.jaffa.persistence.UOW)

Example 20 with DomainObjectNotFoundException

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

the class FormTemplateMaintenanceTx method load.

// .//GEN-END:_preprocessRetrieve_2_be
// .//GEN-BEGIN:_loadRetrieve_1_be
/**
 * Retrieve the domain object.
 */
private FormTemplate load(UOW uow, FormTemplateMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
    FormTemplate domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(FormTemplateMeta.getName());
    // .//GEN-END:_loadRetrieve_1_be
    // Add custom criteria //GEN-FIRST:_loadRetrieve_1
    // .//GEN-LAST:_loadRetrieve_1
    // .//GEN-BEGIN:_loadRetrieve_2_be
    criteria.addCriteria(FormTemplateMeta.FORM_ID, input.getFormId());
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (FormTemplate) itr.next();
    // .//GEN-BEGIN:_loadRetrieve_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(FormTemplateMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) FormTemplate(org.jaffa.modules.printing.domain.FormTemplate) Criteria(org.jaffa.persistence.Criteria)

Aggregations

DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)62 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)57 Criteria (org.jaffa.persistence.Criteria)39 FrameworkException (org.jaffa.exceptions.FrameworkException)10 ApplicationException (org.jaffa.exceptions.ApplicationException)9 Method (java.lang.reflect.Method)6 UOW (org.jaffa.persistence.UOW)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 Iterator (java.util.Iterator)5 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)5 IPersistent (org.jaffa.persistence.IPersistent)5 MultipleDomainObjectsFoundException (org.jaffa.exceptions.MultipleDomainObjectsFoundException)4 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)4 PrinterOutputType (org.jaffa.modules.printing.domain.PrinterOutputType)4 HashMap (java.util.HashMap)3 User (org.jaffa.applications.jaffa.modules.admin.domain.User)3 UserRequest (org.jaffa.applications.jaffa.modules.user.domain.UserRequest)3 UserTimeEntry (org.jaffa.applications.test.modules.time.domain.UserTimeEntry)3 GraphMapping (org.jaffa.beans.moulding.mapping.GraphMapping)3