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 | 0 | 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 | 0 | this.organizationService = organizationService; |
37 | 0 | } |
38 | |
|
39 | |
private OrgInfo getOrganization(String orgId) throws OperationFailedException { |
40 | 0 | if (orgId == null) { |
41 | 0 | return null; |
42 | |
} |
43 | |
try { |
44 | 0 | return organizationService.getOrganization(orgId); |
45 | 0 | } catch (Exception e) { |
46 | 0 | 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 | 0 | String orgId = getReqComponentFieldValue(reqComponent, ReqComponentFieldTypes.ORGANIZATION_KEY.getId()); |
58 | 0 | OrgInfo org = getOrganization(orgId); |
59 | |
|
60 | 0 | Map<String, Object> contextMap = super.createContextMap(reqComponent); |
61 | 0 | contextMap.put(ORG_TOKEN, org); |
62 | 0 | return contextMap; |
63 | |
} |
64 | |
} |