1 | |
package org.kuali.student.lum.workflow.qualifierresolver; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.List; |
5 | |
|
6 | |
import org.apache.commons.lang.StringUtils; |
7 | |
import org.kuali.rice.kew.engine.RouteContext; |
8 | |
import org.kuali.rice.kew.engine.node.RouteNodeUtils; |
9 | |
import org.kuali.rice.kim.bo.types.dto.AttributeSet; |
10 | |
import org.kuali.rice.student.bo.KualiStudentKimAttributes; |
11 | |
|
12 | 0 | public class OrganizationQualifierResolver extends |
13 | |
AbstractOrganizationServiceQualifierResolver { |
14 | |
protected static final String ROUTE_NODE_XML_ORG_ID_QUALIFIER_KEY = "organizationIdQualifierKey"; |
15 | |
protected static final String ROUTE_NODE_XML_USE_NON_DERIVED_ROLES = "useNonDerivedRoles"; |
16 | |
|
17 | |
@Override |
18 | |
public List<AttributeSet> resolve(RouteContext context) { |
19 | 0 | List<AttributeSet> attributeSets = new ArrayList<AttributeSet>(); |
20 | 0 | String orgIdKey = getNodeSpecificOrganizationIdAttributeSetKey(context); |
21 | 0 | for (String orgId : getOrganizationIdsFromDocumentContent(context)) { |
22 | 0 | AttributeSet attributeSet = new AttributeSet(); |
23 | 0 | attributeSet.put(orgIdKey, orgId); |
24 | 0 | attributeSet.put(KualiStudentKimAttributes.QUALIFICATION_ORG_ID, orgId); |
25 | 0 | attributeSets.add(attributeSet); |
26 | 0 | } |
27 | 0 | return attributeSets; |
28 | |
} |
29 | |
|
30 | |
public String getNodeSpecificOrganizationIdAttributeSetKey(RouteContext context) { |
31 | 0 | String organizationIdFieldKey = RouteNodeUtils.getValueOfCustomProperty(context.getNodeInstance().getRouteNode(), ROUTE_NODE_XML_ORG_ID_QUALIFIER_KEY); |
32 | 0 | if (StringUtils.isBlank(organizationIdFieldKey)) { |
33 | 0 | if (usesNonDerivedOrganizationRoles(context)) { |
34 | 0 | throw new RuntimeException("Cannot find required XML element '" + ROUTE_NODE_XML_ORG_ID_QUALIFIER_KEY + "' on the Route Node XML configuration."); |
35 | |
} |
36 | |
} |
37 | 0 | return organizationIdFieldKey; |
38 | |
} |
39 | |
|
40 | |
public Boolean usesNonDerivedOrganizationRoles(RouteContext context) { |
41 | 0 | String useNonDerivedOrganizationRoles = RouteNodeUtils.getValueOfCustomProperty(context.getNodeInstance().getRouteNode(), ROUTE_NODE_XML_USE_NON_DERIVED_ROLES); |
42 | 0 | if (StringUtils.isNotBlank(useNonDerivedOrganizationRoles)) { |
43 | 0 | return Boolean.valueOf(useNonDerivedOrganizationRoles); |
44 | |
} |
45 | 0 | return true; |
46 | |
} |
47 | |
} |