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.coa.identity;
017
018 import java.util.Collections;
019 import java.util.Map;
020 import java.util.Properties;
021
022 import org.apache.commons.lang.StringUtils;
023 import org.kuali.kfs.coa.service.OrgReviewRoleService;
024 import org.kuali.kfs.sys.businessobject.inquiry.KfsInquirableImpl;
025 import org.kuali.kfs.sys.context.SpringContext;
026 import org.kuali.rice.kns.bo.BusinessObject;
027 import org.kuali.rice.kns.lookup.HtmlData;
028 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
029 import org.kuali.rice.kns.util.KNSConstants;
030 import org.kuali.rice.kns.util.UrlFactory;
031
032 public class OrgReviewRoleInquirableImpl extends KfsInquirableImpl {
033
034
035 @Override
036 public BusinessObject getBusinessObject(Map fieldValues) {
037 OrgReviewRole orr = new OrgReviewRole();
038 if ( StringUtils.isNotBlank( (String)fieldValues.get("orgReviewRoleMemberId") ) ) {
039 if ( StringUtils.equals("true", (String)fieldValues.get("delegate") ) ) {
040 SpringContext.getBean( OrgReviewRoleService.class ).populateOrgReviewRoleFromDelegationMember(orr, (String)fieldValues.get("orgReviewRoleMemberId") );
041 } else {
042 SpringContext.getBean( OrgReviewRoleService.class ).populateOrgReviewRoleFromRoleMember(orr, (String)fieldValues.get("orgReviewRoleMemberId") );
043 }
044 }
045 return orr;
046 }
047
048 @Override
049 public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
050 if ( StringUtils.equals( attributeName, "orgReviewRoleInquiryTitle") ) {
051 Properties parameters = new Properties();
052 parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, "start");
053 parameters.put(KNSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, OrgReviewRole.class.getName());
054 if ( StringUtils.isNotBlank(((OrgReviewRole)businessObject).getDelegationMemberId()) ) {
055 parameters.put("orgReviewRoleMemberId", ((OrgReviewRole)businessObject).getDelegationMemberId() );
056 parameters.put("delegate", "true" );
057 } else if ( StringUtils.isNotBlank(((OrgReviewRole)businessObject).getRoleMemberId()) ) {
058 parameters.put("orgReviewRoleMemberId", ((OrgReviewRole)businessObject).getRoleMemberId() );
059 parameters.put("delegate", "false" );
060 }
061 return getHyperLink(OrgReviewRole.class, Collections.EMPTY_MAP, UrlFactory.parameterizeUrl(KNSConstants.INQUIRY_ACTION, parameters));
062 } else {
063 return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
064 }
065 }
066
067 }