1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.service.impl;
17
18 import org.kuali.rice.kim.api.group.Group;
19 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
20 import org.kuali.rice.krad.bo.AdHocRoutePerson;
21 import org.kuali.rice.krad.bo.AdHocRouteWorkgroup;
22 import org.kuali.rice.krad.document.Document;
23 import org.kuali.rice.krad.service.BusinessObjectService;
24 import org.kuali.rice.krad.service.DocumentAdHocService;
25 import org.kuali.rice.krad.service.KRADServiceLocator;
26
27 import java.util.HashMap;
28 import java.util.List;
29
30
31
32
33
34
35
36 public class DocumentAdHocServiceImpl implements DocumentAdHocService {
37
38
39
40
41 public void addAdHocs(Document document) {
42
43
44
45
46 List<AdHocRoutePerson> adHocRoutePersons;
47 List<AdHocRouteWorkgroup> adHocRouteWorkgroups;
48 HashMap criteriaPerson = new HashMap();
49 HashMap criteriaWorkgroup = new HashMap();
50
51 criteriaPerson.put("documentNumber", document.getDocumentNumber());
52 criteriaPerson.put("type", AdHocRoutePerson.PERSON_TYPE);
53 adHocRoutePersons = (List) getBusinessObjectService().findMatching(AdHocRoutePerson.class, criteriaPerson);
54 criteriaWorkgroup.put("documentNumber", document.getDocumentNumber());
55 criteriaWorkgroup.put("type", AdHocRouteWorkgroup.WORKGROUP_TYPE);
56 adHocRouteWorkgroups = (List) getBusinessObjectService().findMatching(AdHocRouteWorkgroup.class, criteriaWorkgroup);
57
58
59 for (AdHocRouteWorkgroup adHocRouteWorkgroup : adHocRouteWorkgroups) {
60 Group group = KimApiServiceLocator.getGroupService().getGroup(adHocRouteWorkgroup.getId());
61 adHocRouteWorkgroup.setRecipientName(group.getName());
62 adHocRouteWorkgroup.setRecipientNamespaceCode(group.getNamespaceCode());
63 }
64 document.setAdHocRoutePersons(adHocRoutePersons);
65 document.setAdHocRouteWorkgroups(adHocRouteWorkgroups);
66 }
67
68
69
70
71
72 protected BusinessObjectService getBusinessObjectService() {
73 return KRADServiceLocator.getBusinessObjectService();
74 }
75
76 }