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.endow.businessobject.lookup;
017
018 import java.util.ArrayList;
019 import java.util.List;
020 import java.sql.Date;
021
022 import org.apache.commons.lang.StringUtils;
023 import org.kuali.kfs.coa.businessobject.Account;
024 import org.kuali.kfs.sys.KFSConstants;
025 import org.kuali.kfs.sys.context.SpringContext;
026 import org.kuali.kfs.module.endow.businessobject.PooledFundValue;
027 import org.kuali.kfs.module.endow.document.service.PooledFundValueService;
028 import org.kuali.rice.kim.bo.Person;
029 import org.kuali.rice.kim.service.IdentityManagementService;
030 import org.kuali.rice.kns.bo.BusinessObject;
031 import org.kuali.rice.kns.lookup.HtmlData;
032 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
033 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
034 import org.kuali.rice.kns.util.GlobalVariables;
035 import org.kuali.rice.kns.util.KNSConstants;
036
037 public class PooledFundValueLookupableHelperService extends KualiLookupableHelperServiceImpl {
038
039 /**
040 * Once a new value has been established for a given Pooled Fund (more recent VAL_EFF_DT),
041 * older value records cannot be modified.
042 *
043 * @returns links to edit and copy maintenance action for the record with the most VAL_EFF_DT
044 * for a given Pooled Fund or links to copy maintenance action only for those records
045 * with older VAL_EFF_DT.
046 * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getCustomActionUrls(org.kuali.rice.kns.bo.BusinessObject,
047 * java.util.List)
048 */
049 @Override
050 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
051
052 List<HtmlData> htmlDataList = new ArrayList<HtmlData>();
053 htmlDataList.add(getUrlData(businessObject, KNSConstants.MAINTENANCE_COPY_METHOD_TO_CALL, pkNames));
054
055 PooledFundValue pooledFundValue = (PooledFundValue) businessObject;
056 String pooledSecurityID = pooledFundValue.getPooledSecurityID();
057 Date valueEffectiveDate = pooledFundValue.getValueEffectiveDate();
058 PooledFundValueService pooledFundValueService = SpringContext.getBean(PooledFundValueService.class);
059 Date theLatestEffectiveDate = pooledFundValueService.getLatestValueEffectiveDate(pooledSecurityID);
060 if(valueEffectiveDate != null && valueEffectiveDate.equals(theLatestEffectiveDate)){
061 htmlDataList.add(getUrlData(businessObject, KNSConstants.MAINTENANCE_EDIT_METHOD_TO_CALL, pkNames));
062 }
063
064 return htmlDataList;
065
066 }
067
068 }