use of edu.cornell.kfs.module.purap.document.IWantDocument in project cu-kfs by CU-CommunityApps.
the class IWantDocumentAction method save.
@Override
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
// Only recreate document description if in INITIATED or SAVED status.
WorkflowDocument workflowDocument = ((KualiDocumentFormBase) form).getDocument().getDocumentHeader().getWorkflowDocument();
if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
iWantDocumentService.setIWantDocumentDescription((IWantDocument) ((KualiDocumentFormBase) form).getDocument());
}
ActionForward actionForward = super.save(mapping, form, request, response);
IWantDocumentForm iWantDocForm = (IWantDocumentForm) form;
IWantDocument iWantDocument = iWantDocForm.getIWantDocument();
boolean added = true;
// add new item and new accounting line if not empty
IWantItem item = iWantDocForm.getNewIWantItemLine();
if (StringUtils.isNotBlank(item.getItemDescription()) || item.getItemUnitPrice() != null || item.getItemQuantity() != null) {
added &= addNewItem(iWantDocForm, iWantDocument, item);
}
added &= addNewFavoriteAccountIfNecessary(added, iWantDocument);
if (added) {
IWantAccount account = iWantDocForm.getNewSourceLine();
if (StringUtils.isNotBlank(account.getAccountNumber()) || StringUtils.isNotBlank(account.getSubAccountNumber()) || StringUtils.isNotBlank(account.getFinancialObjectCode()) || StringUtils.isNotBlank(account.getFinancialSubObjectCode()) || StringUtils.isNotBlank(account.getProjectCode()) || StringUtils.isNotBlank(account.getOrganizationReferenceId())) {
added &= addNewAccount(iWantDocForm, iWantDocument, account);
}
}
// Do not save if item or account additions failed.
if (!added) {
return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
iWantDocument.setExplanation(iWantDocument.getDocumentHeader().getExplanation());
if (StringUtils.isNotBlank(iWantDocForm.getNewAdHocRoutePerson().getId())) {
iWantDocument.setCurrentRouteToNetId(iWantDocForm.getNewAdHocRoutePerson().getId());
}
return actionForward;
}
use of edu.cornell.kfs.module.purap.document.IWantDocument in project cu-kfs by CU-CommunityApps.
the class IWantDocumentAction method refresh.
/**
* @see org.kuali.kfs.kns.web.struts.action.KualiDocumentActionBase#refresh(org.apache.struts.action.ActionMapping,
* org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
@Override
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
IWantDocumentForm iWantDocForm = (IWantDocumentForm) form;
IWantDocument iWantDocument = iWantDocForm.getIWantDocument();
ActionForward actionForward = super.refresh(mapping, form, request, response);
String refreshCaller = request.getParameter(KFSConstants.REFRESH_CALLER);
if (refreshCaller != null && refreshCaller.endsWith(KFSConstants.LOOKUPABLE_SUFFIX)) {
String deliverToNetID = iWantDocument.getDeliverToNetID();
if (StringUtils.isNotEmpty(deliverToNetID)) {
IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
String address = iWantDocumentService.getPersonCampusAddress(deliverToNetID);
iWantDocument.setDeliverToAddress(address);
}
if ("iWantDocVendorLookupable".equalsIgnoreCase(refreshCaller)) {
Integer vendorHeaderId = iWantDocument.getVendorHeaderGeneratedIdentifier();
Integer vendorId = iWantDocument.getVendorDetailAssignedIdentifier();
String phoneNumber = "Phone: ";
Map<String, Object> fieldValues = new HashMap<String, Object>();
fieldValues.put("vendorHeaderGeneratedIdentifier", vendorHeaderId);
fieldValues.put("vendorDetailAssignedIdentifier", vendorId);
fieldValues.put("vendorPhoneTypeCode", "PH");
Collection<VendorPhoneNumber> vendorPhoneNumbers = getBusinessObjectService().findMatching(VendorPhoneNumber.class, fieldValues);
if (ObjectUtils.isNotNull(vendorPhoneNumbers) && vendorPhoneNumbers.size() > 0) {
VendorPhoneNumber retrievedVendorPhoneNumber = vendorPhoneNumbers.toArray(new VendorPhoneNumber[1])[0];
phoneNumber += retrievedVendorPhoneNumber.getVendorPhoneNumber();
}
// populate vendor info
String addressLine1 = iWantDocument.getVendorLine1Address() != null ? iWantDocument.getVendorLine1Address() : StringUtils.EMPTY;
String addressLine2 = iWantDocument.getVendorLine2Address() != null ? iWantDocument.getVendorLine2Address() : StringUtils.EMPTY;
String cityName = iWantDocument.getVendorCityName() != null ? iWantDocument.getVendorCityName() : StringUtils.EMPTY;
String stateCode = iWantDocument.getVendorStateCode() != null ? iWantDocument.getVendorStateCode() : StringUtils.EMPTY;
String countryCode = iWantDocument.getVendorCountryCode() != null ? iWantDocument.getVendorCountryCode() : StringUtils.EMPTY;
String postalCode = iWantDocument.getVendorPostalCode() != null ? iWantDocument.getVendorPostalCode() : StringUtils.EMPTY;
String faxNumber = "Fax: " + (iWantDocument.getVendorFaxNumber() != null ? iWantDocument.getVendorFaxNumber() : StringUtils.EMPTY);
String url = "URL: " + (iWantDocument.getVendorWebURL() != null ? iWantDocument.getVendorWebURL() : StringUtils.EMPTY);
String vendorInfo = new StringBuilder(100).append(addressLine1).append('\n').append(addressLine2).append('\n').append(cityName).append(", ").append(postalCode).append(", ").append(stateCode).append(", ").append(countryCode).append('\n').append(faxNumber).append('\n').append(phoneNumber).append(" \n").append(url).toString();
iWantDocument.setVendorDescription(vendorInfo);
}
}
return actionForward;
}
use of edu.cornell.kfs.module.purap.document.IWantDocument in project cu-kfs by CU-CommunityApps.
the class IWantDocumentAction method continueToItems.
/**
* Takes the user to next page
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward continueToItems(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
IWantDocumentForm iWantForm = (IWantDocumentForm) form;
IWantDocument iWantDocument = iWantForm.getIWantDocument();
iWantDocument.setExplanation(iWantDocument.getDocumentHeader().getExplanation());
KualiRuleService ruleService = SpringContext.getBean(KualiRuleService.class);
boolean rulePassed = true;
// call business rules
rulePassed &= ruleService.applyRules(new RouteDocumentEvent(KFSConstants.DOCUMENT_HEADER_ERRORS, iWantDocument));
if (rulePassed) {
iWantForm.setStep(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
iWantDocument.setStep(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
}
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
use of edu.cornell.kfs.module.purap.document.IWantDocument in project cu-kfs by CU-CommunityApps.
the class IWantDocumentAction method addFavoriteAccount.
/**
* Adds a new IWNT account to the document using the selected Favorite Account from the drop-down.
* This is similar to a method on PurchasingActionBase, but has been modified for IWNT use instead.
*/
public ActionForward addFavoriteAccount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
IWantDocumentForm iwntForm = (IWantDocumentForm) form;
IWantDocument document = iwntForm.getIWantDocument();
if (addNewFavoriteAccount(document)) {
document.setFavoriteAccountLineIdentifier(null);
}
return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
use of edu.cornell.kfs.module.purap.document.IWantDocument in project cu-kfs by CU-CommunityApps.
the class IWantDocumentAction method copy.
/**
* Overridden to guarantee that form of copied document is set to whatever the entry
* mode of the document is
* @see org.kuali.kfs.kns.web.struts.action.KualiTransactionalDocumentActionBase#copy(org.apache.struts.action.ActionMapping,
* org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
@Override
public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ActionForward forward = null;
if (request.getParameter(KRADConstants.PARAMETER_DOC_ID) == null) {
forward = super.copy(mapping, form, request, response);
} else {
// this is copy document from Procurement Gateway:
// use this link to call: http://localhost:8080/kfs-dev/purapIWant.do?methodToCall=copy&docId=xxxx
String docId = request.getParameter(KRADConstants.PARAMETER_DOC_ID);
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
IWantDocument document = null;
document = (IWantDocument) getDocumentService().getByDocumentHeaderId(docId);
document.toCopyFromGateway();
kualiDocumentFormBase.setDocument(document);
WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
kualiDocumentFormBase.setDocTypeName(workflowDocument.getDocumentTypeName());
UserSessionUtils.addWorkflowDocument(GlobalVariables.getUserSession(), workflowDocument);
forward = mapping.findForward(RiceConstants.MAPPING_BASIC);
}
return forward;
}
Aggregations