001    /**
002     * Copyright 2004-2013 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.hr.lookup;
017    
018    import org.apache.commons.lang.StringUtils;
019    import org.kuali.rice.kns.lookup.KualiLookupableImpl;
020    import org.kuali.rice.krad.util.KRADConstants;
021    import org.kuali.rice.krad.util.UrlFactory;
022    
023    import java.util.Properties;
024    
025    
026    public class KPMELookupableImpl extends KualiLookupableImpl {
027    
028        /**
029         * @see org.kuali.rice.kns.lookup.Lookupable#getCreateNewUrl()
030         */
031        @Override
032        public String getCreateNewUrl() {
033            String url = "";
034    
035            if (getLookupableHelperService().allowsMaintenanceNewOrCopyAction()) {
036                Properties parameters = new Properties();
037                parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
038                parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, this.businessObjectClass.getName());
039                if (StringUtils.isNotBlank(getReturnLocation())) {
040                    parameters.put(KRADConstants.RETURN_LOCATION_PARAMETER, getReturnLocation());
041                }
042                url = UrlFactory.parameterizeUrl(KRADConstants.MAINTENANCE_ACTION, parameters);
043                url = "<a title=\"Create a new record\" href=\"" + url + "\"><img src=\"images/tinybutton-createnew.gif\" alt=\"create new\" width=\"70\" height=\"15\"/></a>";
044            }
045    
046            return url;
047        }
048    }