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.core.organization.dto.OrgInfo; |
21 | |
import org.kuali.student.core.organization.service.OrganizationService; |
22 | |
import org.kuali.student.core.statement.dto.ReqComponentInfo; |
23 | |
import org.kuali.student.core.exceptions.OperationFailedException; |
24 | |
import org.kuali.student.lum.statement.typekey.ReqComponentFieldTypes; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 12 | 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 | 6 | this.organizationService = organizationService; |
37 | 6 | } |
38 | |
|
39 | |
private OrgInfo getOrganization(String orgId) throws OperationFailedException { |
40 | 8 | if (orgId == null) { |
41 | 1 | return null; |
42 | |
} |
43 | |
try { |
44 | 7 | 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 | 8 | String orgId = getReqComponentFieldValue(reqComponent, ReqComponentFieldTypes.ORGANIZATION_KEY.getId()); |
58 | 8 | OrgInfo org = getOrganization(orgId); |
59 | |
|
60 | 8 | Map<String, Object> contextMap = super.createContextMap(reqComponent); |
61 | 8 | contextMap.put(ORG_TOKEN, org); |
62 | 8 | return contextMap; |
63 | |
} |
64 | |
} |