1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.web.struts;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.ole.sys.OLEConstants;
23 import org.kuali.ole.sys.businessobject.FinancialSystemDocumentHeader;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.rice.core.api.config.property.ConfigurationService;
26 import org.kuali.rice.kew.api.WorkflowDocument;
27 import org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase;
28 import org.kuali.rice.kns.web.ui.ExtraButton;
29 import org.kuali.rice.kns.web.ui.HeaderField;
30
31
32
33
34 public class FinancialSystemTransactionalDocumentFormBase extends KualiTransactionalDocumentFormBase {
35
36
37
38
39 public FinancialSystemTransactionalDocumentFormBase() {
40 super();
41 }
42
43
44
45
46
47
48 @Override
49 public void populateHeaderFields(WorkflowDocument workflowDocument) {
50 super.populateHeaderFields(workflowDocument);
51 if (getDocument().getDocumentHeader() instanceof FinancialSystemDocumentHeader) {
52 FinancialSystemDocumentHeader documentHeader = (FinancialSystemDocumentHeader)getDocument().getDocumentHeader();
53 if (StringUtils.isNotBlank(documentHeader.getFinancialDocumentInErrorNumber())) {
54 extendDocInfoToThreeColumns();
55 int insertIndex = 2;
56 getDocInfo().remove(insertIndex);
57 getDocInfo().add(insertIndex, new HeaderField("DataDictionary.FinancialSystemDocumentHeader.attributes.financialDocumentInErrorNumber",
58 documentHeader.getFinancialDocumentInErrorNumber(), buildHtmlLink(getDocumentHandlerUrl(documentHeader.getFinancialDocumentInErrorNumber()), documentHeader.getFinancialDocumentInErrorNumber())));
59 }
60 if (StringUtils.isNotBlank(documentHeader.getCorrectedByDocumentId())) {
61 extendDocInfoToThreeColumns();
62 int insertIndex = getNumColumns() + 2;
63 getDocInfo().remove(insertIndex);
64 getDocInfo().add(insertIndex, new HeaderField("DataDictionary.FinancialSystemDocumentHeader.attributes.correctedByDocumentId",
65 documentHeader.getCorrectedByDocumentId(), buildHtmlLink(getDocumentHandlerUrl(documentHeader.getCorrectedByDocumentId()), documentHeader.getCorrectedByDocumentId())));
66
67
68 }
69 }
70 }
71
72
73
74
75
76 protected void extendDocInfoToThreeColumns() {
77 List<HeaderField> newDocInfo = new ArrayList<HeaderField>();
78 int currentColumns = getNumColumns();
79 int targetColumns = 3;
80 if (getNumColumns() < targetColumns) {
81 int column = 0;
82 for (HeaderField headerField : getDocInfo()) {
83 if (column + 1 > currentColumns) {
84 newDocInfo.add(HeaderField.EMPTY_FIELD);
85 column = (column + 1) % targetColumns;
86 }
87 newDocInfo.add(headerField);
88 column = (column + 1) % targetColumns;
89 }
90
91 while (newDocInfo.size() % targetColumns != 0) {
92 newDocInfo.add(HeaderField.EMPTY_FIELD);
93 }
94 setDocInfo(newDocInfo);
95 setNumColumns(3);
96 }
97 }
98
99
100
101
102
103
104 @Override
105 public List<ExtraButton> getExtraButtons() {
106 List<ExtraButton> buttons = super.getExtraButtons();
107 if (getDocumentActions().containsKey(OLEConstants.KFS_ACTION_CAN_ERROR_CORRECT)) {
108 buttons.add(generateErrorCorrectionButton());
109 }
110 return buttons;
111 }
112
113 private ExtraButton errorCorrectionButton;
114
115
116
117
118
119
120
121
122 protected ExtraButton generateErrorCorrectionButton() {
123 if ( errorCorrectionButton == null ) {
124 ExtraButton button = new ExtraButton();
125 button.setExtraButtonAltText("Create error correction document from current document");
126 button.setExtraButtonProperty("methodToCall.correct");
127 button.setExtraButtonSource(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString("kr.externalizable.images.url")+"buttonsmall_errcorr.gif");
128 errorCorrectionButton = button;
129 }
130 return errorCorrectionButton;
131 }
132 }