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.krms.impl.repository; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.krad.lookup.LookupableImpl; 020import org.kuali.rice.krad.uif.UifConstants; 021import org.kuali.rice.krad.uif.UifParameters; 022import org.kuali.rice.krad.util.KRADConstants; 023import org.kuali.rice.krad.util.KRADUtils; 024import org.kuali.rice.krad.util.UrlFactory; 025import org.kuali.rice.krad.lookup.LookupForm; 026 027import java.util.List; 028import java.util.Map; 029import java.util.Properties; 030 031public class PropositionLookupableHelperServiceImpl extends LookupableImpl { 032 033 @Override 034 public boolean allowsMaintenanceNewOrCopyAction() { 035 return true; 036 } 037 038 @Override 039 public boolean allowsMaintenanceEditAction(Object dataObject) { 040 return true; 041 } 042 043 @Override 044 public boolean allowsMaintenanceDeleteAction(Object dataObject) { 045 return true; 046 } 047 048 @Override 049 protected String getMaintenanceActionUrl(LookupForm lookupForm, Object dataObject, String methodToCall, 050 List<String> pkNames) { 051 Properties props = new Properties(); 052 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall); 053 054 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject); 055 for (String primaryKey : primaryKeyValues.keySet()) { 056 String primaryKeyValue = primaryKeyValues.get(primaryKey); 057 058 props.put(primaryKey, primaryKeyValue); 059 props.put(KRADConstants.OVERRIDE_KEYS, primaryKey); 060 } 061 062 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) { 063 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation()); 064 } 065 066 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, PropositionBo.class.getName()); 067 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name()); 068 069 return UrlFactory.parameterizeUrl(org.kuali.rice.krms.impl.util.KrmsImplConstants.WebPaths.PROPOSITION_PATH, props); 070 } 071}