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.core.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 | |
|
51 | 0 | public class CocOrganizationQualifierResolver extends AbstractOrganizationServiceQualifierResolver { |
52 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CocOrganizationQualifierResolver.class); |
53 | |
|
54 | |
protected static final String ROUTE_NODE_XML_ORG_ID_QUALIFIER_KEY = "organizationIdQualifierKey"; |
55 | |
protected static final String ROUTE_NODE_XML_ORG_SHORT_NAME_QUALIFIER_KEY = "organizationShortNameQualifierKey"; |
56 | |
protected static final String ROUTE_NODE_XML_USE_NON_DERIVED_ROLES = "useNonDerivedRoles"; |
57 | |
|
58 | |
public static final String KUALI_ORG_TYPE_CURRICULUM_PARENT = "kuali.org.CurriculumParent"; |
59 | |
public static final String KUALI_ORG_HIERARCHY_CURRICULUM = "kuali.org.hierarchy.Curriculum"; |
60 | |
public static final String KUALI_ORG_COC = "kuali.org.COC"; |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
@Override |
66 | |
public List<AttributeSet> resolve(RouteContext context) { |
67 | 0 | List<AttributeSet> attributeSets = new ArrayList<AttributeSet>(); |
68 | 0 | String orgShortNameKey = getNodeSpecificOrganizationShortNameAttributeSetKey(context); |
69 | 0 | String orgIdKey = getNodeSpecificOrganizationIdAttributeSetKey(context); |
70 | 0 | for (String orgId : getOrganizationIdsFromDocumentContent(context)) { |
71 | 0 | List<SearchResultRow> results = relatedOrgsFromOrgId(orgId, getOrganizationRelationTypeCode(), getRelatedOrganizationTypeCode()); |
72 | 0 | attributeSets.addAll(attributeSetFromSearchResult(results, orgShortNameKey, orgIdKey)); |
73 | 0 | } |
74 | 0 | return attributeSets; |
75 | |
} |
76 | |
|
77 | |
public String getNodeSpecificOrganizationIdAttributeSetKey(RouteContext context) { |
78 | 0 | String organizationIdFieldKey = RouteNodeUtils.getValueOfCustomProperty(context.getNodeInstance().getRouteNode(), ROUTE_NODE_XML_ORG_ID_QUALIFIER_KEY); |
79 | 0 | if (StringUtils.isBlank(organizationIdFieldKey)) { |
80 | 0 | if (usesNonDerivedOrganizationRoles(context)) { |
81 | 0 | throw new RuntimeException("Cannot find required XML element '" + ROUTE_NODE_XML_ORG_ID_QUALIFIER_KEY + "' on the Route Node XML configuration."); |
82 | |
} |
83 | |
} |
84 | 0 | return organizationIdFieldKey; |
85 | |
} |
86 | |
|
87 | |
public String getNodeSpecificOrganizationShortNameAttributeSetKey(RouteContext context) { |
88 | 0 | String organizationShortNameFieldKey = RouteNodeUtils.getValueOfCustomProperty(context.getNodeInstance().getRouteNode(), ROUTE_NODE_XML_ORG_SHORT_NAME_QUALIFIER_KEY); |
89 | 0 | if (StringUtils.isBlank(organizationShortNameFieldKey)) { |
90 | 0 | if (usesNonDerivedOrganizationRoles(context)) { |
91 | 0 | throw new RuntimeException("Cannot find required XML element '" + ROUTE_NODE_XML_ORG_SHORT_NAME_QUALIFIER_KEY + "' on the Route Node XML configuration."); |
92 | |
} |
93 | |
} |
94 | 0 | return organizationShortNameFieldKey; |
95 | |
} |
96 | |
|
97 | |
public Boolean usesNonDerivedOrganizationRoles(RouteContext context) { |
98 | 0 | String useNonDerivedOrganizationRoles = RouteNodeUtils.getValueOfCustomProperty(context.getNodeInstance().getRouteNode(), ROUTE_NODE_XML_USE_NON_DERIVED_ROLES); |
99 | 0 | if (StringUtils.isNotBlank(useNonDerivedOrganizationRoles)) { |
100 | 0 | return Boolean.valueOf(useNonDerivedOrganizationRoles); |
101 | |
} |
102 | 0 | return true; |
103 | |
} |
104 | |
|
105 | |
protected String getOrganizationHierarchyTypeCode() { |
106 | 0 | return KUALI_ORG_HIERARCHY_CURRICULUM; |
107 | |
} |
108 | |
|
109 | |
protected String getOrganizationRelationTypeCode() { |
110 | 0 | return KUALI_ORG_TYPE_CURRICULUM_PARENT; |
111 | |
} |
112 | |
|
113 | |
protected String getRelatedOrganizationTypeCode() { |
114 | 0 | return KUALI_ORG_COC; |
115 | |
} |
116 | |
|
117 | |
} |