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.inquiry;
017
018 import java.util.HashMap;
019 import java.util.Map;
020 import java.util.Properties;
021
022 import org.kuali.kfs.module.endow.EndowPropertyConstants;
023 import org.kuali.kfs.module.endow.businessobject.KEMIDHistoricalReportingGroup;
024 import org.kuali.kfs.module.endow.businessobject.KEMIDHistoricalTaxLot;
025 import org.kuali.kfs.sys.KFSConstants;
026 import org.kuali.kfs.sys.businessobject.inquiry.KfsInquirableImpl;
027 import org.kuali.kfs.sys.context.SpringContext;
028 import org.kuali.rice.kns.bo.BusinessObject;
029 import org.kuali.rice.kns.lookup.HtmlData;
030 import org.kuali.rice.kns.service.KualiConfigurationService;
031 import org.kuali.rice.kns.util.KNSConstants;
032 import org.kuali.rice.kns.util.ObjectUtils;
033 import org.kuali.rice.kns.util.UrlFactory;
034
035 public class KEMIDHistoricalReportingGroupInquirable extends KfsInquirableImpl {
036
037 /**
038 * @see org.kuali.kfs.sys.businessobject.inquiry.KfsInquirableImpl#getInquiryUrl(org.kuali.rice.kns.bo.BusinessObject,
039 * java.lang.String, boolean)
040 */
041 @Override
042 public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
043 KEMIDHistoricalReportingGroup historicalReportingGroup = (KEMIDHistoricalReportingGroup) businessObject;
044 if (EndowPropertyConstants.KEMID_CRNT_REP_GRP_UNITS.equals(attributeName) && ObjectUtils.isNotNull(historicalReportingGroup.getUnits())) {
045
046 Properties params = new Properties();
047 params.put(KFSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.SEARCH_METHOD);
048 params.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, KEMIDHistoricalTaxLot.class.getName());
049 params.put(KNSConstants.DOC_FORM_KEY, "88888888");
050 params.put(KFSConstants.HIDE_LOOKUP_RETURN_LINK, "true");
051 params.put(KFSConstants.BACK_LOCATION, SpringContext.getBean(KualiConfigurationService.class).getPropertyString(KNSConstants.APPLICATION_URL_KEY) + "/" + KFSConstants.MAPPING_PORTAL + ".do");
052 params.put(KFSConstants.LOOKUP_READ_ONLY_FIELDS, EndowPropertyConstants.KEMID + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_KEMID_PURPOSE_CD + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_REP_GRP + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_IP_IND + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_SECURITY_ID + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_REGIS_CD + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_BALANCE_DATE + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_KEMID_CLOSED_IND + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_REGIS_DESC + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_SEC_DESC + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_KEMID_SHORT_TTL + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_PURPOSE_DESC + "," + EndowPropertyConstants.KEMID_HIST_TAX_LOT_INC_PRIN_DESC + "," + EndowPropertyConstants.MONTH_END_DATE_ID);
053
054 params.put(EndowPropertyConstants.KEMID, UrlFactory.encode(String.valueOf(historicalReportingGroup.getKemid())));
055 params.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_KEMID_PURPOSE_CD, UrlFactory.encode(historicalReportingGroup.getKemidObj().getPurposeCode()));
056 params.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_REP_GRP, UrlFactory.encode(historicalReportingGroup.getReportingGroupCode()));
057 params.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_IP_IND, UrlFactory.encode(historicalReportingGroup.getIpIndicator()));
058 params.put(EndowPropertyConstants.KEMID_HIST_REP_GRP_SEC_ID, UrlFactory.encode(historicalReportingGroup.getSecurityId()));
059 params.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_REGIS_CD, UrlFactory.encode(historicalReportingGroup.getRegistrationCode()));
060 params.put(EndowPropertyConstants.MONTH_END_DATE_ID, UrlFactory.encode(String.valueOf(historicalReportingGroup.getHistoryBalanceDateId())));
061 params.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_KEMID_CLOSED_IND, historicalReportingGroup.getKemidObj().isClose() ? "Yes" : "No");
062 params.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_REGIS_DESC, historicalReportingGroup.getRegistration().getName());
063 params.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_SEC_DESC, historicalReportingGroup.getSecurity().getDescription());
064 params.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_KEMID_SHORT_TTL, historicalReportingGroup.getKemidObj().getShortTitle());
065 params.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_PURPOSE_DESC, historicalReportingGroup.getKemidObj().getPurpose().getName());
066 params.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_INC_PRIN_DESC, historicalReportingGroup.getIncomePrincipalIndicator().getName());
067
068 String url = UrlFactory.parameterizeUrl(KNSConstants.LOOKUP_ACTION, params);
069
070 Map<String, String> fieldList = new HashMap<String, String>();
071 fieldList.put(EndowPropertyConstants.KEMID, historicalReportingGroup.getKemid().toString());
072 fieldList.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_KEMID_PURPOSE_CD, historicalReportingGroup.getKemidObj().getPurposeCode());
073 fieldList.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_REP_GRP, historicalReportingGroup.getReportingGroupCode());
074 fieldList.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_IP_IND, historicalReportingGroup.getIpIndicator());
075 fieldList.put(EndowPropertyConstants.KEMID_HIST_REP_GRP_SEC_ID, historicalReportingGroup.getSecurityId());
076 fieldList.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_REGIS_CD, historicalReportingGroup.getRegistrationCode());
077 fieldList.put(EndowPropertyConstants.MONTH_END_DATE_ID, String.valueOf(historicalReportingGroup.getHistoryBalanceDateId()));
078 fieldList.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_KEMID_CLOSED_IND, historicalReportingGroup.getKemidObj().isClose() ? "Yes" : "No");
079 fieldList.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_REGIS_DESC, historicalReportingGroup.getRegistration().getName());
080 fieldList.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_SEC_DESC, historicalReportingGroup.getSecurity().getDescription());
081 fieldList.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_KEMID_SHORT_TTL, historicalReportingGroup.getKemidObj().getShortTitle());
082 fieldList.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_PURPOSE_DESC, historicalReportingGroup.getKemidObj().getPurpose().getName());
083 fieldList.put(EndowPropertyConstants.KEMID_HIST_TAX_LOT_INC_PRIN_DESC, historicalReportingGroup.getIncomePrincipalIndicator().getName());
084
085 return getHyperLink(KEMIDHistoricalTaxLot.class, fieldList, url);
086 }
087 return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
088 }
089
090 }