1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.service.impl; |
17 | |
|
18 | |
|
19 | |
import org.kuali.rice.kew.doctype.service.DocumentTypeService; |
20 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
21 | |
import org.kuali.rice.kim.api.responsibility.Responsibility; |
22 | |
import org.kuali.rice.kim.impl.responsibility.KimResponsibilityTypeService; |
23 | |
import org.kuali.rice.kim.impl.responsibility.KimResponsibilityTypeServiceBase; |
24 | |
import org.kuali.rice.kim.util.KimConstants; |
25 | |
|
26 | |
import java.util.ArrayList; |
27 | |
import java.util.HashMap; |
28 | |
import java.util.List; |
29 | |
import java.util.Map; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public class DocumentTypeResponsibilityTypeServiceImpl extends |
35 | |
KimResponsibilityTypeServiceBase implements KimResponsibilityTypeService { |
36 | |
DocumentTypeService documentTypeService; |
37 | |
protected String exactMatchStringAttributeName; |
38 | |
|
39 | |
{ |
40 | 0 | requiredAttributes.add( KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME ); |
41 | 0 | checkRequiredAttributes = true; |
42 | 0 | } |
43 | |
|
44 | |
@Override |
45 | |
protected List<Responsibility> performResponsibilityMatches( |
46 | |
Map<String, String> requestedDetails, |
47 | |
List<Responsibility> responsibilitiesList) { |
48 | 0 | Map<String, List<Responsibility>> potentialDocumentTypeMatches = new HashMap<String, List<Responsibility>>(); |
49 | 0 | for (Responsibility responsibility : responsibilitiesList) { |
50 | 0 | if ((exactMatchStringAttributeName == null) |
51 | |
|| responsibility |
52 | |
.getAttributes() |
53 | |
.get(exactMatchStringAttributeName) |
54 | |
.equals( |
55 | |
requestedDetails |
56 | |
.get(exactMatchStringAttributeName))) { |
57 | 0 | if (!potentialDocumentTypeMatches.containsKey(responsibility |
58 | |
.getAttributes().get(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME))) { |
59 | 0 | potentialDocumentTypeMatches.put( |
60 | |
responsibility.getAttributes().get( |
61 | |
KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME), |
62 | |
new ArrayList<Responsibility>()); |
63 | |
} |
64 | 0 | potentialDocumentTypeMatches.get( |
65 | |
responsibility.getAttributes().get( |
66 | |
KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME)).add( |
67 | |
responsibility); |
68 | |
} |
69 | |
} |
70 | 0 | List<Responsibility> matchingResponsibilities = new ArrayList<Responsibility>(); |
71 | 0 | if (potentialDocumentTypeMatches.containsKey(requestedDetails |
72 | |
.get(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME))) { |
73 | 0 | matchingResponsibilities |
74 | |
.addAll(potentialDocumentTypeMatches.get(requestedDetails |
75 | |
.get(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME))); |
76 | |
} else { |
77 | 0 | String closestParentDocumentTypeName = getClosestParentDocumentTypeName( |
78 | |
getDocumentTypeService().findByName( |
79 | |
requestedDetails |
80 | |
.get(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME)), |
81 | |
potentialDocumentTypeMatches.keySet()); |
82 | 0 | if (closestParentDocumentTypeName != null) { |
83 | 0 | matchingResponsibilities.addAll(potentialDocumentTypeMatches |
84 | |
.get(closestParentDocumentTypeName)); |
85 | |
} |
86 | |
} |
87 | 0 | return matchingResponsibilities; |
88 | |
} |
89 | |
|
90 | |
public DocumentTypeService getDocumentTypeService() { |
91 | 0 | if (documentTypeService == null) { |
92 | 0 | documentTypeService = KEWServiceLocator.getDocumentTypeService(); |
93 | |
} |
94 | 0 | return this.documentTypeService; |
95 | |
} |
96 | |
} |