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 | |
import java.util.ArrayList; |
19 | |
import java.util.HashMap; |
20 | |
import java.util.List; |
21 | |
import java.util.Map; |
22 | |
|
23 | |
import org.kuali.rice.kew.doctype.service.DocumentTypeService; |
24 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
25 | |
import org.kuali.rice.kim.bo.impl.KimAttributes; |
26 | |
import org.kuali.rice.kim.bo.role.dto.KimResponsibilityInfo; |
27 | |
import org.kuali.rice.kim.bo.types.dto.AttributeSet; |
28 | |
import org.kuali.rice.kim.service.support.KimResponsibilityTypeService; |
29 | |
import org.kuali.rice.kim.service.support.impl.KimResponsibilityTypeServiceBase; |
30 | |
import org.kuali.rice.kim.util.KimCommonUtils; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public class DocumentTypeResponsibilityTypeServiceImpl extends |
36 | |
KimResponsibilityTypeServiceBase implements KimResponsibilityTypeService { |
37 | |
DocumentTypeService documentTypeService; |
38 | |
protected String exactMatchStringAttributeName; |
39 | |
|
40 | |
{ |
41 | 0 | requiredAttributes.add( KimAttributes.DOCUMENT_TYPE_NAME ); |
42 | 0 | checkRequiredAttributes = true; |
43 | 0 | } |
44 | |
|
45 | |
@Override |
46 | |
protected List<KimResponsibilityInfo> performResponsibilityMatches( |
47 | |
AttributeSet requestedDetails, |
48 | |
List<KimResponsibilityInfo> responsibilitiesList) { |
49 | 0 | Map<String, List<KimResponsibilityInfo>> potentialDocumentTypeMatches = new HashMap<String, List<KimResponsibilityInfo>>(); |
50 | 0 | for (KimResponsibilityInfo responsibility : responsibilitiesList) { |
51 | 0 | if ((exactMatchStringAttributeName == null) |
52 | |
|| responsibility |
53 | |
.getDetails() |
54 | |
.get(exactMatchStringAttributeName) |
55 | |
.equals( |
56 | |
requestedDetails |
57 | |
.get(exactMatchStringAttributeName))) { |
58 | 0 | if (!potentialDocumentTypeMatches.containsKey(responsibility |
59 | |
.getDetails().get(KimAttributes.DOCUMENT_TYPE_NAME))) { |
60 | 0 | potentialDocumentTypeMatches.put( |
61 | |
responsibility.getDetails().get( |
62 | |
KimAttributes.DOCUMENT_TYPE_NAME), |
63 | |
new ArrayList<KimResponsibilityInfo>()); |
64 | |
} |
65 | 0 | potentialDocumentTypeMatches.get( |
66 | |
responsibility.getDetails().get( |
67 | |
KimAttributes.DOCUMENT_TYPE_NAME)).add( |
68 | |
responsibility); |
69 | |
} |
70 | |
} |
71 | 0 | List<KimResponsibilityInfo> matchingResponsibilities = new ArrayList<KimResponsibilityInfo>(); |
72 | 0 | if (potentialDocumentTypeMatches.containsKey(requestedDetails |
73 | |
.get(KimAttributes.DOCUMENT_TYPE_NAME))) { |
74 | 0 | matchingResponsibilities |
75 | |
.addAll(potentialDocumentTypeMatches.get(requestedDetails |
76 | |
.get(KimAttributes.DOCUMENT_TYPE_NAME))); |
77 | |
} else { |
78 | 0 | String closestParentDocumentTypeName = KimCommonUtils.getClosestParentDocumentTypeName( |
79 | |
getDocumentTypeService().findByName( |
80 | |
requestedDetails |
81 | |
.get(KimAttributes.DOCUMENT_TYPE_NAME)), |
82 | |
potentialDocumentTypeMatches.keySet()); |
83 | 0 | if (closestParentDocumentTypeName != null) { |
84 | 0 | matchingResponsibilities.addAll(potentialDocumentTypeMatches |
85 | |
.get(closestParentDocumentTypeName)); |
86 | |
} |
87 | |
} |
88 | 0 | return matchingResponsibilities; |
89 | |
} |
90 | |
|
91 | |
public DocumentTypeService getDocumentTypeService() { |
92 | 0 | if (documentTypeService == null) { |
93 | 0 | documentTypeService = KEWServiceLocator.getDocumentTypeService(); |
94 | |
} |
95 | 0 | return this.documentTypeService; |
96 | |
} |
97 | |
} |