use of org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException 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.FormSelectionException 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) {
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.FormSelectionException in project jaffa-framework by jaffa-projects.
the class FormSelectionMaintenanceComponent method doInquiry.
// .//GEN-END:value6_1_be
// .//GEN-BEGIN:_doInquiry_1_be
/**
* This performs the actual query to obtain the FinderOutDto.
* @throws ApplicationExceptions This will be thrown in case any invalid data has been set.
* @throws FrameworkException Indicates some system error.
* @return the FinderOutDto object.
*/
protected FinderOutDto doInquiry() throws ApplicationExceptions, FrameworkException {
ApplicationExceptions appExps = null;
FormSelectionMaintenanceInDto inputDto = new FormSelectionMaintenanceInDto();
/**
* Check that a proper form Event was found.
* Give a message that no events are defined for the form preview link.
* Conditions are:
* getEvent().startsWith("???") indicates the event label was not found.
* getEvent().equals("") indicates the event label was found but no event was defined.
*/
if (getAutoDisplayAll()) {
if (getEvent() == null || getEvent().startsWith("???") || getEvent().equals("")) {
throw new ApplicationExceptions(new FormSelectionException(FormSelectionException.FORM_PREVIEW_EVENT_NOT_DEFINED) {
});
}
}
// Check for Mandatory fields (Event & Key1/Voucher are mandatory)
if (getEvent() == null) {
if (appExps == null) {
appExps = new ApplicationExceptions();
}
appExps.add(new MandatoryFieldException("[label.Jaffa.Printing.FormSelection.Event]"));
}
if (getKey1() == null) {
if (appExps == null) {
appExps = new ApplicationExceptions();
}
appExps.add(new MandatoryFieldException("[label.Jaffa.Printing.FormSelection.Key1]"));
}
if (appExps != null && appExps.size() > 0) {
throw appExps;
}
inputDto.setDefaultPrinters(getDefaultPrinters());
// .//GEN-LAST:_doInquiry_1
// .//GEN-BEGIN:_doInquiry_2_be
inputDto.setMaxRecords(getMaxRecords());
if (getEvent() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getEventDd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getEventDd())) {
inputDto.setEvent(StringCriteriaField.getStringCriteriaField(getEventDd(), getEvent(), null));
}
if (getKey1() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey1Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey1Dd())) {
inputDto.setKey1(StringCriteriaField.getStringCriteriaField(getKey1Dd(), getKey1(), null));
}
if (getKey2() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey2Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey2Dd())) {
inputDto.setKey2(StringCriteriaField.getStringCriteriaField(getKey2Dd(), getKey2(), null));
}
if (getKey3() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey3Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey3Dd())) {
inputDto.setKey3(StringCriteriaField.getStringCriteriaField(getKey3Dd(), getKey3(), null));
}
if (getKey4() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey4Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey4Dd())) {
inputDto.setKey4(StringCriteriaField.getStringCriteriaField(getKey4Dd(), getKey4(), null));
}
if (getKey5() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey5Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey5Dd())) {
inputDto.setKey5(StringCriteriaField.getStringCriteriaField(getKey5Dd(), getKey5(), null));
}
if (getKey6() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey6Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey6Dd())) {
inputDto.setKey6(StringCriteriaField.getStringCriteriaField(getKey6Dd(), getKey6(), null));
}
if (getValue1() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue1Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue1Dd())) {
inputDto.setValue1(StringCriteriaField.getStringCriteriaField(getValue1Dd(), getValue1(), null));
}
if (getValue2() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue2Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue2Dd())) {
inputDto.setValue2(StringCriteriaField.getStringCriteriaField(getValue2Dd(), getValue2(), null));
}
if (getValue3() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue3Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue3Dd())) {
inputDto.setValue3(StringCriteriaField.getStringCriteriaField(getValue3Dd(), getValue3(), null));
}
if (getValue4() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue4Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue4Dd())) {
inputDto.setValue4(StringCriteriaField.getStringCriteriaField(getValue4Dd(), getValue4(), null));
}
if (getValue5() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue5Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue5Dd())) {
inputDto.setValue5(StringCriteriaField.getStringCriteriaField(getValue5Dd(), getValue5(), null));
}
if (getValue6() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue6Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue6Dd())) {
inputDto.setValue6(StringCriteriaField.getStringCriteriaField(getValue6Dd(), getValue6(), null));
}
// throw ApplicationExceptions, if any parsing errors occured
if (appExps != null && appExps.size() > 0) {
throw appExps;
}
inputDto.setHeaderDto(getHeaderDto());
addSortCriteria(inputDto);
// perform the inquiry
if (m_tx == null) {
m_tx = (IFormSelectionMaintenance) Factory.createObject(IFormSelectionMaintenance.class);
}
FinderOutDto finderOutDto = m_tx.find(inputDto);
// .//GEN-END:_doInquiry_2_be
// Add custom code after the Transaction//GEN-FIRST:_doInquiry_2
finderOutDto = m_tx.findOutDto(inputDto);
// .//GEN-BEGIN:_doInquiry_3_be
return finderOutDto;
}
use of org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException 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.FormSelectionException 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