| 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.kim.bo.types.dto.AttributeSet;     | 
  
            
  
    | 12 | 
    
            
    
     | 
    
      import org.kuali.rice.student.bo.KualiStudentKimAttributes;     | 
  
            
  
    | 13 | 
    
            
    
     | 
    
      import org.kuali.student.common.exceptions.DoesNotExistException;     | 
  
            
  
    | 14 | 
    
            
    
     | 
    
      import org.kuali.student.core.organization.dto.OrgInfo;     | 
  
            
  
    | 15 | 
    
            
    
     | 
    
      import org.kuali.student.core.organization.dto.OrgOrgRelationInfo;     | 
  
            
  
    | 16 | 
    
            
    
     | 
    
      import org.kuali.student.core.organization.service.OrganizationService;     | 
  
            
  
    | 17 | 
    
            
    
     | 
    
      import org.kuali.student.lum.workflow.node.OrganizationDynamicNode;     | 
  
            
  
    | 18 | 
    
            
    
     | 
    
           | 
  
            
  
    | 19 | 
    
            
    
     | 
    
           | 
  
            
  
    | 20 | 
    
            
    
     | 
    
      @link     | 
  
            
  
    | 21 | 
    
            
    
     | 
    
           | 
  
            
  
    | 22 | 
    
            
    
     | 
    
           | 
  
            
  
    | 23 | 
    
            
    
     | 
    
      @link     | 
  
            
  
    | 24 | 
    
            
    
     | 
    
           | 
  
            
  
    | 25 | 
    
            
    
     | 
    
      @link     | 
  
            
  
    | 26 | 
    
            
    
     | 
    
           | 
  
            
  
    | 27 | 
    
            
    
     | 
    
      @link     | 
  
            
  
    | 28 | 
    
            
    
     | 
    
           | 
  
            
  
    | 29 | 
    
            
    
     | 
    
           | 
  
            
  
    | 30 | 
    
            
    
     | 
    
           | 
  
            
  
    | 31 | 
    
            
    
     | 
    
           | 
  
            
  
    | 32 | 
    
            
    
     | 
    
      @link     | 
  
            
  
    | 33 | 
    
            
    
     | 
    
           | 
  
            
  
    | 34 | 
    
            
    
     | 
    
           | 
  
            
  
    | 35 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 46 (46) | 
           Complexity: 11 | 
           Complexity Density: 0.37 | 
                        
            
        | 
    
  
  
    | 36 | 
    
            
    
     | 
    
      public class OrganizationCurriculumCommitteeQualifierResolver extends AbstractOrganizationServiceQualifierResolver {     | 
  
            
  
    | 37 | 
    
            
    
     | 
    
          protected static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OrganizationCurriculumCommitteeQualifierResolver.class);     | 
  
            
  
    | 38 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 40 (40) | 
           Complexity: 9 | 
           Complexity Density: 0.35 | 
                        
            
        | 
    
  
  
    | 39 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 40 | 
    
            
    
     | 
    
          public List<AttributeSet> resolve(RouteContext routeContext) {     | 
  
            
  
    | 41 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 42 | 
    
           0
    
     | 
    
              String orgIdValue = routeContext.getNodeInstance().getNodeState(OrganizationDynamicNode.NODE_STATE_ORG_ID_KEY).getValue();     | 
  
            
  
    | 43 | 
    
           0
    
     | 
    
              if (StringUtils.isBlank(orgIdValue)) {     | 
  
            
  
    | 44 | 
    
           0
    
     | 
    
                  throw new RuntimeException("Cannot find valid organization ID in Route Node Instance Node States");     | 
  
            
  
    | 45 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 46 | 
    
           0
    
     | 
    
              if (LOG.isDebugEnabled()) {     | 
  
            
  
    | 47 | 
    
           0
    
     | 
    
                  LOG.debug("orgIdValue = '" + orgIdValue + "'");     | 
  
            
  
    | 48 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 49 | 
    
            
    
     | 
    
           | 
  
            
  
    | 50 | 
    
           0
    
     | 
    
              try {     | 
  
            
  
    | 51 | 
    
           0
    
     | 
    
                  List<AttributeSet> attributeSets = new ArrayList<AttributeSet>();     | 
  
            
  
    | 52 | 
    
            
    
     | 
    
                       | 
  
            
  
    | 53 | 
    
           0
    
     | 
    
                  List<OrgOrgRelationInfo> orgRelationInfos = getOrganizationService().getOrgOrgRelationsByOrg(orgIdValue);     | 
  
            
  
    | 54 | 
    
           0
    
     | 
    
                  for (OrgOrgRelationInfo orgOrgRelationInfo : orgRelationInfos) {     | 
  
            
  
    | 55 | 
    
            
    
     | 
    
                           | 
  
            
  
    | 56 | 
    
           0
    
     | 
    
                      if (StringUtils.equals("Active", orgOrgRelationInfo.getState())) {     | 
  
            
  
    | 57 | 
    
            
    
     | 
    
                               | 
  
            
  
    | 58 | 
    
           0
    
     | 
    
                          if (StringUtils.equals(AbstractOrganizationServiceQualifierResolver.KUALI_ORG_TYPE_CURRICULUM_PARENT, orgOrgRelationInfo.getType())) {     | 
  
            
  
    | 59 | 
    
           0
    
     | 
    
                              OrgInfo nextNodeOrgInfo = getOrganization(orgOrgRelationInfo.getRelatedOrgId());     | 
  
            
  
    | 60 | 
    
            
    
     | 
    
                                   | 
  
            
  
    | 61 | 
    
           0
    
     | 
    
                              if (StringUtils.equals(AbstractOrganizationServiceQualifierResolver.KUALI_ORG_COC, nextNodeOrgInfo.getType())) {     | 
  
            
  
    | 62 | 
    
           0
    
     | 
    
                                  if (LOG.isDebugEnabled()) {     | 
  
            
  
    | 63 | 
    
           0
    
     | 
    
                                      LOG.debug("---- Related Org Relation: " + nextNodeOrgInfo.getId() + " - " + nextNodeOrgInfo.getShortName() + " (" + nextNodeOrgInfo.getLongName() + ")");     | 
  
            
  
    | 64 | 
    
            
    
     | 
    
                                  }     | 
  
            
  
    | 65 | 
    
           0
    
     | 
    
                                  AttributeSet attributeSet = new AttributeSet();     | 
  
            
  
    | 66 | 
    
           0
    
     | 
    
                                  attributeSet.put(KualiStudentKimAttributes.QUALIFICATION_ORG_ID, nextNodeOrgInfo.getId());     | 
  
            
  
    | 67 | 
    
           0
    
     | 
    
                                  attributeSets.add(attributeSet);     | 
  
            
  
    | 68 | 
    
            
    
     | 
    
                              }     | 
  
            
  
    | 69 | 
    
            
    
     | 
    
                          }     | 
  
            
  
    | 70 | 
    
            
    
     | 
    
                      }     | 
  
            
  
    | 71 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 72 | 
    
            
    
     | 
    
                       | 
  
            
  
    | 73 | 
    
           0
    
     | 
    
                  if (attributeSets.isEmpty()) {     | 
  
            
  
    | 74 | 
    
           0
    
     | 
    
                      OrgInfo currentNodeOrg = getOrganization(orgIdValue);     | 
  
            
  
    | 75 | 
    
           0
    
     | 
    
                      AttributeSet attributeSet = new AttributeSet();     | 
  
            
  
    | 76 | 
    
           0
    
     | 
    
                      attributeSet.put(KualiStudentKimAttributes.QUALIFICATION_ORG_ID, currentNodeOrg.getId());     | 
  
            
  
    | 77 | 
    
           0
    
     | 
    
                      attributeSets.add(attributeSet);     | 
  
            
  
    | 78 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 79 | 
    
           0
    
     | 
    
                  return attributeSets;     | 
  
            
  
    | 80 | 
    
            
    
     | 
    
              } catch (Exception e) {     | 
  
            
  
    | 81 | 
    
           0
    
     | 
    
                  LOG.error("Error getting organization(s) or organization relations", e);     | 
  
            
  
    | 82 | 
    
           0
    
     | 
    
                  throw new RuntimeException(e);     | 
  
            
  
    | 83 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 84 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 85 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 4 (4) | 
           Complexity: 2 | 
           Complexity Density: 0.5 | 
                        
            
        | 
    
  
  
    | 86 | 
    
           0
    
     | 
    
           protected OrgInfo getOrganization(String orgId) throws Exception {...     | 
  
            
  
    | 87 | 
    
           0
    
     | 
    
              try {     | 
  
            
  
    | 88 | 
    
           0
    
     | 
    
                  return getOrganizationService().getOrganization(orgId);     | 
  
            
  
    | 89 | 
    
            
    
     | 
    
              } catch (DoesNotExistException e) {     | 
  
            
  
    | 90 | 
    
           0
    
     | 
    
                  LOG.error("No valid organization found for id '" + orgId + "'", e);     | 
  
            
  
    | 91 | 
    
           0
    
     | 
    
                  throw e;     | 
  
            
  
    | 92 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 93 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 94 | 
    
            
    
     | 
    
           | 
  
            
  
    | 95 | 
    
            
    
     | 
    
      }     |