001 /** 002 * Copyright 2005-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.rice.krms.impl.repository; 017 018 import org.apache.commons.lang.StringUtils; 019 import org.kuali.rice.krad.lookup.LookupableImpl; 020 import org.kuali.rice.krad.uif.UifConstants; 021 import org.kuali.rice.krad.uif.UifParameters; 022 import org.kuali.rice.krad.util.KRADConstants; 023 import org.kuali.rice.krad.util.KRADUtils; 024 import org.kuali.rice.krad.util.UrlFactory; 025 import org.kuali.rice.krad.web.form.LookupForm; 026 027 import java.util.List; 028 import java.util.Map; 029 import java.util.Properties; 030 031 public 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 getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall, List<String> pkNames) { 050 Properties props = new Properties(); 051 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall); 052 053 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject); 054 for (String primaryKey : primaryKeyValues.keySet()) { 055 String primaryKeyValue = primaryKeyValues.get(primaryKey); 056 057 props.put(primaryKey, primaryKeyValue); 058 props.put(KRADConstants.OVERRIDE_KEYS, primaryKey); 059 } 060 061 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) { 062 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation()); 063 } 064 065 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, PropositionBo.class.getName()); 066 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name()); 067 068 return UrlFactory.parameterizeUrl(org.kuali.rice.krms.impl.util.KrmsImplConstants.WebPaths.PROPOSITION_PATH, props); 069 } 070 }