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.ld.document.web.struts; 017 018 import java.util.Map; 019 020 import javax.servlet.http.HttpServletRequest; 021 022 import org.kuali.kfs.module.ld.LaborPropertyConstants; 023 import org.kuali.kfs.module.ld.businessobject.LaborAccountingLineOverride; 024 import org.kuali.kfs.sys.KFSPropertyConstants; 025 import org.kuali.kfs.sys.businessobject.AccountingLine; 026 import org.kuali.kfs.sys.businessobject.SourceAccountingLine; 027 import org.kuali.kfs.sys.businessobject.TargetAccountingLine; 028 import org.kuali.kfs.sys.context.SpringContext; 029 import org.kuali.kfs.sys.service.OptionsService; 030 import org.kuali.rice.kns.util.KNSConstants; 031 032 /** 033 * Base Struts Action Form for all expense transfer documents. 034 */ 035 public abstract class ExpenseTransferDocumentFormBase extends LaborDocumentFormBase implements MultipleValueLookupBroker { 036 037 protected String lookupResultsSequenceNumber; // Indicates which result set we are using when refreshing/returning from a 038 // multi-value lookup. 039 protected String lookupResultsBOClassName; // Type of result returned by the multi-value lookup. ?to be persisted in the lookup 040 // results service instead? 041 protected String lookedUpCollectionName; // The name of the collection looked up (by a multiple value lookup) 042 protected Integer universityFiscalYear; 043 044 /** 045 * Constructs a ExpenseTransferDocumentFormBase instance for the dependent object. 046 */ 047 public ExpenseTransferDocumentFormBase() { 048 super(); 049 setUniversityFiscalYear(SpringContext.getBean(OptionsService.class).getCurrentYearOptions().getUniversityFiscalYear()); 050 } 051 052 @Override 053 public void addRequiredNonEditableProperties() { 054 super.addRequiredNonEditableProperties(); 055 registerRequiredNonEditableProperty(KNSConstants.LOOKUP_RESULTS_SEQUENCE_NUMBER); 056 } 057 058 /** 059 * @see org.kuali.kfs.module.ld.document.web.struts.MultipleValueLookupBroker#getLookupResultsSequenceNumber() 060 */ 061 public String getLookupResultsSequenceNumber() { 062 return lookupResultsSequenceNumber; 063 } 064 065 /** 066 * @see org.kuali.kfs.module.ld.document.web.struts.MultipleValueLookupBroker#setLookupResultsSequenceNumber(java.lang.String) 067 */ 068 public void setLookupResultsSequenceNumber(String lookupResultsSequenceNumber) { 069 this.lookupResultsSequenceNumber = lookupResultsSequenceNumber; 070 } 071 072 /** 073 * @see org.kuali.kfs.module.ld.document.web.struts.MultipleValueLookupBroker#getLookupResultsBOClassName() 074 */ 075 public String getLookupResultsBOClassName() { 076 return lookupResultsBOClassName; 077 } 078 079 /** 080 * @see org.kuali.kfs.module.ld.document.web.struts.MultipleValueLookupBroker#setLookupResultsBOClassName(java.lang.String) 081 */ 082 public void setLookupResultsBOClassName(String lookupResultsBOClassName) { 083 this.lookupResultsBOClassName = lookupResultsBOClassName; 084 } 085 086 /** 087 * @see org.kuali.kfs.module.ld.document.web.struts.MultipleValueLookupBroker#getLookedUpCollectionName() 088 */ 089 public String getLookedUpCollectionName() { 090 return lookedUpCollectionName; 091 } 092 093 /** 094 * @see org.kuali.kfs.module.ld.document.web.struts.MultipleValueLookupBroker#setLookedUpCollectionName(java.lang.String) 095 */ 096 public void setLookedUpCollectionName(String lookedUpCollectionName) { 097 this.lookedUpCollectionName = lookedUpCollectionName; 098 } 099 100 /** 101 * Gets the universityFiscalYear attribute. 102 * 103 * @return Returns the universityFiscalYear. 104 */ 105 public Integer getUniversityFiscalYear() { 106 return universityFiscalYear; 107 } 108 109 /** 110 * Sets the universityFiscalYear attribute value. 111 * 112 * @param universityFiscalYear The universityFiscalYear to set. 113 */ 114 public void setUniversityFiscalYear(Integer universityFiscalYear) { 115 this.universityFiscalYear = universityFiscalYear; 116 } 117 118 /** 119 * Populate the search fields with the last search criteria 120 */ 121 public abstract void populateSearchFields(); 122 123 /** 124 * Gets forced read only source fields 125 * 126 * @return Returns a Map of read only source fields 127 */ 128 public Map getForcedReadOnlySourceFields() { 129 Map map = super.getForcedReadOnlyFields(); 130 map.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, Boolean.TRUE); 131 map.put(KFSPropertyConstants.ACCOUNT_NUMBER, Boolean.TRUE); 132 map.put(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, Boolean.TRUE); 133 map.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, Boolean.TRUE); 134 map.put(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, Boolean.TRUE); 135 map.put(KFSPropertyConstants.PROJECT_CODE, Boolean.TRUE); 136 map.put(KFSPropertyConstants.ORGANIZATION_REFERENCE_ID, Boolean.TRUE); 137 map.put(KFSPropertyConstants.POSITION_NUMBER, Boolean.TRUE); 138 map.put(LaborPropertyConstants.PAYROLL_END_DATE_FISCAL_PERIOD_CODE, Boolean.TRUE); 139 map.put(LaborPropertyConstants.PAYROLL_END_DATE_FISCAL_YEAR, Boolean.TRUE); 140 return map; 141 } 142 143 /** 144 * Returns forced read only target fields (i.e read only fields plus payroll end date fiscal 145 * period code and payroll end date fiscal year) 146 * 147 * @see org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase#getForcedReadOnlyFields() 148 */ 149 public Map getForcedReadOnlyTargetFields() { 150 Map map = super.getForcedReadOnlyFields(); 151 map.put(LaborPropertyConstants.PAYROLL_END_DATE_FISCAL_PERIOD_CODE, Boolean.TRUE); 152 map.put(LaborPropertyConstants.PAYROLL_END_DATE_FISCAL_YEAR, Boolean.TRUE); 153 return map; 154 } 155 156 /** 157 * Deal with the labor-specific override code to the given source accounting line 158 * 159 * @see org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase#populateSourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) 160 */ 161 @Override 162 public void populateSourceAccountingLine(SourceAccountingLine sourceLine, String accountingLinePropertyName, Map parameterMap) { 163 super.populateSourceAccountingLine(sourceLine, accountingLinePropertyName, parameterMap); 164 LaborAccountingLineOverride.populateFromInput(sourceLine); 165 } 166 167 /** 168 * Deal with the labor-specific override code to the given target accounting line 169 * 170 * @see org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase#populateTargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) 171 */ 172 @Override 173 public void populateTargetAccountingLine(TargetAccountingLine targetLine, String accountingLinePropertyName, Map parameterMap) { 174 super.populateTargetAccountingLine(targetLine, accountingLinePropertyName, parameterMap); 175 LaborAccountingLineOverride.populateFromInput(targetLine); 176 } 177 178 /** 179 * @see org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase#repopulateOverrides(org.kuali.kfs.sys.businessobject.AccountingLine, java.lang.String, javax.servlet.http.HttpServletRequest) 180 */ 181 @Override 182 protected void repopulateOverrides(AccountingLine line, String accountingLinePropertyName, Map parameterMap) { 183 super.repopulateOverrides(line, accountingLinePropertyName, parameterMap); 184 LaborAccountingLineOverride.determineNeededOverrides(line); 185 if (line.getNonFringeAccountOverrideNeeded()) { 186 if (parameterMap.containsKey(accountingLinePropertyName+".nonFringeAccountOverride.present")) { 187 line.setNonFringeAccountOverride(parameterMap.containsKey(accountingLinePropertyName+".nonFringeAccountOverride")); 188 } 189 } else { 190 line.setNonFringeAccountOverride(false); 191 } 192 } 193 194 }