mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
28 lines
659 B
Java
28 lines
659 B
Java
|
|
package com.commafeed.backend.services;
|
||
|
|
|
||
|
|
import javax.ejb.Stateless;
|
||
|
|
import javax.inject.Inject;
|
||
|
|
import javax.persistence.EntityManager;
|
||
|
|
import javax.persistence.PersistenceContext;
|
||
|
|
import javax.persistence.Query;
|
||
|
|
|
||
|
|
@Stateless
|
||
|
|
public class CleaningService {
|
||
|
|
|
||
|
|
@Inject
|
||
|
|
ApplicationSettingsService applicationSettingsService;
|
||
|
|
|
||
|
|
@PersistenceContext
|
||
|
|
EntityManager em;
|
||
|
|
|
||
|
|
// @Schedule(hour = "*")
|
||
|
|
protected void cleanOldStatuses() {
|
||
|
|
int keepStatusDays = applicationSettingsService.get()
|
||
|
|
.getKeepStatusDays();
|
||
|
|
if (keepStatusDays > 0) {
|
||
|
|
Query query = em.createNamedQuery("Statuses.deleteOld");
|
||
|
|
query.executeUpdate();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|