use of org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceTx method buildOutDto.
private FormSelectionMaintenanceOutDto buildOutDto(UOW uow, Collection results, FormSelectionMaintenanceInDto input) throws FrameworkException {
FormSelectionMaintenanceOutDto output = new FormSelectionMaintenanceOutDto();
// key=outputType, value=List of Printers
Map<String, List<String>> printersPerOutputType = null;
String variation = VariationContext.getVariation();
String outputType = null;
String[] keys = new String[6];
if (input.getKey1() != null) {
String[] keyArray = input.getKey1().getValues();
keys[0] = keyArray[0];
}
if (input.getKey2() != null) {
String[] keyArray = input.getKey2().getValues();
keys[1] = keyArray[0];
}
if (input.getKey3() != null) {
String[] keyArray = input.getKey3().getValues();
keys[2] = keyArray[0];
}
if (input.getKey4() != null) {
String[] keyArray = input.getKey4().getValues();
keys[3] = keyArray[0];
}
if (input.getKey5() != null) {
String[] keyArray = input.getKey5().getValues();
keys[4] = keyArray[0];
}
if (input.getKey6() != null) {
String[] keyArray = input.getKey6().getValues();
keys[5] = keyArray[0];
}
if (log.isDebugEnabled())
log.debug("Form Selection building OutDto using Event=" + input.getEvent() + ", key1=" + keys[0] + ", key2=" + keys[1] + ", key3=" + keys[2] + ", key4=" + keys[3] + ", key5=" + keys[4] + ", key6=" + keys[5] + ", variation=" + variation);
for (Iterator i = results.iterator(); i.hasNext(); ) {
FormUsage formUsage = (FormUsage) i.next();
FormDefinition formDefinition = FormProcessor.findFormDefinition(uow, formUsage.getFormName(), formUsage.getFormAlternate(), variation, outputType, keys);
if (formDefinition != null) {
FormSelectionMaintenanceOutRowDto row = new FormSelectionMaintenanceOutRowDto();
row.setFormName(formDefinition.getFormName());
row.setCopies(formUsage.getCopies());
if (input.getEvent() != null) {
String[] mEvent = input.getEvent().getValues();
row.setEvent(mEvent[0]);
}
if (keys[0] != null) {
row.setKey1(keys[0]);
}
if (keys[1] != null) {
row.setKey2(keys[1]);
}
if (keys[2] != null) {
row.setKey3(keys[2]);
}
if (keys[3] != null) {
row.setKey4(keys[3]);
}
if (keys[4] != null) {
row.setKey5(keys[4]);
}
if (keys[5] != null) {
row.setKey6(keys[5]);
}
if (input.getValue1() != null) {
String[] mValue1 = input.getValue1().getValues();
row.setValue1(mValue1[0]);
}
if (input.getValue2() != null) {
String[] mValue2 = input.getValue2().getValues();
row.setValue2(mValue2[0]);
}
if (input.getValue3() != null) {
String[] mValue3 = input.getValue3().getValues();
row.setValue3(mValue3[0]);
}
if (input.getValue4() != null) {
String[] mValue4 = input.getValue4().getValues();
row.setValue4(mValue4[0]);
}
if (input.getValue5() != null) {
String[] mValue5 = input.getValue5().getValues();
row.setValue5(mValue5[0]);
}
if (input.getValue6() != null) {
String[] mValue6 = input.getValue6().getValues();
row.setValue6(mValue6[0]);
}
// Use the form definition selected because it may have selected the "-RL" right-to-left alternate.
if (formUsage.getFormAlternate() != null) {
row.setFormAlternateName(formDefinition.getFormAlternate());
}
row.setVariation(formDefinition.getFormVariation());
row.setAdditionalDataComponent(formDefinition.getAdditionalDataComponent());
// Query on FormGroup to find FormType.
Criteria criteria = new Criteria();
criteria.setTable(FormGroupMeta.getName());
criteria.addCriteria(FormGroupMeta.FORM_NAME, formUsage.getFormName());
Collection col = uow.query(criteria);
Iterator itr = col.iterator();
if (itr.hasNext()) {
FormGroup formGroup = (FormGroup) itr.next();
row.setFormType(formGroup.getFormType());
}
// Default the printer if possible and only if it has not already been initialized
if (row.getPrinter() == null && input.getDefaultPrinters() != null) {
// Construct a Map of valid printers per outputType
if (printersPerOutputType == null)
printersPerOutputType = determinePrintersPerOutputType(uow, input.getDefaultPrinters());
// Get the first printer for an outputType
List<String> printers = printersPerOutputType.get(formDefinition.getOutputType());
if (printers != null && printers.size() >= 0)
row.setPrinter(printers.get(0));
}
if (row.getEmail() == null && (FormPrintFactory.ENGINE_TYPE_ITEXT.equals(row.getFormType()) || FormPrintFactory.ENGINE_TYPE_FOP.equals(row.getFormType())))
row.setEmail(getUserEmail());
output.addRows(row);
}
}
return output;
}
use of org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceTx method findOutDto.
// .//GEN-END:_buildDto_3_be
// All the custom code goes here//GEN-FIRST:_custom
// TODO-SWAT add script event here
/**
* Searches for FormUsage objects.
* @param input The criteria based on which the search will be performed.
* @throws ApplicationExceptions This will be thrown if the criteria contains invalid data.
* @throws FrameworkException Indicates some system error
* @return The search results.
*/
public FormSelectionMaintenanceOutDto findOutDto(FormSelectionMaintenanceInDto input) throws FrameworkException, ApplicationExceptions {
// TODO-SWAT fire script event here
UOW uow = null;
try {
// Print Debug Information for the input
if (log.isDebugEnabled()) {
log.debug("Input: " + input);
}
// create the UOW
uow = new UOW();
// Build the Criteria Object
Criteria criteria = buildCriteria(input, uow);
// Execute The Query
Collection results = uow.query(criteria);
// Convert the domain objects into the outbound dto
FormSelectionMaintenanceOutDto output = buildOutDto(uow, results, input);
// Print Debug Information for the output
if (log.isDebugEnabled()) {
log.debug("Output: " + output);
}
return output;
} finally {
if (uow != null)
uow.rollback();
}
}
use of org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceForm method populateRows.
// .//GEN-END:_doValidate_2_be
// .//GEN-BEGIN:_populateRows_1_be
/**
* This will populate the input GridModel with the data in the finderOutDto of the Component.
* @param rows The GridModel object to populate.
*/
public void populateRows(GridModel rows) {
rows.clearRows();
FormSelectionMaintenanceOutDto outputDto = (FormSelectionMaintenanceOutDto) ((FormSelectionMaintenanceComponent) getComponent()).getFinderOutDto();
if (outputDto != null) {
GridModelRow row;
for (int i = 0; i < outputDto.getRowsCount(); i++) {
FormSelectionMaintenanceOutRowDto rowDto = outputDto.getRows(i);
row = rows.newRow();
row.addElement("select", new CheckBoxModel((rowDto.getSelect() != null ? rowDto.getSelect() : Boolean.FALSE)));
row.addElement("errMessage", rowDto.getErrMessage());
row.addElement("formName", rowDto.getFormName());
row.addElement("event", rowDto.getEvent());
row.addElement("key1", rowDto.getKey1());
row.addElement("key2", rowDto.getKey2());
row.addElement("key3", rowDto.getKey3());
row.addElement("key4", rowDto.getKey4());
row.addElement("key5", rowDto.getKey5());
row.addElement("key6", rowDto.getKey6());
row.addElement("value1", rowDto.getValue1());
row.addElement("value2", rowDto.getValue2());
row.addElement("value3", rowDto.getValue3());
row.addElement("value4", rowDto.getValue4());
row.addElement("value5", rowDto.getValue5());
row.addElement("value6", rowDto.getValue6());
row.addElement("printer", rowDto.getPrinter());
row.addElement("email", rowDto.getEmail());
row.addElement("publish", new CheckBoxModel((rowDto.getPublish() != null ? rowDto.getPublish() : Boolean.FALSE)));
row.addElement("copies", rowDto.getCopies());
// .//GEN-END:_populateRows_1_be
// Add custom code for the row//GEN-FIRST:_populateRows_1
EditBoxModel printerModel = new EditBoxModel(rowDto.getPrinter(), PrinterDefinitionMeta.META_PRINTER_ID);
printerModel.setMandatory(false);
row.addElement("printer", printerModel);
row.addElement("email", new EditBoxModel(rowDto.getEmail()));
row.addElement("copies", new EditBoxModel(rowDto.getCopies()));
row.addElement("formType", rowDto.getFormType());
row.addElement("object", rowDto);
row.addElement("additionalDataComponent", rowDto.getAdditionalDataComponent());
// .//GEN-LAST:_populateRows_1
// .//GEN-BEGIN:_populateRows_2_be
}
}
}
use of org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceComponent method print.
/**
* Generates all forms and/or labels for the current Event and Keyset.
* This method should be used when a User Interface is not needed.
* Prior to calling this method, set the Event and Keyset using
* setEvent(), setKey1(), setValue1(), setKey2(), setValue2(),setKey3(), setValue3(),
* setKey4(), setValue4(), setKey5(), setValue5(), setKey6(), setValue6().
* The forms and/or labels that match the current
* Event and Keyset will be printed and/or emailed.
* @throws ApplicationExceptions - When an exception occurs for a given
* Form or Label, the exception will be caught and added to the
* ApplicationExceptions.ApplicationExceptionArray. Therefore multiple
* exceptions may be caught and finally thrown at the end of this method.
* Forms and/or Labels that do not experience an exception will be
* generated successfully.
*/
public void print() throws ApplicationExceptions, Exception {
if (log.isDebugEnabled()) {
log.debug(" Begin generating forms and labels. ");
log.debug("Event = " + getEvent() + ".");
log.debug("Key 1 " + getKey1() + " = " + getValue1() + ".");
log.debug("Key 2 " + getKey2() + " = " + getValue2() + ".");
log.debug("Key 3 " + getKey3() + " = " + getValue3() + ".");
log.debug("Key 4 " + getKey4() + " = " + getValue4() + ".");
log.debug("Key 5 " + getKey5() + " = " + getValue5() + ".");
log.debug("Key 6 " + getKey6() + " = " + getValue6() + ".");
}
ApplicationExceptions appExps = new ApplicationExceptions();
GridModel gridModelRows = new GridModel();
FormSelectionMaintenanceOutDto finderOutDto = null;
setFormUserId(SecurityManager.getPrincipal() != null ? SecurityManager.getPrincipal().getName() : null);
// Validate that Event and Key1 are populated at a minimum.
if (getEvent() == null) {
throw new ApplicationExceptions(new MandatoryFieldException("[label.Jaffa.Printing.FormSelection.Event]"));
}
if (getKey1() == null || getValue1() == null) {
throw new ApplicationExceptions(new MandatoryFieldException("[label.Jaffa.Printing.FormSelection.Key1]"));
}
try {
finderOutDto = (FormSelectionMaintenanceOutDto) doInquiry2();
} catch (Exception ex) {
throw new ApplicationExceptions(new ApplicationException(ex.getMessage()));
}
if (finderOutDto != null && finderOutDto.getRowsCount() > 0) {
EditBoxModel printerModel = null;
GridModelRow gridModelRow = null;
FormSelectionMaintenanceOutRowDto[] rows = finderOutDto.getRows();
for (FormSelectionMaintenanceOutRowDto row : rows) {
gridModelRow = gridModelRows.newRow();
gridModelRow.addElement("select", new CheckBoxModel(Boolean.TRUE));
gridModelRow.addElement("formName", row.getFormName());
gridModelRow.addElement("formAlternateName", row.getFormAlternateName());
gridModelRow.addElement("formVariation", row.getFormVariation());
gridModelRow.addElement("event", row.getEvent());
gridModelRow.addElement("key1", row.getKey1());
gridModelRow.addElement("key2", row.getKey2());
gridModelRow.addElement("key3", row.getKey3());
gridModelRow.addElement("key4", row.getKey4());
gridModelRow.addElement("key5", row.getKey5());
gridModelRow.addElement("key6", row.getKey6());
gridModelRow.addElement("value1", row.getValue1());
gridModelRow.addElement("value2", row.getValue2());
gridModelRow.addElement("value3", row.getValue3());
gridModelRow.addElement("value4", row.getValue4());
gridModelRow.addElement("value5", row.getValue5());
gridModelRow.addElement("value6", row.getValue6());
printerModel = new EditBoxModel(row.getPrinter(), PrinterDefinitionMeta.META_PRINTER_ID);
printerModel.setMandatory(false);
gridModelRow.addElement("printer", printerModel);
gridModelRow.addElement("email", new EditBoxModel(getEmailAddress()));
gridModelRow.addElement("publish", new CheckBoxModel(Boolean.FALSE));
gridModelRow.addElement("copies", new EditBoxModel(row.getCopies()));
gridModelRow.addElement("object", row);
try {
ApplicationExceptions aes = new ApplicationExceptions();
validateFields(gridModelRow, aes, false);
if (aes != null && aes.size() > 0) {
for (Iterator i = aes.iterator(); i.hasNext(); ) {
ApplicationException appEx = (ApplicationException) i.next();
appExps.add(appEx);
}
} else {
m_tx.dispatchPrintRequest(createPrintRequestObject(gridModelRow, false));
}
} catch (Exception ex) {
if (ex instanceof ApplicationExceptions) {
for (ApplicationException appExp : ((ApplicationExceptions) ex).getApplicationExceptionArray()) {
appExps.add(appExp);
}
} else if (ex instanceof ApplicationException) {
appExps.add((ApplicationException) ex);
} else {
appExps.add(new ApplicationException(ex.getMessage()));
}
}
}
} else {
if (appExps.size() == 0) {
appExps.add(new FormSelectionException(FormSelectionException.NO_FORM_DEFINED_FOR_EVENT, getEvent()));
}
}
if (appExps != null && appExps.size() > 0) {
throw appExps;
}
if (log.isDebugEnabled()) {
log.debug(" Finished generating forms and labels. ");
}
}
use of org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceComponent method display.
/**
* Following attributes can be set on component invocation to control the types of output allowed
* directDisplay (), printing (), email(), webPublish(), autoDisplayAll()
*/
public FormKey display() throws ApplicationExceptions, FrameworkException {
FormKey fk = null;
GridModel rows = new GridModel();
fileNames = new StringBuilder();
if (getAutoDisplayAll()) {
setDirectDisplay(true);
setPrinting(false);
setEmail(false);
setWebPublish(false);
}
if (getAutoDisplayAll()) {
FormSelectionMaintenanceOutDto finderOutDto = (FormSelectionMaintenanceOutDto) doInquiry();
if (finderOutDto != null && finderOutDto.getRowsCount() > 0) {
if (log.isDebugEnabled()) {
log.debug("Form Preview for event " + getEvent() + ", Key1=" + getKey1() + ", Key2=" + getKey2() + ", Key3=" + getKey3() + ", Key4=" + getKey4() + ", Key5=" + getKey5() + ", Key6=" + getKey6() + ". Found " + finderOutDto.getRowsCount() + " rows.");
}
for (int i = 0; i < finderOutDto.getRowsCount(); i++) {
FormSelectionMaintenanceOutRowDto rowDto = finderOutDto.getRows(i);
rowDto.setSelect(Boolean.TRUE);
rowDto.setAdditionalDataObject(getAdditionalDataObject());
GridModelRow row = rows.newRow();
row.addElement("select", new CheckBoxModel((rowDto.getSelect() != null ? rowDto.getSelect() : Boolean.FALSE)));
row.addElement("errMessage", rowDto.getErrMessage());
row.addElement("formName", rowDto.getFormName());
row.addElement("event", rowDto.getEvent());
row.addElement("key1", rowDto.getKey1());
row.addElement("key2", rowDto.getKey2());
row.addElement("key3", rowDto.getKey3());
row.addElement("key4", rowDto.getKey4());
row.addElement("key5", rowDto.getKey5());
row.addElement("key6", rowDto.getKey6());
row.addElement("value1", rowDto.getValue1());
row.addElement("value2", rowDto.getValue2());
row.addElement("value3", rowDto.getValue3());
row.addElement("value4", rowDto.getValue4());
row.addElement("value5", rowDto.getValue5());
row.addElement("value6", rowDto.getValue6());
row.addElement("printer", rowDto.getPrinter());
row.addElement("email", rowDto.getEmail());
row.addElement("publish", new CheckBoxModel((rowDto.getPublish() != null ? rowDto.getPublish() : Boolean.FALSE)));
row.addElement("copies", rowDto.getCopies());
EditBoxModel printerModel = new EditBoxModel(rowDto.getPrinter(), PrinterDefinitionMeta.META_PRINTER_ID);
printerModel.setMandatory(false);
row.addElement("printer", printerModel);
row.addElement("email", new EditBoxModel(rowDto.getEmail()));
row.addElement("copies", new EditBoxModel(rowDto.getCopies()));
row.addElement("formType", rowDto.getFormType());
row.addElement("object", rowDto);
row.addElement("additionalDataComponent", rowDto.getAdditionalDataComponent());
fk = doShowForm(row);
if (finderOutDto.getRowsCount() == 1 && ((HttpServletRequest) ContextManagerFactory.instance().getProperty("request")).getHeader("user-agent").indexOf("UnixWare") >= 0) {
String tmpDir = System.getProperty("java.io.tmpdir");
String[] path = getFileNames().split(",");
((HttpServletRequest) ContextManagerFactory.instance().getProperty("request")).setAttribute("org.jaffa.applications.jaffa.modules.admin.components.fileexplorer", new File(tmpDir, path[0]));
fk = new FormKey("jaffa_admin_fileExplorer_download", null);
}
}
} else {
throw new ApplicationExceptions(new FormSelectionException(FormSelectionException.NO_FORM_DEFINED_FOR_EVENT, getEvent()) {
});
}
} else {
fk = super.display();
}
return fk;
}
Aggregations