package eu.dnetlib.uoaadmintools.services; import eu.dnetlib.uoaadmintools.dao.LayoutDAO; import eu.dnetlib.uoaadmintools.entities.Layout; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service public class LayoutService { private final Logger log = Logger.getLogger(this.getClass()); @Autowired private LayoutDAO layoutDAO; public List findAll() { return this.layoutDAO.findAll(); } public void updatePid(String old_pid, String new_pid) { log.debug("layout service: updatePid"); Layout layout = layoutDAO.findByPortalPid(old_pid); log.debug("layout service: layout id: "+(layout != null ? layout.getId() : "not found")); if(layout != null) { layout.setPortalPid(new_pid); log.debug("layout layout: new layout pid: " + layout.getPortalPid()); layoutDAO.save(layout); log.debug("layout saved!"); } } public void deleteByPid(String pid) { Layout layout = layoutDAO.findByPortalPid(pid); if(layout != null) { layoutDAO.delete(layout.getId()); } } public Layout findByPid(String pid) { return layoutDAO.findByPortalPid(pid); } public Layout save(Layout layout) { return layoutDAO.save(layout); } }