1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.web.struts;
17
18 import java.util.Iterator;
19 import java.util.List;
20
21 import javax.servlet.http.HttpServletRequest;
22 import javax.servlet.http.HttpServletResponse;
23
24 import org.apache.struts.action.ActionForm;
25 import org.apache.struts.action.ActionForward;
26 import org.apache.struts.action.ActionMapping;
27 import org.kuali.ole.fp.document.BudgetAdjustmentDocument;
28 import org.kuali.ole.sys.OLEKeyConstants;
29 import org.kuali.ole.sys.businessobject.AccountingLine;
30 import org.kuali.ole.sys.businessobject.AccountingLineOverride;
31 import org.kuali.ole.sys.businessobject.AccountingLineOverride.COMPONENT;
32 import org.kuali.ole.sys.context.SpringContext;
33 import org.kuali.ole.sys.document.AccountingDocument;
34 import org.kuali.ole.sys.web.struts.KualiAccountingDocumentActionBase;
35 import org.kuali.rice.kew.api.exception.WorkflowException;
36 import org.kuali.rice.kns.util.KNSGlobalVariables;
37 import org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase;
38 import org.kuali.rice.krad.service.PersistenceService;
39
40
41
42
43 public class BudgetAdjustmentAction extends KualiAccountingDocumentActionBase {
44 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BudgetAdjustmentAction.class);
45
46
47
48
49
50
51 @Override
52 protected void createDocument(KualiDocumentFormBase kualiDocumentFormBase) throws WorkflowException {
53 super.createDocument(kualiDocumentFormBase);
54 ((BudgetAdjustmentDocument) kualiDocumentFormBase.getDocument()).initiateDocument();
55
56 }
57
58
59
60
61
62
63
64 @Override
65 public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
66 KNSGlobalVariables.getMessageList().add(OLEKeyConstants.WARNING_DOCUMENT_BA_COPY_LABOR_BENEFITS);
67 return super.copy(mapping, form, request, response);
68 }
69
70 @Override
71 protected void processAccountingLineOverrides(AccountingDocument financialDocument, List accountingLines) {
72 if (!accountingLines.isEmpty()) {
73 SpringContext.getBean(PersistenceService.class).retrieveReferenceObjects(accountingLines, AccountingLineOverride.REFRESH_FIELDS);
74
75 for (Iterator i = accountingLines.iterator(); i.hasNext();) {
76 AccountingLine line = (AccountingLine) i.next();
77 processForOutput(financialDocument,line);
78 }
79 }
80 }
81
82 protected void processForOutput(AccountingDocument financialDocument,AccountingLine line) {
83 AccountingLineOverride fromCurrentCode = AccountingLineOverride.valueOf(line.getOverrideCode());
84 AccountingLineOverride needed = AccountingLineOverride.determineNeededOverrides(financialDocument,line);
85 line.setAccountExpiredOverride(fromCurrentCode.hasComponent(COMPONENT.EXPIRED_ACCOUNT));
86 line.setAccountExpiredOverrideNeeded(needed.hasComponent(COMPONENT.EXPIRED_ACCOUNT));
87 line.setObjectBudgetOverride(false);
88 line.setObjectBudgetOverrideNeeded(false);
89
90 }
91
92
93 }