Project

General

Profile

1
package eu.dnetlib.uoaadmintools.services;
2

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

    
9
import java.util.List;
10

    
11
@Service
12
public class LayoutService {
13
    private final Logger log = Logger.getLogger(this.getClass());
14

    
15
    @Autowired
16
    private LayoutDAO layoutDAO;
17

    
18
    public List<Layout> findAll() {
19
        return this.layoutDAO.findAll();
20
    }
21

    
22
    public void updatePid(String old_pid, String new_pid) {
23
        log.debug("layout service: updatePid");
24
        Layout layout = layoutDAO.findByPortalPid(old_pid);
25
        log.debug("layout service: layout id: "+(layout != null ? layout.getId() : "not found"));
26
        if(layout != null) {
27
            layout.setPortalPid(new_pid);
28
            log.debug("layout layout: new layout pid: " + layout.getPortalPid());
29
            layoutDAO.save(layout);
30
            log.debug("layout saved!");
31
        }
32
    }
33

    
34
    public void deleteByPid(String pid) {
35
        Layout layout = layoutDAO.findByPortalPid(pid);
36
        if(layout != null) {
37
            layoutDAO.delete(layout.getId());
38
        }
39
    }
40

    
41
    public Layout findByPid(String pid) {
42
        return layoutDAO.findByPortalPid(pid);
43
    }
44

    
45
    public Layout save(Layout layout) {
46
        return layoutDAO.save(layout);
47
    }
48
}
(2-2/7)