001/**
002 * Copyright 2005-2017 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 */
016package org.kuali.rice.kim.lookup;
017
018import org.apache.commons.lang.StringUtils;
019import org.kuali.rice.kim.api.KimConstants;
020import org.kuali.rice.kim.impl.permission.GenericPermissionBo;
021import org.kuali.rice.kns.lookup.KualiLookupableImpl;
022import org.kuali.rice.krad.util.KRADConstants;
023import org.kuali.rice.krad.util.UrlFactory;
024
025import java.util.Properties;
026
027/**
028 * This is a description of what this class does - kellerj don't forget to fill this in. 
029 * 
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 *
032 */
033public class PermissionLookupableImpl extends KualiLookupableImpl {
034
035        
036        /**
037         * This overridden method ...
038         * 
039         * @see org.kuali.rice.krad.lookup.KualiLookupableImpl#getCreateNewUrl()
040         */
041        @Override
042        public String getCreateNewUrl() {
043        String url = "";
044
045        if (getLookupableHelperService().allowsNewOrCopyAction(KimConstants.KimUIConstants.KIM_PERMISSION_DOCUMENT_TYPE_NAME)) {
046            Properties parameters = new Properties();
047            parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
048            parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, GenericPermissionBo.class.getName());
049                if (StringUtils.isNotBlank(getReturnLocation())) {
050                        parameters.put(KRADConstants.RETURN_LOCATION_PARAMETER, getReturnLocation());
051                        }
052            url = UrlFactory.parameterizeUrl(KRADConstants.MAINTENANCE_ACTION, parameters);
053            url = "<a title=\"Create a new record\" href=\"" + url + "\"><img src=\"images/tinybutton-createnew.gif\" alt=\"create new\" width=\"70\" height=\"15\"/></a>";
054        }
055
056        return url;
057        }
058}