1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.krms.termresolver;
17
18 import org.kuali.rice.krms.api.engine.TermResolutionException;
19 import org.kuali.rice.krms.api.engine.TermResolver;
20 import org.kuali.student.krms.util.KSKRMSExecutionUtil;
21 import org.kuali.student.r2.common.dto.ContextInfo;
22 import org.kuali.student.r2.core.constants.KSKRMSServiceConstants;
23 import org.kuali.student.r2.core.organization.dto.OrgInfo;
24 import org.kuali.student.r2.core.organization.service.OrganizationService;
25
26 import java.util.Collections;
27 import java.util.HashSet;
28 import java.util.Map;
29 import java.util.Set;
30
31
32
33
34 public class AdminOrgPermissionTermResolver implements TermResolver<Boolean> {
35
36 private OrganizationService organizationService;
37
38 @Override
39 public Set<String> getPrerequisites() {
40 Set<String> prereqs = new HashSet<String>(2);
41 prereqs.add(KSKRMSServiceConstants.TERM_PREREQUISITE_PERSON_ID);
42 prereqs.add(KSKRMSServiceConstants.TERM_PREREQUISITE_CONTEXTINFO);
43 return Collections.unmodifiableSet(prereqs);
44 }
45
46 @Override
47 public String getOutput() {
48 return KSKRMSServiceConstants.TERM_RESOLVER_ADMINORGANIZATIONPERMISSIONREQUIRED;
49 }
50
51 @Override
52 public Set<String> getParameterNames() {
53 return Collections.singleton(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_ORGANIZATION_KEY);
54 }
55
56 @Override
57 public int getCost() {
58 return 1;
59 }
60
61 @Override
62 public Boolean resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException {
63 ContextInfo context = (ContextInfo) resolvedPrereqs.get(KSKRMSServiceConstants.TERM_PREREQUISITE_CONTEXTINFO);
64 String orgId = parameters.get(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_ORGANIZATION_KEY);
65
66 try {
67 OrgInfo org = organizationService.getOrg(orgId, context);
68
69 } catch (Exception e) {
70 KSKRMSExecutionUtil.convertExceptionsToTermResolutionException(parameters, e, this);
71 }
72
73 return true;
74 }
75
76 public OrganizationService getOrganizationService() {
77 return organizationService;
78 }
79
80 public void setOrganizationService(OrganizationService organizationService) {
81 this.organizationService = organizationService;
82 }
83
84 }