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.CurrentTaxLotBalance;
024 import org.kuali.kfs.module.endow.businessobject.KEMIDCurrentBalance;
025 import org.kuali.kfs.module.endow.businessobject.KEMIDCurrentBalanceDetail;
026 import org.kuali.kfs.module.endow.businessobject.KEMIDCurrentReportingGroup;
027 import org.kuali.kfs.sys.KFSConstants;
028 import org.kuali.kfs.sys.businessobject.inquiry.KfsInquirableImpl;
029 import org.kuali.kfs.sys.context.SpringContext;
030 import org.kuali.rice.kns.bo.BusinessObject;
031 import org.kuali.rice.kns.lookup.HtmlData;
032 import org.kuali.rice.kns.service.DateTimeService;
033 import org.kuali.rice.kns.service.KualiConfigurationService;
034 import org.kuali.rice.kns.util.KNSConstants;
035 import org.kuali.rice.kns.util.ObjectUtils;
036 import org.kuali.rice.kns.util.UrlFactory;
037
038 public class KEMIDCurrentReportingGroupInquirable extends KfsInquirableImpl {
039
040 /**
041 * @see org.kuali.kfs.sys.businessobject.inquiry.KfsInquirableImpl#getInquiryUrl(org.kuali.rice.kns.bo.BusinessObject, java.lang.String, boolean)
042 */
043 @Override
044 public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
045 KEMIDCurrentReportingGroup currentReportingGroup = (KEMIDCurrentReportingGroup) businessObject;
046 if (EndowPropertyConstants.KEMID_CRNT_REP_GRP_UNITS.equals(attributeName) && ObjectUtils.isNotNull(currentReportingGroup.getUnits())) {
047
048 Properties params = new Properties();
049 params.put(KFSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.SEARCH_METHOD);
050 params.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, CurrentTaxLotBalance.class.getName());
051 params.put(KNSConstants.DOC_FORM_KEY, "88888888");
052 params.put(KFSConstants.HIDE_LOOKUP_RETURN_LINK, "true");
053 params.put(KFSConstants.BACK_LOCATION, SpringContext.getBean(KualiConfigurationService.class).getPropertyString(KNSConstants.APPLICATION_URL_KEY) + "/" + KFSConstants.MAPPING_PORTAL + ".do");
054 params.put(KFSConstants.LOOKUP_READ_ONLY_FIELDS, EndowPropertyConstants.KEMID + "," + EndowPropertyConstants.CURRENT_TAX_LOT_KEMID_PURPOSE_CD + "," + EndowPropertyConstants.CURRENT_TAX_LOT_REP_GRP + "," + EndowPropertyConstants.CURRENT_TAX_LOT_IP_IND + "," + EndowPropertyConstants.CURRENT_TAX_LOT_SECURITY_ID + "," + EndowPropertyConstants.CURRENT_TAX_LOT_REGIS_CD + "," + EndowPropertyConstants.CURRENT_TAX_LOT_BALANCE_DATE + "," + EndowPropertyConstants.CURRENT_TAX_LOT_KEMID_CLOSED_IND + "," + EndowPropertyConstants.CURRENT_TAX_LOT_REGIS_DESC + "," + EndowPropertyConstants.CURRENT_TAX_LOT_SEC_DESC + "," + EndowPropertyConstants.CURRENT_TAX_LOT_KEMID_SHORT_TTL + "," + EndowPropertyConstants.CURRENT_TAX_LOT_PURPOSE_DESC + "," + EndowPropertyConstants.CURRENT_TAX_LOT_INC_PRIN_DESC);
055 params.put(EndowPropertyConstants.KEMID, UrlFactory.encode(String.valueOf(currentReportingGroup.getKemid())));
056 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_KEMID_PURPOSE_CD, UrlFactory.encode(currentReportingGroup.getKemidObj().getPurposeCode()));
057 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_REP_GRP, UrlFactory.encode(currentReportingGroup.getReportingGroupCode()));
058 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_IP_IND, UrlFactory.encode(currentReportingGroup.getIpIndicator()));
059 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_SECURITY_ID, UrlFactory.encode(currentReportingGroup.getSecurityId()));
060 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_REGIS_CD, UrlFactory.encode(currentReportingGroup.getRegistrationCode()));
061 DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
062 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_BALANCE_DATE, dateTimeService.toDateString(currentReportingGroup.getBalanceDate()));
063 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_KEMID_CLOSED_IND, currentReportingGroup.getKemidObj().isClose() ? "Yes" : "No");
064 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_REGIS_DESC, currentReportingGroup.getRegistration().getName());
065 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_SEC_DESC, currentReportingGroup.getSecurity().getDescription());
066 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_KEMID_SHORT_TTL, currentReportingGroup.getKemidObj().getShortTitle());
067 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_PURPOSE_DESC, currentReportingGroup.getKemidObj().getPurpose().getName());
068 params.put(EndowPropertyConstants.CURRENT_TAX_LOT_INC_PRIN_DESC, currentReportingGroup.getIncomePrincipalIndicator().getName());
069
070 String url = UrlFactory.parameterizeUrl(KNSConstants.LOOKUP_ACTION, params);
071
072 Map<String, String> fieldList = new HashMap<String, String>();
073 fieldList.put(EndowPropertyConstants.KEMID, currentReportingGroup.getKemid().toString());
074 fieldList.put(EndowPropertyConstants.CURRENT_BAL_PURPOSE_CD, currentReportingGroup.getKemidObj().getPurposeCode());
075 fieldList.put(EndowPropertyConstants.CURRENT_TAX_LOT_REP_GRP, currentReportingGroup.getReportingGroupCode());
076 fieldList.put(EndowPropertyConstants.CURRENT_TAX_LOT_IP_IND, currentReportingGroup.getIpIndicator());
077 fieldList.put(EndowPropertyConstants.CURRENT_TAX_LOT_SECURITY_ID, currentReportingGroup.getSecurityId());
078 fieldList.put(EndowPropertyConstants.CURRENT_TAX_LOT_REGIS_CD, currentReportingGroup.getRegistrationCode());
079 fieldList.put(EndowPropertyConstants.CURRENT_TAX_LOT_BALANCE_DATE, dateTimeService.toDateString(currentReportingGroup.getBalanceDate()));
080 fieldList.put(EndowPropertyConstants.CURRENT_TAX_LOT_KEMID_CLOSED_IND, currentReportingGroup.getKemidObj().isClose() ? "Yes" : "No");
081 fieldList.put(EndowPropertyConstants.CURRENT_TAX_LOT_REGIS_DESC, currentReportingGroup.getRegistration().getName());
082 fieldList.put(EndowPropertyConstants.CURRENT_TAX_LOT_SEC_DESC, currentReportingGroup.getSecurity().getDescription());
083 fieldList.put(EndowPropertyConstants.CURRENT_TAX_LOT_KEMID_SHORT_TTL, currentReportingGroup.getKemidObj().getShortTitle());
084 fieldList.put(EndowPropertyConstants.CURRENT_TAX_LOT_PURPOSE_DESC, currentReportingGroup.getKemidObj().getPurpose().getName());
085 fieldList.put(EndowPropertyConstants.CURRENT_TAX_LOT_INC_PRIN_DESC, currentReportingGroup.getIncomePrincipalIndicator().getName());
086
087 return getHyperLink(CurrentTaxLotBalance.class, fieldList, url);
088 }
089 return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
090 }
091 }