use of org.jaffa.modules.printing.domain.OutputCommand in project jaffa-framework by jaffa-projects.
the class PrinterOutputTypeViewerTx method addRelatedDtos.
// .//GEN-END:_buildDto_3_be
// .//GEN-BEGIN:_addRelatedDtos_1_be
private void addRelatedDtos(UOW uow, PrinterOutputTypeViewerOutDto output, PrinterOutputType printerOutputType) throws UOWException {
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_1_be
if (printerOutputType.getOutputType() != null) {
Criteria criteria = new Criteria();
criteria.setTable(OutputCommandMeta.getName());
criteria.addCriteria(OutputCommandMeta.OUTPUT_TYPE, printerOutputType.getOutputType());
criteria.addOrderBy("OutputCommandId", Criteria.ORDER_BY_ASC);
// .//GEN-END:_addRelatedDtos_OutputCommand_1_be
// Add custom code to set the criteria before the query //GEN-FIRST:_addRelatedDtos_OutputCommand_1
// .//GEN-LAST:_addRelatedDtos_OutputCommand_1
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_2_be
Iterator itr = uow.query(criteria).iterator();
while (itr.hasNext()) {
OutputCommand outputCommand = (OutputCommand) itr.next();
OutputCommandDto dto = new OutputCommandDto();
// .//GEN-END:_addRelatedDtos_OutputCommand_2_be
// Add custom code before all the setters //GEN-FIRST:_addRelatedDtos_OutputCommand_2
// .//GEN-LAST:_addRelatedDtos_OutputCommand_2
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_OutputCommandId_1_be
dto.setOutputCommandId(outputCommand.getOutputCommandId());
// .//GEN-END:_addRelatedDtos_OutputCommand_OutputCommandId_1_be
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_OutputType_1_be
dto.setOutputType(outputCommand.getOutputType());
// .//GEN-END:_addRelatedDtos_OutputCommand_OutputType_1_be
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_SequenceNo_1_be
dto.setSequenceNo(outputCommand.getSequenceNo());
// .//GEN-END:_addRelatedDtos_OutputCommand_SequenceNo_1_be
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_OsPattern_1_be
dto.setOsPattern(outputCommand.getOsPattern());
// .//GEN-END:_addRelatedDtos_OutputCommand_OsPattern_1_be
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_CommandLine_1_be
dto.setCommandLine(outputCommand.getCommandLine());
// .//GEN-END:_addRelatedDtos_OutputCommand_CommandLine_1_be
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_CreatedOn_1_be
dto.setCreatedOn(outputCommand.getCreatedOn());
// .//GEN-END:_addRelatedDtos_OutputCommand_CreatedOn_1_be
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_CreatedBy_1_be
dto.setCreatedBy(outputCommand.getCreatedBy());
// .//GEN-END:_addRelatedDtos_OutputCommand_CreatedBy_1_be
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_LastChangedOn_1_be
dto.setLastChangedOn(outputCommand.getLastChangedOn());
// .//GEN-END:_addRelatedDtos_OutputCommand_LastChangedOn_1_be
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_LastChangedBy_1_be
dto.setLastChangedBy(outputCommand.getLastChangedBy());
// .//GEN-END:_addRelatedDtos_OutputCommand_LastChangedBy_1_be
// Add custom code to pass values to the dto //GEN-FIRST:_addRelatedDtos_OutputCommand_3
// .//GEN-LAST:_addRelatedDtos_OutputCommand_3
// .//GEN-BEGIN:_addRelatedDtos_OutputCommand_3_be
output.addOutputCommand(dto);
}
}
// .//GEN-END:_addRelatedDtos_OutputCommand_3_be
// .//GEN-BEGIN:_addRelatedDtos_2_be
}
use of org.jaffa.modules.printing.domain.OutputCommand 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.modules.printing.domain.OutputCommand in project jaffa-framework by jaffa-projects.
the class OutputCommandFinderTx method buildDto.
// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private OutputCommandFinderOutDto buildDto(UOW uow, Collection results, OutputCommandFinderInDto input) throws UOWException {
OutputCommandFinderOutDto output = new OutputCommandFinderOutDto();
int maxRecords = input.getMaxRecords() != null ? input.getMaxRecords().intValue() : 0;
int counter = 0;
for (Iterator i = results.iterator(); i.hasNext(); ) {
if (++counter > maxRecords && maxRecords > 0) {
output.setMoreRecordsExist(Boolean.TRUE);
break;
}
OutputCommandFinderOutRowDto row = new OutputCommandFinderOutRowDto();
OutputCommand outputCommand = (OutputCommand) i.next();
// .//GEN-END:_buildDto_1_be
// Add custom code before all the setters //GEN-FIRST:_buildDto_1
// .//GEN-LAST:_buildDto_1
// .//GEN-BEGIN:_buildDto_OutputCommandId_1_be
row.setOutputCommandId(outputCommand.getOutputCommandId());
// .//GEN-END:_buildDto_OutputCommandId_1_be
// .//GEN-BEGIN:_buildDto_OutputType_1_be
row.setOutputType(outputCommand.getOutputType());
// .//GEN-END:_buildDto_OutputType_1_be
// .//GEN-BEGIN:_buildDto_SequenceNo_1_be
row.setSequenceNo(outputCommand.getSequenceNo());
// .//GEN-END:_buildDto_SequenceNo_1_be
// .//GEN-BEGIN:_buildDto_OsPattern_1_be
row.setOsPattern(outputCommand.getOsPattern());
// .//GEN-END:_buildDto_OsPattern_1_be
// .//GEN-BEGIN:_buildDto_CommandLine_1_be
row.setCommandLine(outputCommand.getCommandLine());
// .//GEN-END:_buildDto_CommandLine_1_be
// .//GEN-BEGIN:_buildDto_CreatedOn_1_be
row.setCreatedOn(outputCommand.getCreatedOn());
// .//GEN-END:_buildDto_CreatedOn_1_be
// .//GEN-BEGIN:_buildDto_CreatedBy_1_be
row.setCreatedBy(outputCommand.getCreatedBy());
// .//GEN-END:_buildDto_CreatedBy_1_be
// .//GEN-BEGIN:_buildDto_LastChangedOn_1_be
row.setLastChangedOn(outputCommand.getLastChangedOn());
// .//GEN-END:_buildDto_LastChangedOn_1_be
// .//GEN-BEGIN:_buildDto_LastChangedBy_1_be
row.setLastChangedBy(outputCommand.getLastChangedBy());
// .//GEN-END:_buildDto_LastChangedBy_1_be
// Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
// .//GEN-LAST:_buildDto_2
// .//GEN-BEGIN:_buildDto_3_be
output.addRows(row);
}
return output;
}
use of org.jaffa.modules.printing.domain.OutputCommand in project jaffa-framework by jaffa-projects.
the class PrinterOutputTypeMaintenanceTx 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, PrinterOutputTypeMaintenanceDeleteInDto input, PrinterOutputType printerOutputType) throws FrameworkException, ApplicationExceptions {
ApplicationExceptions appExps = null;
// .//GEN-BEGIN:_deleteRelatedObjects_OutputCommand_1_be
if (printerOutputType.getOutputType() != null) {
Criteria criteria = new Criteria();
criteria.setTable(OutputCommandMeta.getName());
criteria.addCriteria(OutputCommandMeta.OUTPUT_TYPE, printerOutputType.getOutputType());
criteria.setLocking(Criteria.LOCKING_PARANOID);
// .//GEN-END:_deleteRelatedObjects_OutputCommand_1_be
// Add custom code to set the criteria before the query //GEN-FIRST:_deleteRelatedObjects_OutputCommand_1
// .//GEN-LAST:_deleteRelatedObjects_OutputCommand_1
// .//GEN-BEGIN:_deleteRelatedObjects_OutputCommand_2_be
Iterator itr = uow.query(criteria).iterator();
while (itr.hasNext()) {
OutputCommand outputCommand = (OutputCommand) itr.next();
if (log.isDebugEnabled())
log.debug("Invoking the org.jaffa.modules.printing.components.outputcommandmaintenance.tx.OutputCommandMaintenanceTx class to cascade delete the related object " + outputCommand);
org.jaffa.modules.printing.components.outputcommandmaintenance.dto.OutputCommandMaintenanceDeleteInDto deleteInDto = new org.jaffa.modules.printing.components.outputcommandmaintenance.dto.OutputCommandMaintenanceDeleteInDto();
deleteInDto.setHeaderDto(input.getHeaderDto());
deleteInDto.setOutputCommandId(outputCommand.getOutputCommandId());
org.jaffa.modules.printing.components.outputcommandmaintenance.tx.OutputCommandMaintenanceTx tx = new org.jaffa.modules.printing.components.outputcommandmaintenance.tx.OutputCommandMaintenanceTx();
// .//GEN-END:_deleteRelatedObjects_OutputCommand_2_be
// Add custom code to set any addtional criteria before the delete //GEN-FIRST:_deleteRelatedObjects_OutputCommand_2
// .//GEN-LAST:_deleteRelatedObjects_OutputCommand_2
// .//GEN-BEGIN:_deleteRelatedObjects_OutputCommand_3_be
tx.delete(deleteInDto, uow);
tx.destroy();
}
// .//GEN-END:_deleteRelatedObjects_OutputCommand_3_be
// .//GEN-BEGIN:_deleteRelatedObjects_OutputCommand_6_be
}
// .//GEN-BEGIN:_deleteRelatedObjects_2_be
if (appExps != null)
throw appExps;
}
use of org.jaffa.modules.printing.domain.OutputCommand in project jaffa-framework by jaffa-projects.
the class OutputCommandMaintenanceTx 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 OutputCommand.
* @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 OutputCommandMaintenancePrevalidateOutDto prevalidateCreate(OutputCommandMaintenanceCreateInDto 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
OutputCommand domain = createDomain(uow, input, true);
domain = postCreate(uow, input, domain, true);
// Build the outbound dto
OutputCommandMaintenancePrevalidateOutDto 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();
}
}
Aggregations