Project

General

Profile

1
package eu.dnetlib.uoaadmintools.services;
2

    
3
import eu.dnetlib.uoaadmintools.dao.PortalSubscribersDAO;
4
import eu.dnetlib.uoaadmintools.entities.subscriber.PortalSubscribers;
5
import org.apache.log4j.Logger;
6
import org.springframework.beans.factory.annotation.Autowired;
7
import org.springframework.stereotype.Service;
8

    
9
@Service
10
public class SubscriberService {
11
    private final Logger log = Logger.getLogger(this.getClass());
12

    
13
    @Autowired
14
    private PortalSubscribersDAO portalSubscribersDAO;
15

    
16
    public void updatePid(String old_pid, String new_pid) {
17
        PortalSubscribers portalSubscribers =  portalSubscribersDAO.findByPid(old_pid);
18
        portalSubscribers.setPid(new_pid);
19
        portalSubscribersDAO.save(portalSubscribers);
20
    }
21

    
22
    public void createPortalSubscribers(String pid) {
23
        PortalSubscribers portalSubscribers =  new PortalSubscribers(pid);
24
        portalSubscribersDAO.save(portalSubscribers);
25
    }
26

    
27
    public void deletePortalSubscribers(String pid) {
28
        PortalSubscribers portalSubscribers = portalSubscribersDAO.findByPid(pid);
29
        if(portalSubscribers != null) {
30
            portalSubscribersDAO.delete(portalSubscribers.getId());
31
        }
32
    }
33
}
(3-3/3)