PublisherServiceSpring.java
1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package org.legrog.web.publisher;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherRepository;
import org.legrog.entities.PublisherRevision;
import org.legrog.entities.PublisherRevisionRepository;
import javax.ejb.Stateless;
import javax.inject.Inject;
import java.util.List;
import java.util.Set;
@Stateless
public class PublisherServiceSpring implements PublisherService {
@Inject
PublisherRepository publisherRepository;
@Inject
PublisherRevisionRepository publisherRevisionRepository;
public void addPublisherRevision(PublisherRevision publisherRevision) {
publisherRevisionRepository.save(publisherRevision);
}
public List<PublisherRevision> getAllPublisherRevisions() {
return publisherRevisionRepository.findAll();
}
public PublisherRevision getPublisherRevision(Integer publisherRevisionId) {
return publisherRevisionRepository.findOne(publisherRevisionId);
}
public void addPublisher(Publisher publisher) {
publisherRepository.save(publisher);
}
public void updatePublisher(Publisher publisher) {
publisherRepository.save(publisher);
}
public void addRevisionToPublisher(Publisher publisher, PublisherRevision publisherRevision) {
Set<PublisherRevision> publisherRevisionSet = publisher.getRevisions();
publisherRevisionSet.add(publisherRevision);
publisher.setRevisions(publisherRevisionSet);
publisherRevision.setPublisher(publisher);
publisherRepository.save(publisher);
}
public Publisher getPublisher(Integer publisherId) {
return publisherRepository.findOne(publisherId);
}
public List<Publisher> getAllPublishers() {
return publisherRepository.findAll();
}
}