Commit 923d4f4f by Tuomas Riihimäki

Automatically release slot when place is released by timeout

1 parent a680baac
......@@ -40,6 +40,7 @@ import fi.codecrew.moya.model.EventMap_;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PlaceSlot;
import fi.codecrew.moya.model.Place_;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.Product_;
......@@ -51,7 +52,10 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
private static final Logger logger = LoggerFactory.getLogger(PlaceFacade.class);
@EJB
EventBeanLocal eventBean;
private EventBeanLocal eventBean;
@EJB
private PlaceSlotFacade placeslotfacade;
public PlaceFacade() {
......@@ -74,6 +78,12 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
for (Place p : q.getResultList()) {
logger.debug("Releasing place {} at automagic timed place check.", p);
if (p.checkReleased()) {
PlaceSlot slot = placeslotfacade.findSlotForPlace(p);
if (slot != null) {
slot.setPlace(null);
slot.setUsed(null);
}
++updated;
}
}
......@@ -173,10 +183,6 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
return super.getSingleNullableResult(getEm().createQuery(cq));
}
public Long findCountForProduct(Product product) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
......@@ -190,10 +196,6 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
return super.getSingleNullableResult(getEm().createQuery(cq));
}
public Long countAvailable(EventMap map) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!