use of org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase in project cu-kfs by CU-CommunityApps.
the class WebUtils method isFormSessionDocument.
public static boolean isFormSessionDocument(PojoFormBase form) {
Document document = null;
if (KualiDocumentFormBase.class.isAssignableFrom(form.getClass())) {
KualiDocumentFormBase docForm = (KualiDocumentFormBase) form;
document = docForm.getDocument();
}
return isDocumentSession(document, form);
}
use of org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method createReasonNote.
/*
* creating the change to vendor reason note.
*/
private void createReasonNote(ActionForm form) {
// TODO : move to service ?
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
try {
Note noteObj = SpringContext.getBean(DocumentService.class).createNoteFromDocument(kualiDocumentFormBase.getDocument(), ((PurchasingFormBase) kualiDocumentFormBase).getReasonToChange());
populateIdentifierOnNoteAndExtension(noteObj);
kualiDocumentFormBase.getDocument().addNote(noteObj);
if (doesDocumentAllowImmediateSaveOfNewNote(kualiDocumentFormBase.getDocument(), noteObj)) {
getNoteService().save(noteObj);
}
((PurchasingFormBase) kualiDocumentFormBase).setReasonToChange(KFSConstants.EMPTY_STRING);
} catch (Exception e) {
String errorMessage = "Error creating and saving close note for reason change requirement with document service";
LOG.error("createReasonNote " + errorMessage, e);
throw new RuntimeException(errorMessage, e);
}
}
use of org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method save.
@Override
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
if (isAttachmentSizeExceedSqLimit(form, "save") || isReasonToChangeRequired(form)) {
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
// save this flag before notes is saved during route
boolean isCreatingReasonNote = isCreatingReasonNote(form);
// else if (!(kualiDocumentFormBase.getDocument() instanceof RequisitionDocument)) {
// restoreSendToVendorFlag(kualiDocumentFormBase.getDocument().getDocumentBusinessObject().getBoNotes(), ((PurchaseOrderForm)kualiDocumentFormBase).getCopiedNotes());
// }
ActionForward forward = super.save(mapping, form, request, response);
if (GlobalVariables.getMessageMap().hasNoErrors() && isCreatingReasonNote) {
createReasonNote(form);
}
return forward;
}
use of org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method isAttachmentSizeExceedSqLimit.
/*
* check if number of attachments, that are sent to SQ, is over the limit.
* default to 10, and also use a system param to make it flexible.
*/
private boolean isAttachmentSizeExceedSqLimit(ActionForm form, String action) {
boolean isExceed = false;
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
String attachmentSize = "10";
int addOne = StringUtils.equals("add", action) ? 1 : 0;
try {
attachmentSize = SpringContext.getBean(ParameterService.class).getParameterValueAsString(PurapConstants.PURAP_NAMESPACE, KRADConstants.DetailTypes.ALL_DETAIL_TYPE, CUPurapConstants.MAX_SQ_NO_ATTACHMENTS);
} catch (Exception e) {
// param not found
LOG.info("Parameter MAX_SQ_NO_ATTACHMENTS not found");
}
if (StringUtils.isNotBlank(attachmentSize) && Integer.parseInt(attachmentSize) < (getNumberOfNotesToSendToVendor(kualiDocumentFormBase.getDocument()) + addOne)) {
GlobalVariables.getMessageMap().putError(String.format("%s.%s", KRADConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME, KRADConstants.NOTE_TOPIC_TEXT_PROPERTY_NAME), CUPurapKeyConstants.ERROR_EXCEED_SQ_NUMBER_OF_ATT_LIMIT, action, attachmentSize);
isExceed = true;
}
return isExceed;
}
use of org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase in project cu-kfs by CU-CommunityApps.
the class CuPurchaseOrderAction method movePoCxer.
protected ActionForward movePoCxer(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String newStatus, String newStatusLabel) throws Exception {
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
PurchaseOrderDocument po = (PurchaseOrderDocument) kualiDocumentFormBase.getDocument();
Object question = request.getParameter(KFSConstants.QUESTION_INST_ATTRIBUTE_NAME);
// If the user has not received the question screen yet, then perform the PO status update.
if (ObjectUtils.isNull(question)) {
// Check authorization.
checkMovePoCxerAuthorization(po);
// Use logic similar to the executeManualStatusChange() method to override the document's status.
try {
PurapService purapService = SpringContext.getBean(PurapService.class);
po.updateAndSaveAppDocStatus(newStatus);
purapService.saveDocumentNoValidation(po);
} catch (Exception e) {
throw new RuntimeException(e);
}
// Add a message to the route log.
po.getDocumentHeader().getWorkflowDocument().logAnnotation("Moved PO document from 'Error occurred sending cxml' status to '" + newStatusLabel + "' status.");
// Present a success message to the user.
String message = "PO document " + po.getDocumentNumber() + " was successfully moved to '" + newStatusLabel + "' status.";
return this.performQuestionWithoutInput(mapping, form, request, response, MOVE_CXML_ERROR_PO_SUCCESS, message, STATUS_OVERRIDE_QUESTION, MOVE_CXML_ERROR_PO_SUCCESS, "");
}
return returnToSender(request, mapping, kualiDocumentFormBase);
}
Aggregations