1 | |
|
2 | |
|
3 | |
|
4 | |
package org.kuali.student.lum.workflow.qualifierresolver; |
5 | |
|
6 | |
import java.util.ArrayList; |
7 | |
import java.util.List; |
8 | |
|
9 | |
import org.apache.commons.lang.StringUtils; |
10 | |
import org.kuali.rice.kew.engine.RouteContext; |
11 | |
import org.kuali.rice.kew.engine.node.RouteNodeUtils; |
12 | |
import org.kuali.rice.kim.bo.types.dto.AttributeSet; |
13 | |
import org.kuali.student.common.search.dto.SearchResultRow; |
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | 0 | public class CocOrganizationQualifierResolver extends AbstractOrganizationServiceQualifierResolver { |
51 | |
|
52 | |
protected static final String ROUTE_NODE_XML_ORG_ID_QUALIFIER_KEY = "organizationIdQualifierKey"; |
53 | |
protected static final String ROUTE_NODE_XML_USE_NON_DERIVED_ROLES = "useNonDerivedRoles"; |
54 | |
|
55 | |
public static final String KUALI_ORG_TYPE_CURRICULUM_PARENT = "kuali.org.CurriculumParent"; |
56 | |
public static final String KUALI_ORG_HIERARCHY_CURRICULUM = "kuali.org.hierarchy.Curriculum"; |
57 | |
public static final String KUALI_ORG_COC = "kuali.org.COC"; |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
@Override |
63 | |
public List<AttributeSet> resolve(RouteContext context) { |
64 | 0 | List<AttributeSet> attributeSets = new ArrayList<AttributeSet>(); |
65 | 0 | String orgIdKey = getNodeSpecificOrganizationIdAttributeSetKey(context); |
66 | 0 | for (String orgId : getOrganizationIdsFromDocumentContent(context)) { |
67 | 0 | List<SearchResultRow> results = relatedOrgsFromOrgId(orgId, getOrganizationRelationTypeCode(), getRelatedOrganizationTypeCode()); |
68 | 0 | attributeSets.addAll(attributeSetFromSearchResult(results, orgIdKey)); |
69 | 0 | } |
70 | 0 | return attributeSets; |
71 | |
} |
72 | |
|
73 | |
public String getNodeSpecificOrganizationIdAttributeSetKey(RouteContext context) { |
74 | 0 | String organizationIdFieldKey = RouteNodeUtils.getValueOfCustomProperty(context.getNodeInstance().getRouteNode(), ROUTE_NODE_XML_ORG_ID_QUALIFIER_KEY); |
75 | 0 | if (StringUtils.isBlank(organizationIdFieldKey)) { |
76 | 0 | if (usesNonDerivedOrganizationRoles(context)) { |
77 | 0 | throw new RuntimeException("Cannot find required XML element '" + ROUTE_NODE_XML_ORG_ID_QUALIFIER_KEY + "' on the Route Node XML configuration."); |
78 | |
} |
79 | |
} |
80 | 0 | return organizationIdFieldKey; |
81 | |
} |
82 | |
|
83 | |
public Boolean usesNonDerivedOrganizationRoles(RouteContext context) { |
84 | 0 | String useNonDerivedOrganizationRoles = RouteNodeUtils.getValueOfCustomProperty(context.getNodeInstance().getRouteNode(), ROUTE_NODE_XML_USE_NON_DERIVED_ROLES); |
85 | 0 | if (StringUtils.isNotBlank(useNonDerivedOrganizationRoles)) { |
86 | 0 | return Boolean.valueOf(useNonDerivedOrganizationRoles); |
87 | |
} |
88 | 0 | return true; |
89 | |
} |
90 | |
|
91 | |
protected String getOrganizationHierarchyTypeCode() { |
92 | 0 | return KUALI_ORG_HIERARCHY_CURRICULUM; |
93 | |
} |
94 | |
|
95 | |
protected String getOrganizationRelationTypeCode() { |
96 | 0 | return KUALI_ORG_TYPE_CURRICULUM_PARENT; |
97 | |
} |
98 | |
|
99 | |
protected String getRelatedOrganizationTypeCode() { |
100 | 0 | return KUALI_ORG_COC; |
101 | |
} |
102 | |
|
103 | |
} |