Commit 979346f1 by Tuomas Riihimäki

Lock and release placeslots

1 parent 54d109ae
...@@ -126,4 +126,8 @@ public interface PlaceBeanLocal { ...@@ -126,4 +126,8 @@ public interface PlaceBeanLocal {
List<PlaceSlot> getPlaceslots(EventUser user); List<PlaceSlot> getPlaceslots(EventUser user);
boolean lockSlot(PlaceSlot row);
boolean releaseSlot(PlaceSlot row);
} }
...@@ -801,4 +801,26 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -801,4 +801,26 @@ public class PlaceBean implements PlaceBeanLocal {
return placeSlotFacade.finForUser(user); return placeSlotFacade.finForUser(user);
} }
@Override
public boolean lockSlot(PlaceSlot row) {
row = placeSlotFacade.reload(row);
if (row.getPlace() == null && row.getUsed() == null) {
row.setUsed(new Date());
}else {
return false;
}
return true;
}
@Override
public boolean releaseSlot(PlaceSlot row) {
row = placeSlotFacade.reload(row);
if (row.getPlace() == null && row.getUsed() != null) {
row.setUsed(null);
}else {
return false;
}
return true;
}
} }
...@@ -89,6 +89,10 @@ ...@@ -89,6 +89,10 @@
<f:param name="billid" value="#{slot.bill.id}" /> <f:param name="billid" value="#{slot.bill.id}" />
</h:link> </h:link>
</p:column> </p:column>
<p:column >
<h:commandButton rendered="#{empty slot.place and empty slot.used}" value="#{i18n['placeslot.lockSlot']}" ajax="false" action="#{placeGroupView.lockSlot}" />
<h:commandButton rendered="#{empty slot.place and not empty slot.used}" value="#{i18n['placeslot.releaseSlot']}" ajax="false" action="#{placeGroupView.releaseSlot}" />
</p:column>
</p:dataTable> </p:dataTable>
</h:form> </h:form>
......
...@@ -78,7 +78,7 @@ public class PlacegroupView extends GenericCDIView { ...@@ -78,7 +78,7 @@ public class PlacegroupView extends GenericCDIView {
private Map<Integer, String> inviteMails = new HashMap<>(); private Map<Integer, String> inviteMails = new HashMap<>();
@EJB @EJB
private PlaceBeanLocal placeslotBean; private PlaceBeanLocal placeslotBean;
private ListDataModel<PlaceSlot> placeslots; private ListDataModel<PlaceSlot> placeslots;
public String editGroup() { public String editGroup() {
...@@ -211,6 +211,20 @@ public class PlacegroupView extends GenericCDIView { ...@@ -211,6 +211,20 @@ public class PlacegroupView extends GenericCDIView {
return null; return null;
} }
public String lockSlot() {
PlaceSlot row = placeslots.getRowData();
placeslotBean.lockSlot(row);
placeslots = null;
return null;
}
public String releaseSlot() {
PlaceSlot row = placeslots.getRowData();
placeslotBean.releaseSlot(row);
placeslots = null;
return null;
}
public ListDataModel<PlaceGroup> getPlacegroups() { public ListDataModel<PlaceGroup> getPlacegroups() {
if (placegroups == null) { if (placegroups == null) {
List<PlaceGroup> retlist = new ArrayList<PlaceGroup>(); List<PlaceGroup> retlist = new ArrayList<PlaceGroup>();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!