1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kcb.service.impl;
17
18 import java.util.Collection;
19 import java.util.List;
20
21 import org.kuali.rice.core.api.criteria.QueryByCriteria;
22 import org.kuali.rice.kcb.bo.Message;
23 import org.kuali.rice.kcb.service.MessageService;
24 import org.kuali.rice.krad.data.DataObjectService;
25 import org.kuali.rice.krad.data.PersistenceOption;
26
27 import static org.kuali.rice.core.api.criteria.PredicateFactory.equal;
28
29
30
31
32
33
34
35 public class MessageServiceImpl implements MessageService {
36
37 private DataObjectService dataObjectService;
38
39
40
41 public void deleteMessage(Message message) {
42 dataObjectService.delete(message);
43 }
44
45
46
47
48 public Message getMessage(Long id) {
49 return dataObjectService.find(Message.class, id);
50 }
51
52
53
54
55 public Collection<Message> getAllMessages() {
56 return dataObjectService.findMatching(Message.class, QueryByCriteria.Builder.create().build()).getResults();
57 }
58
59
60
61
62 public Message saveMessage(Message message) {
63 return dataObjectService.save(message);
64 }
65
66
67
68
69 public Message getMessageByOriginId(String originId) {
70 QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
71 criteria.setPredicates(equal(Message.ORIGINID_FIELD, originId));
72 List<Message> messages = dataObjectService.findMatching(Message.class, criteria.build()).getResults();
73
74 if (messages.isEmpty()) {
75 return null;
76 }
77
78 return messages.get(0);
79 }
80
81
82
83
84
85 public void setDataObjectService(DataObjectService dataObjectService) {
86 this.dataObjectService = dataObjectService;
87 }
88 }