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;
}
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;
}
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;
}
}
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();
}
}
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;
}
Aggregations