use of org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto 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.FormSelectionMaintenanceOutRowDto 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.FormSelectionMaintenanceOutRowDto 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.FormSelectionMaintenanceOutRowDto in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceComponent method doUpdateDetail.
/**
* Show the AdditionalData Component.
* Pass the Additional Data Object if there is one.
*/
public FormKey doUpdateDetail(GridModelRow selectedRow, String actionPath) throws ApplicationExceptions, FrameworkException {
FormKey fk = null;
String additionalComponent = null;
try {
final FormSelectionMaintenanceOutRowDto rowDto = (FormSelectionMaintenanceOutRowDto) selectedRow.get("object");
additionalComponent = rowDto.getAdditionalDataComponent();
Component comp = (Component) run(additionalComponent);
BeanUtils.setProperty(comp, getKey1(), getValue1());
if (getKey2() != null) {
BeanUtils.setProperty(comp, getKey2(), getValue2());
}
if (getKey3() != null) {
BeanUtils.setProperty(comp, getKey3(), getValue3());
}
if (getKey4() != null) {
BeanUtils.setProperty(comp, getKey4(), getValue4());
}
if (getKey5() != null) {
BeanUtils.setProperty(comp, getKey5(), getValue5());
}
if (getKey6() != null) {
BeanUtils.setProperty(comp, getKey6(), getValue6());
}
// implements IAdditionalDataObject.
if (comp instanceof IAdditionalDataObject) {
((IAdditionalDataObject) comp).setAdditionalDataObject(rowDto.getAdditionalDataObject());
((IUpdateComponent) comp).addUpdateListener(new IUpdateListener() {
public void updateDone(EventObject source) {
try {
rowDto.setAdditionalDataObject(((IAdditionalDataObject) source.getSource()).getAdditionalDataObject());
} catch (Exception e) {
log.warn("Error setting the Additional Data Object after the Update", e);
}
}
});
}
comp.setReturnToFormKey(getResultsFormKey());
// Populate info to allow Web 2.0 component to return to this component
if (comp instanceof RiaWrapperComponent) {
RiaWrapperComponent c = (RiaWrapperComponent) comp;
c.getParameters().setProperty("returnToActionPath", actionPath);
c.getParameters().setProperty("returnToFormKey_componentId", comp.getReturnToFormKey().getComponentId());
}
fk = comp.display();
} catch (SecurityException se) {
log.error("SecurityException Occurred ", se);
throw new ApplicationExceptions(new FormSelectionException(FormSelectionException.SECURITY_EXCEPTION));
} catch (IllegalAccessException e) {
log.error("IllegalAccessException Occurred ", e);
} catch (InvocationTargetException e) {
log.error("InvocationTargetException Occurred ", e);
} catch (IllegalArgumentException e) {
log.error("IllegalArgumentException Occurred ", e);
} catch (ApplicationExceptions applicationException) {
throw applicationException;
} catch (FrameworkException frameworkException) {
throw frameworkException;
}
return fk;
}
use of org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceComponent method createPrintRequestObject.
private FormPrintRequest createPrintRequestObject(GridModelRow row, boolean showForm) {
if (log.isDebugEnabled()) {
log.debug("Create Print Request Object");
}
FormSelectionMaintenanceOutRowDto rowDto = (FormSelectionMaintenanceOutRowDto) row.get("object");
EditBoxModel mPrinter = (EditBoxModel) row.get("printer");
EditBoxModel mCopies = (EditBoxModel) row.get("copies");
EditBoxModel mEmail = (EditBoxModel) row.get("email");
CheckBoxModel mPublish = (CheckBoxModel) row.get("publish");
String variation = (String) row.get("formVariation");
FormPrintRequest formPrintRequest = new FormPrintRequest();
formPrintRequest.setFormAlternateName(rowDto.getFormAlternateName());
formPrintRequest.setFormName(rowDto.getFormName());
if (getFormUserId() != null) {
formPrintRequest.setUserName(getFormUserId());
} else {
formPrintRequest.setUserName(getHeaderDto().getUserId());
}
formPrintRequest.setVariation(variation);
// Set the additionalDataObject per row, else use the global object.
if (rowDto.getAdditionalDataObject() != null) {
formPrintRequest.setAdditionalDataObject(rowDto.getAdditionalDataObject());
} else if (getAdditionalDataObject() != null) {
formPrintRequest.setAdditionalDataObject(getAdditionalDataObject());
}
LinkedHashMap keys = new LinkedHashMap();
keys.put(getKey1(), getValue1());
if (getKey2() != null) {
keys.put(getKey2(), getValue2());
}
if (getKey3() != null) {
keys.put(getKey3(), getValue3());
}
if (getKey4() != null) {
keys.put(getKey4(), getValue4());
}
if (getKey5() != null) {
keys.put(getKey5(), getValue5());
}
if (getKey6() != null) {
keys.put(getKey6(), getValue6());
}
formPrintRequest.setKeys(keys);
if (showForm) {
formPrintRequest.setPrintCopies(0);
} else {
formPrintRequest.setEmailToAddresses(mEmail.getValue());
String copiesValue = mCopies.getValue();
if (copiesValue != null) {
formPrintRequest.setPrintCopies(Integer.valueOf(copiesValue));
}
formPrintRequest.setPrinterId(mPrinter.getValue());
}
if (log.isDebugEnabled()) {
log.debug("*** Creating Print Request. Setting Additional Data Object = " + rowDto.getAdditionalDataObject());
}
return formPrintRequest;
}
Aggregations