use of org.jaffa.modules.printing.services.FormPrintRequest 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(new Integer(0));
} else {
formPrintRequest.setEmailToAddresses(mEmail.getValue());
formPrintRequest.setPrintCopies(new Integer(mCopies.getValue()));
formPrintRequest.setPrinterId(mPrinter.getValue());
}
if (log.isDebugEnabled()) {
log.debug("*** Creating Print Request. Setting Additional Data Object = " + rowDto.getAdditionalDataObject());
}
return formPrintRequest;
}
use of org.jaffa.modules.printing.services.FormPrintRequest in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceComponent method doShowForm.
public FormKey doShowForm(GridModelRow selectedRow) throws ApplicationExceptions, FrameworkException {
if (log.isDebugEnabled()) {
log.debug("*** Begin doShowForm(row)");
}
FormKey fk = null;
String fileName = "";
try {
File fileOut = File.createTempFile("form_", ".pdf");
fileName = fileOut.getAbsolutePath();
fileNames.append(fileOut.getName() + ",");
} catch (IOException io) {
// FIXME - IOException should not be ignored!
io.printStackTrace();
}
ApplicationExceptions appExps = null;
boolean isValidationOk = true;
try {
appExps = new ApplicationExceptions();
// Field validation
validateFields(selectedRow, appExps, true);
selectedRow.addElement("errMessage", appExps);
if (appExps != null && appExps.size() > 0) {
if (isValidationOk) {
isValidationOk = false;
}
}
if (isValidationOk) {
try {
selectedRow.addElement("formVariation", VariationContext.getVariation());
FormPrintRequest formPrintRequest = createPrintRequestObject(selectedRow, true);
formPrintRequest.setSaveFileName(fileName);
m_tx.dispatchPrintRequest(formPrintRequest);
fk = getDisplayFormKey();
} catch (ApplicationExceptions ae) {
selectedRow.addElement("errMessage", ae);
isValidationOk = false;
if (getAutoDisplayAll()) {
if (log.isDebugEnabled()) {
log.debug("*** doShowForm() throwing Application Ex. ");
}
throw ae;
}
} catch (FrameworkException fe) {
selectedRow.addElement("errMessage", fe);
isValidationOk = false;
if (getAutoDisplayAll()) {
if (log.isDebugEnabled()) {
log.debug("*** doShowForm() throwing Framework Ex. ");
}
throw fe;
}
}
}
if (!isValidationOk) {
fk = getResultsFormKey();
}
} catch (ApplicationExceptions applicationException) {
throw applicationException;
} catch (FrameworkException frameworkException) {
throw frameworkException;
}
if (log.isDebugEnabled()) {
log.debug("FormKey : " + fk);
log.debug("*** End doShowForm(row)");
}
return fk;
}
Aggregations