1 |
35288
|
antonis.le
|
package eu.dnetlib.goldoa.service;
|
2 |
|
|
|
3 |
35468
|
antonis.le
|
import eu.dnetlib.goldoa.domain.Publisher;
|
4 |
35288
|
antonis.le
|
import eu.dnetlib.goldoa.domain.Vocabulary;
|
5 |
35468
|
antonis.le
|
import eu.dnetlib.goldoa.service.dao.PersonDAO;
|
6 |
35440
|
antonis.le
|
import eu.dnetlib.goldoa.service.dao.PublisherDAO;
|
7 |
35521
|
antonis.le
|
import org.apache.commons.codec.digest.DigestUtils;
|
8 |
35478
|
antonis.le
|
import org.springframework.beans.factory.annotation.Autowired;
|
9 |
35343
|
antonis.le
|
import org.springframework.transaction.annotation.Transactional;
|
10 |
35288
|
antonis.le
|
|
11 |
|
|
import java.util.List;
|
12 |
|
|
|
13 |
|
|
/**
|
14 |
|
|
* Created by antleb on 3/11/15.
|
15 |
|
|
*/
|
16 |
35343
|
antonis.le
|
@Transactional
|
17 |
35288
|
antonis.le
|
public class PublisherManagerImpl implements PublisherManager, Searchable {
|
18 |
|
|
|
19 |
35478
|
antonis.le
|
@Autowired
|
20 |
35468
|
antonis.le
|
private PublisherDAO publisherDAO;
|
21 |
35478
|
antonis.le
|
@Autowired
|
22 |
35468
|
antonis.le
|
private PersonDAO personDAO;
|
23 |
35288
|
antonis.le
|
|
24 |
|
|
@Override
|
25 |
|
|
public List<Vocabulary> search(String term) {
|
26 |
35440
|
antonis.le
|
return publisherDAO.search(term);
|
27 |
35288
|
antonis.le
|
}
|
28 |
|
|
|
29 |
35468
|
antonis.le
|
@Override
|
30 |
|
|
public Publisher getPublisher(String publisherId) {
|
31 |
|
|
Publisher publisher = publisherDAO.getPublisher(publisherId);
|
32 |
|
|
|
33 |
|
|
if (publisher.getContact() != null)
|
34 |
35749
|
antonis.le
|
publisher.setContact(personDAO.getPersonById(publisher.getContact().getId()));
|
35 |
35468
|
antonis.le
|
|
36 |
|
|
return publisher;
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
@Override
|
40 |
|
|
public Publisher savePublisher(Publisher publisher) {
|
41 |
35521
|
antonis.le
|
|
42 |
|
|
if (publisher.getId() == null) {
|
43 |
|
|
publisher.setId("portal::" + DigestUtils.md5Hex(publisher.getName()));
|
44 |
|
|
publisher.setSource("portal");
|
45 |
|
|
|
46 |
|
|
}
|
47 |
35468
|
antonis.le
|
return publisherDAO.savePublisher(publisher);
|
48 |
|
|
}
|
49 |
35521
|
antonis.le
|
|
50 |
|
|
public PublisherDAO getPublisherDAO() {
|
51 |
|
|
return publisherDAO;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
public void setPublisherDAO(PublisherDAO publisherDAO) {
|
55 |
|
|
this.publisherDAO = publisherDAO;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
35288
|
antonis.le
|
}
|