1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.repository;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.lookup.LookupableImpl;
20 import org.kuali.rice.krad.uif.UifConstants;
21 import org.kuali.rice.krad.uif.UifParameters;
22 import org.kuali.rice.krad.util.KRADConstants;
23 import org.kuali.rice.krad.util.KRADUtils;
24 import org.kuali.rice.krad.util.UrlFactory;
25 import org.kuali.rice.krad.lookup.LookupForm;
26 import org.kuali.rice.krms.api.KrmsConstants;
27 import org.kuali.rice.krms.impl.ui.AgendaEditor;
28
29 import java.util.List;
30 import java.util.Map;
31 import java.util.Properties;
32
33 public class AgendaLookupableHelperServiceImpl extends LookupableImpl {
34
35 @Override
36 public boolean allowsMaintenanceNewOrCopyAction() {
37
38
39 return true;
40 }
41
42 @Override
43 public boolean allowsMaintenanceEditAction(Object dataObject) {
44 boolean allowsEdit = false;
45
46 AgendaBo agenda = (AgendaBo) dataObject;
47 allowsEdit = KrmsRepositoryServiceLocator.getAgendaAuthorizationService().isAuthorized(KrmsConstants.MAINTAIN_KRMS_AGENDA, agenda.getContextId());
48
49 return allowsEdit;
50 }
51
52 @Override
53 public boolean allowsMaintenanceDeleteAction(Object dataObject) {
54 boolean allowsMaintain = false;
55 boolean allowsDelete = false;
56
57 AgendaBo agenda = (AgendaBo) dataObject;
58 allowsMaintain = KrmsRepositoryServiceLocator.getAgendaAuthorizationService().isAuthorized(KrmsConstants.MAINTAIN_KRMS_AGENDA, agenda.getContextId());
59
60 return allowsDelete && allowsMaintain;
61 }
62
63 @Override
64 protected String getMaintenanceActionUrl(LookupForm lookupForm, Object dataObject, String methodToCall,
65 List<String> pkNames) {
66 Properties props = new Properties();
67 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
68
69 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
70 for (String primaryKey : primaryKeyValues.keySet()) {
71 String primaryKeyValue = primaryKeyValues.get(primaryKey);
72
73 props.put(primaryKey, primaryKeyValue);
74 props.put(KRADConstants.OVERRIDE_KEYS, primaryKey);
75 }
76
77 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
78 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
79 }
80
81 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, AgendaEditor.class.getName());
82 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
83
84 return UrlFactory.parameterizeUrl(org.kuali.rice.krms.impl.util.KrmsImplConstants.WebPaths.AGENDA_EDITOR_PATH, props);
85 }
86 }