use of org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceTx method buildDto.
// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private FormSelectionMaintenanceOutDto buildDto(UOW uow, Collection results, FormSelectionMaintenanceInDto input) throws UOWException {
FormSelectionMaintenanceOutDto output = new FormSelectionMaintenanceOutDto();
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;
}
FormSelectionMaintenanceOutRowDto row = new FormSelectionMaintenanceOutRowDto();
FormUsage formUsage = (FormUsage) 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_FormName_1_be
row.setFormName(formUsage.getFormName());
// .//GEN-END:_buildDto_FormName_1_be
// Add custom code to pass values to the dto//GEN-FIRST:_buildDto_2
row.setCopies(formUsage.getCopies());
// .//GEN-LAST:_buildDto_2
// .//GEN-BEGIN:_buildDto_3_be
output.addRows(row);
}
return output;
}
use of org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto 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;
}
use of org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceComponent method validateFields.
protected void validateFields(GridModelRow row, ApplicationExceptions appExps, boolean showForm) throws ApplicationExceptions, FrameworkException {
String additionalComponent = null;
CheckBoxModel checkBoxModel = (CheckBoxModel) row.get("select");
if ((checkBoxModel != null && checkBoxModel.getState()) || showForm) {
// Check copies are greater then zero
EditBoxModel mCopies = (EditBoxModel) row.get("copies");
if (mCopies != null && !showForm) {
if (mCopies.getValue() != null && mCopies.getValue().length() > 0) {
int iCopies = Integer.parseInt(mCopies.getValue());
if (iCopies < 1) {
appExps.add(new FormSelectionException(FormSelectionException.INVALID_COPIES));
}
} else {
appExps.add(new FormSelectionException(FormSelectionException.INVALID_COPIES));
}
}
if (!showForm) {
// check either printer, email or publish has value
EditBoxModel mPrinter = (EditBoxModel) row.get("printer");
EditBoxModel mEmail = (EditBoxModel) row.get("email");
CheckBoxModel mPublish = (CheckBoxModel) row.get("publish");
if ((mPrinter.getValue() == null) && (mEmail.getValue() == null) && (mPublish.getState() != true) && !showForm) {
appExps.add(new FormSelectionException(FormSelectionException.INVALID_OUTPUT_DESTINATION));
}
}
// Validate AdditionalData exist or not
try {
FormSelectionMaintenanceOutRowDto rowDto = (FormSelectionMaintenanceOutRowDto) row.get("object");
additionalComponent = rowDto.getAdditionalDataComponent();
if (additionalComponent != null) {
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());
}
if (comp instanceof IAdditionalData) {
((IAdditionalData) comp).validate();
} else {
if (log.isDebugEnabled()) {
log.debug("Additional Data Interface not implemented ");
}
}
}
} catch (SecurityException se) {
log.error("SecurityException Occurred ", se);
appExps.add(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) {
log.debug("Catch : Application Exception from additional data component");
if (applicationException != null && applicationException.size() > 0) {
for (Iterator i = applicationException.iterator(); i.hasNext(); ) {
ApplicationException appEx = (ApplicationException) i.next();
appExps.add(appEx);
}
}
} catch (FrameworkException frameworkException) {
throw frameworkException;
}
}
}
Aggregations