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.ec.businessobject.inquiry; 017 018 import java.util.ArrayList; 019 import java.util.HashMap; 020 import java.util.List; 021 import java.util.Map; 022 import java.util.Properties; 023 024 import org.apache.commons.lang.ObjectUtils; 025 import org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl; 026 import org.kuali.kfs.integration.ld.LaborLedgerBalanceForEffortCertification; 027 import org.kuali.kfs.integration.ld.LaborModuleService; 028 import org.kuali.kfs.module.ec.EffortConstants; 029 import org.kuali.kfs.module.ec.EffortPropertyConstants; 030 import org.kuali.kfs.module.ec.businessobject.EffortCertificationDetail; 031 import org.kuali.kfs.module.ec.businessobject.EffortCertificationDetailBuild; 032 import org.kuali.kfs.module.ec.document.EffortCertificationDocument; 033 import org.kuali.kfs.sys.KFSConstants; 034 import org.kuali.kfs.sys.KFSPropertyConstants; 035 import org.kuali.kfs.sys.context.SpringContext; 036 import org.kuali.rice.kns.bo.BusinessObject; 037 import org.kuali.rice.kns.service.KualiModuleService; 038 import org.kuali.rice.kns.util.KualiDecimal; 039 040 public class EffortLedgerBalanceInquirableImpl extends AbstractGeneralLedgerInquirableImpl { 041 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(EffortLedgerBalanceInquirableImpl.class); 042 043 private KualiModuleService kualiModuleService = SpringContext.getBean(KualiModuleService.class); 044 045 /** 046 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String) 047 */ 048 @Override 049 protected void addMoreParameters(Properties parameter, String attributeName) { 050 BusinessObject businessObject = this.getBusinessObject(); 051 EffortCertificationDocument document = null; 052 053 if (businessObject instanceof EffortCertificationDetailBuild) { 054 EffortCertificationDetailBuild effortCertificationDetail = (EffortCertificationDetailBuild) businessObject; 055 document = effortCertificationDetail.getEffortCertificationDocumentBuild(); 056 } 057 else if (businessObject instanceof EffortCertificationDetail) { 058 EffortCertificationDetail effortCertificationDetail = (EffortCertificationDetail) businessObject; 059 document = effortCertificationDetail.getEffortCertificationDocument(); 060 } 061 062 if (document != null) { 063 parameter.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, ObjectUtils.toString(document.getUniversityFiscalYear())); 064 parameter.put(EffortPropertyConstants.EFFORT_CERTIFICATION_REPORT_NUMBER, document.getEffortCertificationReportNumber()); 065 parameter.put(KFSPropertyConstants.EMPLID, document.getEmplid()); 066 } 067 } 068 069 /** 070 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#buildUserDefinedAttributeKeyList() 071 */ 072 @Override 073 protected List<String> buildUserDefinedAttributeKeyList() { 074 List<String> keys = new ArrayList<String>(); 075 076 keys.add(KFSPropertyConstants.ACCOUNT_NUMBER); 077 keys.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE); 078 keys.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER); 079 keys.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE); 080 keys.add(KFSPropertyConstants.POSITION_NUMBER); 081 082 return keys; 083 } 084 085 /** 086 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getAttributeName(java.lang.String) 087 */ 088 @Override 089 protected String getAttributeName(String attributeName) { 090 return attributeName; 091 } 092 093 /** 094 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl() 095 */ 096 @Override 097 protected String getBaseUrl() { 098 return KFSConstants.GL_BALANCE_INQUIRY_ACTION; 099 } 100 101 /** 102 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getInquiryBusinessObjectClass(java.lang.String) 103 */ 104 @Override 105 protected Class getInquiryBusinessObjectClass(String attributeName) { 106 return kualiModuleService.getResponsibleModuleService(LaborLedgerBalanceForEffortCertification.class).getExternalizableBusinessObjectImplementation(LaborLedgerBalanceForEffortCertification.class); 107 } 108 109 /** 110 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyName(java.lang.String) 111 */ 112 @Override 113 protected String getKeyName(String keyName) { 114 return keyName; 115 } 116 117 /** 118 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyValue(java.lang.String, java.lang.Object) 119 */ 120 @Override 121 protected Object getKeyValue(String keyName, Object keyValue) { 122 return keyValue; 123 } 124 125 /** 126 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getLookupableImplAttributeName() 127 */ 128 @Override 129 protected String getLookupableImplAttributeName() { 130 return null; 131 } 132 133 /** 134 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap() 135 */ 136 @Override 137 protected Map<String, Object> getUserDefinedAttributeMap() { 138 Map<String, Object> userDefinedAttributeMap = new HashMap<String, Object>(); 139 140 userDefinedAttributeMap.put(EffortPropertyConstants.EFFORT_CERTIFICATION_PAYROLL_AMOUNT, KualiDecimal.ZERO); 141 userDefinedAttributeMap.put(EffortPropertyConstants.EFFORT_CERTIFICATION_ORIGINAL_PAYROLL_AMOUNT, KualiDecimal.ZERO); 142 143 return userDefinedAttributeMap; 144 } 145 146 /** 147 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#isExclusiveField(java.lang.Object, java.lang.Object) 148 */ 149 @Override 150 protected boolean isExclusiveField(Object keyName, Object keyValue) { 151 if (super.isExclusiveField(keyName, keyValue)) { 152 return true; 153 } 154 155 if (keyName != null && keyValue != null) { 156 if (keyName.equals(EffortPropertyConstants.SOURCE_ACCOUNT_NUMBER) && keyValue.equals(EffortConstants.DASH_ACCOUNT_NUMBER)) { 157 return true; 158 } 159 else if (keyName.equals(EffortPropertyConstants.SOURCE_CHART_OF_ACCOUNTS_CODE) && keyValue.equals(EffortConstants.DASH_CHART_OF_ACCOUNTS_CODE)) { 160 return true; 161 } 162 } 163 return false; 164 } 165 }