1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.lum.statement.config.context;
17
18 import java.util.Map;
19
20 import org.kuali.student.common.exceptions.OperationFailedException;
21 import org.kuali.student.core.organization.dto.OrgInfo;
22 import org.kuali.student.core.organization.service.OrganizationService;
23 import org.kuali.student.core.statement.dto.ReqComponentInfo;
24 import org.kuali.student.lum.statement.typekey.ReqComponentFieldTypes;
25
26
27
28
29 public class OrganizationContextImpl extends BasicContextImpl {
30
31 private OrganizationService organizationService;
32
33 public final static String ORG_TOKEN = "org";
34
35 public void setOrganizationService(OrganizationService organizationService) {
36 this.organizationService = organizationService;
37 }
38
39 private OrgInfo getOrganization(String orgId) throws OperationFailedException {
40 if (orgId == null) {
41 return null;
42 }
43 try {
44 return organizationService.getOrganization(orgId);
45 } catch (Exception e) {
46 throw new OperationFailedException(e.getMessage(), e);
47 }
48 }
49
50
51
52
53
54
55
56 public Map<String, Object> createContextMap(ReqComponentInfo reqComponent) throws OperationFailedException {
57 String orgId = getReqComponentFieldValue(reqComponent, ReqComponentFieldTypes.ORGANIZATION_KEY.getId());
58 OrgInfo org = getOrganization(orgId);
59
60 Map<String, Object> contextMap = super.createContextMap(reqComponent);
61 contextMap.put(ORG_TOKEN, org);
62 return contextMap;
63 }
64 }