1
2
3
4 package org.kuali.student.lum.workflow.qualifierresolver;
5
6 import java.util.ArrayList;
7 import java.util.LinkedHashMap;
8 import java.util.List;
9 import java.util.Map;
10
11 import org.apache.commons.lang.StringUtils;
12 import org.kuali.rice.kew.engine.RouteContext;
13 import org.kuali.rice.student.bo.KualiStudentKimAttributes;
14 import org.kuali.student.common.util.security.ContextUtils;
15 import org.kuali.student.r2.core.organization.dto.OrgInfo;
16 import org.kuali.student.r2.core.organization.dto.OrgOrgRelationInfo;
17 import org.kuali.student.r2.core.organization.service.OrganizationService;
18 import org.kuali.student.lum.workflow.node.OrganizationDynamicNode;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 @Deprecated
41 public class OrganizationCurriculumCommitteeQualifierResolver extends AbstractOrganizationServiceQualifierResolver {
42 protected static final Logger LOG = LoggerFactory.getLogger(OrganizationCurriculumCommitteeQualifierResolver.class);
43
44 @Override
45 public List<Map<String,String>> resolve(RouteContext routeContext) {
46
47 String orgIdValue = routeContext.getNodeInstance().getNodeState(OrganizationDynamicNode.NODE_STATE_ORG_ID_KEY).getValue();
48 if (StringUtils.isBlank(orgIdValue)) {
49 throw new RuntimeException("Cannot find valid organization ID in Route Node Instance Node States");
50 }
51 LOG.debug("orgIdValue = '{}'", orgIdValue);
52
53 try {
54 List<Map<String,String>> attributeSets = new ArrayList<Map<String,String>>();
55
56 List<OrgOrgRelationInfo> orgRelationInfos = getOrganizationService().getOrgOrgRelationsByOrg(orgIdValue, ContextUtils.getContextInfo());
57 for (OrgOrgRelationInfo orgOrgRelationInfo : orgRelationInfos) {
58
59 if (StringUtils.equals("Active", orgOrgRelationInfo.getStateKey())) {
60
61 if (StringUtils.equals(AbstractOrganizationServiceQualifierResolver.KUALI_ORG_TYPE_CURRICULUM_PARENT, orgOrgRelationInfo.getTypeKey())) {
62 OrgInfo nextNodeOrgInfo = getOrganization(orgOrgRelationInfo.getRelatedOrgId());
63
64 if (StringUtils.equals(AbstractOrganizationServiceQualifierResolver.KUALI_ORG_COC, nextNodeOrgInfo.getTypeKey())) {
65 LOG.debug("---- Related Org Relation: {} - {} ({})", nextNodeOrgInfo.getId(), nextNodeOrgInfo.getShortName(), nextNodeOrgInfo.getLongName());
66 Map<String,String> attributeSet = new LinkedHashMap<String,String>();
67 attributeSet.put(KualiStudentKimAttributes.QUALIFICATION_ORG_ID, nextNodeOrgInfo.getId());
68 attributeSets.add(attributeSet);
69 }
70 }
71 }
72 }
73
74 if (attributeSets.isEmpty()) {
75 OrgInfo currentNodeOrg = getOrganization(orgIdValue);
76 Map<String,String> attributeSet = new LinkedHashMap<String,String>();
77 attributeSet.put(KualiStudentKimAttributes.QUALIFICATION_ORG_ID, currentNodeOrg.getId());
78 attributeSets.add(attributeSet);
79 }
80 return attributeSets;
81 } catch (Exception e) {
82 LOG.error("Error getting organization(s) or organization relations", e);
83 throw new RuntimeException(e);
84 }
85 }
86
87 protected OrgInfo getOrganization(String orgId) throws Exception {
88
89 OrgInfo orgInfo = getOrganizationService().getOrg(orgId, null);
90 return orgInfo;
91
92
93
94
95 }
96
97 }