Coverage Report - org.kuali.student.lum.workflow.qualifierresolver.ParentOrganizationQualifierResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
ParentOrganizationQualifierResolver
0%
0/27
0%
0/12
3
 
 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.student.common.search.dto.SearchResultRow;
 11  
 
 12  0
 public class ParentOrganizationQualifierResolver 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  
     protected static final String ROUTE_NODE_XML_ORG_RELATION_TYPE = "organizationRelationType";
 18  
     protected static final String ROUTE_NODE_XML_RELATED_ORG_TYPE = "relatedOrganizationType";
 19  
     
 20  
         @Override
 21  
         public List<AttributeSet> resolve(RouteContext context) {
 22  0
         List<AttributeSet> attributeSets = new ArrayList<AttributeSet>();
 23  
         
 24  0
         String orgIdKey = getNodeSpecificOrganizationIdAttributeSetKey(context);
 25  0
         String orgRelationType = getOrganizationRelationTypeCode(context);
 26  0
         String relatedOrgType = getRelatedOrganizationTypeCode(context);
 27  
         
 28  0
         for (String orgId : getOrganizationIdsFromDocumentContent(context)) {
 29  0
             List<SearchResultRow> results = relatedOrgsFromOrgId(orgId, orgRelationType, relatedOrgType);
 30  0
             attributeSets.addAll(attributeSetFromSearchResult(results, orgIdKey));
 31  0
         }
 32  0
         return attributeSets;
 33  
         }
 34  
         
 35  
     protected String getRelatedOrganizationTypeCode(RouteContext context) {
 36  0
              String relatedOrganizationType = RouteNodeUtils.getValueOfCustomProperty(context.getNodeInstance().getRouteNode(), ROUTE_NODE_XML_RELATED_ORG_TYPE);
 37  0
              if(StringUtils.isBlank(relatedOrganizationType)){
 38  0
                      throw new RuntimeException("Cannot find required XML element '" + ROUTE_NODE_XML_RELATED_ORG_TYPE + "' on the Route Node XML configuration.");
 39  
              }
 40  0
              return relatedOrganizationType;
 41  
         }
 42  
 
 43  
         protected String getOrganizationRelationTypeCode(RouteContext context) {
 44  0
             String orgRelationType = RouteNodeUtils.getValueOfCustomProperty(context.getNodeInstance().getRouteNode(), ROUTE_NODE_XML_ORG_RELATION_TYPE);
 45  0
             if(StringUtils.isBlank(orgRelationType)){
 46  0
                     throw new RuntimeException("Cannot find required XML element '" + ROUTE_NODE_XML_ORG_RELATION_TYPE + "' on the Route Node XML configuration.");
 47  
             }
 48  0
             return orgRelationType;
 49  
         }
 50  
 
 51  
         public String getNodeSpecificOrganizationIdAttributeSetKey(RouteContext context) {
 52  0
         String organizationIdFieldKey = RouteNodeUtils.getValueOfCustomProperty(context.getNodeInstance().getRouteNode(), ROUTE_NODE_XML_ORG_ID_QUALIFIER_KEY);
 53  0
         if (StringUtils.isBlank(organizationIdFieldKey)) {
 54  0
             if (usesNonDerivedOrganizationRoles(context)) {
 55  0
                 throw new RuntimeException("Cannot find required XML element '" + ROUTE_NODE_XML_ORG_ID_QUALIFIER_KEY + "' on the Route Node XML configuration.");
 56  
             }
 57  
         }
 58  0
         return organizationIdFieldKey;
 59  
     }
 60  
     
 61  
     public Boolean usesNonDerivedOrganizationRoles(RouteContext context) {
 62  0
         String useNonDerivedOrganizationRoles = RouteNodeUtils.getValueOfCustomProperty(context.getNodeInstance().getRouteNode(), ROUTE_NODE_XML_USE_NON_DERIVED_ROLES);
 63  0
         if (StringUtils.isNotBlank(useNonDerivedOrganizationRoles)) {
 64  0
             return Boolean.valueOf(useNonDerivedOrganizationRoles);
 65  
         }
 66  0
         return true;
 67  
     }
 68  
 }