1 /*
2 * Copyright 2008 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.module.purap.document.web;
17
18 import org.kuali.ole.module.purap.businessobject.PurApAccountingLineBase;
19 import org.kuali.ole.module.purap.businessobject.PurApItemBase;
20 import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocument;
21 import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocumentBase;
22 import org.kuali.ole.sys.businessobject.AccountingLine;
23 import org.kuali.ole.sys.document.AccountingDocument;
24 import org.kuali.ole.sys.document.web.AccountingLineViewField;
25
26 /**
27 * Represents a field (plus, optionally, a dynamic name field) to be rendered as part of an accounting line.
28 */
29 public class PurapAccountingLineViewField extends AccountingLineViewField {
30
31 /**
32 * Overrides the method in AccountingLineViewField so that we could control when the inquiry link
33 * should be rendered and when it should be hidden.
34 *
35 * @see org.kuali.ole.sys.document.web.AccountingLineViewField#isRenderingInquiry(org.kuali.ole.sys.document.AccountingDocument, org.kuali.ole.sys.businessobject.AccountingLine)
36 */
37 @Override
38 protected boolean isRenderingInquiry(AccountingDocument document, AccountingLine line) {
39 if (!((PurchasingAccountsPayableDocument) document).isInquiryRendered()) {
40 return false;
41 }
42 return super.isRenderingInquiry(document, line);
43 }
44
45 /**
46 * Overrides the method in AccountingLineViewField so that we could control when the
47 * dynamic name label should be displayed and when it shouldn't be displayed.
48 *
49 * @see org.kuali.ole.sys.document.web.AccountingLineViewField#getDynamicNameLabelDisplayedValue(org.kuali.ole.sys.businessobject.AccountingLine)
50 */
51 @Override
52 protected String getDynamicNameLabelDisplayedValue(AccountingLine accountingLine) {
53 PurApAccountingLineBase purapLine = (PurApAccountingLineBase) accountingLine;
54 PurApItemBase purapItem = purapLine.getPurapItem();
55 PurchasingAccountsPayableDocumentBase purapDocument = null;
56
57 if (purapItem != null) {
58 purapDocument = purapItem.getPurapDocument();
59 }
60 if (purapItem == null || purapDocument == null || purapDocument.isInquiryRendered()) {
61 return super.getDynamicNameLabelDisplayedValue(accountingLine);
62 } else {
63 return null;
64 }
65 }
66 }