View Javadoc
1   package org.kuali.kpme.edo.workflow.role;
2   
3   import java.util.Collections;
4   import java.util.HashMap;
5   import java.util.List;
6   import java.util.Map;
7   
8   import org.apache.commons.lang.StringUtils;
9   import org.kuali.kpme.edo.permission.EDOKimAttributes;
10  import org.kuali.kpme.edo.service.EdoServiceLocator;
11  import org.kuali.kpme.edo.util.EdoPropertyConstants;
12  import org.kuali.rice.kew.engine.RouteContext;
13  import org.kuali.rice.kns.workflow.attribute.QualifierResolverBase;
14  
15  public class SuppGenericQualifierResolver extends QualifierResolverBase {
16  
17      @Override
18      public List<Map<String, String>> resolve(RouteContext context) {
19          Map<String, String> qualifiers = new HashMap<String, String>();
20  
21          String nodeName = context.getNodeInstance().getName();
22          String documentContent = context.getDocumentContent().getDocContent();
23  
24          String workflowId = StringUtils.substringBetween(documentContent, "<workflowId>","</workflowId");
25  
26          // KPME-3711 This method has been moved to EdoSuppReviewLayerDefinitionService
27          //String qualifier = EdoServiceLocator.getEdoReviewLayerDefinitionService().getSuppLevelQualifierByWorkflowId(workflowId, nodeName);
28          // TODO Get qualifier from EdoReviewLayerDefinition instead
29          String qualifier = EdoServiceLocator.getEdoSuppReviewLayerDefinitionService().getSuppLevelQualifierByWorkflowId(workflowId, nodeName);
30  
31          if (StringUtils.isNotBlank(qualifier)) {
32              if (qualifier.equals(EdoPropertyConstants.EdoSuppReviewLayerDefinitionFields.SCHOOL_ID)) {
33                  String schoolId = StringUtils.substringBetween(documentContent, "<schoolId>", "</schoolId>");
34                  if(StringUtils.isNotBlank(schoolId)) {
35                      qualifiers.put(EDOKimAttributes.EDO_SCHOOL_ID, schoolId);
36                  }
37              }
38              if (qualifier.equals(EdoPropertyConstants.EdoSuppReviewLayerDefinitionFields.DEPARTMENT_ID)) {
39                  String departmentId = StringUtils.substringBetween(documentContent, "<departmentId>", "</departmentId>");
40                  if(StringUtils.isNotBlank(departmentId)) {
41                      qualifiers.put(EDOKimAttributes.EDO_DEPARTMENT_ID, departmentId);
42                  }
43              }
44              if (qualifier.equals(EdoPropertyConstants.EdoSuppReviewLayerDefinitionFields.CAMPUS_ID)) {
45                  String campusId = StringUtils.substringBetween(documentContent, "<campusId>", "</campusId>");
46                  if(StringUtils.isNotBlank(campusId)) {
47                      qualifiers.put(EDOKimAttributes.EDO_CAMPUS_ID, campusId);
48                  }
49              }
50          }
51  
52          return Collections.singletonList(qualifiers);
53      }
54  
55  }