001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.module.purap.document.web;
017
018 import org.kuali.kfs.module.purap.businessobject.PurApAccountingLineBase;
019 import org.kuali.kfs.module.purap.businessobject.PurApItemBase;
020 import org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument;
021 import org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocumentBase;
022 import org.kuali.kfs.sys.businessobject.AccountingLine;
023 import org.kuali.kfs.sys.document.AccountingDocument;
024 import org.kuali.kfs.sys.document.web.AccountingLineViewField;
025
026 /**
027 * Represents a field (plus, optionally, a dynamic name field) to be rendered as part of an accounting line.
028 */
029 public class PurapAccountingLineViewField extends AccountingLineViewField {
030
031 /**
032 * Overrides the method in AccountingLineViewField so that we could control when the inquiry link
033 * should be rendered and when it should be hidden.
034 *
035 * @see org.kuali.kfs.sys.document.web.AccountingLineViewField#isRenderingInquiry(org.kuali.kfs.sys.document.AccountingDocument, org.kuali.kfs.sys.businessobject.AccountingLine)
036 */
037 @Override
038 protected boolean isRenderingInquiry(AccountingDocument document, AccountingLine line) {
039 if (!((PurchasingAccountsPayableDocument)document).isInquiryRendered()) {
040 return false;
041 }
042 return super.isRenderingInquiry(document, line);
043 }
044
045 /**
046 * Overrides the method in AccountingLineViewField so that we could control when the
047 * dynamic name label should be displayed and when it shouldn't be displayed.
048 *
049 * @see org.kuali.kfs.sys.document.web.AccountingLineViewField#getDynamicNameLabelDisplayedValue(org.kuali.kfs.sys.businessobject.AccountingLine)
050 */
051 @Override
052 protected String getDynamicNameLabelDisplayedValue(AccountingLine accountingLine) {
053 PurApAccountingLineBase purapLine = (PurApAccountingLineBase)accountingLine;
054 PurApItemBase purapItem = purapLine.getPurapItem();
055 PurchasingAccountsPayableDocumentBase purapDocument = null;
056
057 if (purapItem != null) {
058 purapDocument = purapItem.getPurapDocument();
059 }
060 if (purapItem == null || purapDocument == null || purapDocument.isInquiryRendered()) {
061 return super.getDynamicNameLabelDisplayedValue(accountingLine);
062 }
063 else {
064 return null;
065 }
066 }
067 }