34 lines
1.0 KiB
Java
34 lines
1.0 KiB
Java
|
package eu.dnetlib.uoaadmintools.services;
|
||
|
|
||
|
import eu.dnetlib.uoaadmintools.dao.StatisticsDAO;
|
||
|
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics;
|
||
|
import org.apache.log4j.Logger;
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.stereotype.Service;
|
||
|
|
||
|
@Service
|
||
|
public class StatisticsService {
|
||
|
private final Logger log = Logger.getLogger(this.getClass());
|
||
|
|
||
|
@Autowired
|
||
|
private StatisticsDAO statisticsDAO;
|
||
|
|
||
|
public void updatePid(String old_pid, String new_pid) {
|
||
|
Statistics statistics = statisticsDAO.findByPid(old_pid);
|
||
|
statistics.setPid(new_pid);
|
||
|
statisticsDAO.save(statistics);
|
||
|
}
|
||
|
|
||
|
public void createPortalStatistics(String pid) {
|
||
|
Statistics statistics = new Statistics(pid);
|
||
|
statisticsDAO.save(statistics);
|
||
|
}
|
||
|
|
||
|
public void deleteByPid(String pid) {
|
||
|
Statistics stats = statisticsDAO.findByPid(pid);
|
||
|
if(stats != null) {
|
||
|
statisticsDAO.delete(stats.getId());
|
||
|
}
|
||
|
}
|
||
|
}
|