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