Commit 5aff2beb by Tuomas Riihimäki

Error handling, etc

1 parent 7b83cf06
package fi.codecrew.moya.exceptions;
import fi.codecrew.moya.model.Place;
import javax.ejb.EJBException;
public class PlaceAlreadyTakenException extends EJBException {
public PlaceAlreadyTakenException(Place p) {
super("Place " + (p != null ? p.toString():"") + "already taken");
this.place = p;
}
private final Place place;
public Place getPlace() {
return place;
}
}
/*
* Copyright Codecrew Ry
*
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
/*
* To change this template, choose Tools | Templates
......@@ -49,6 +49,8 @@ import javax.ejb.Stateless;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerService;
import fi.codecrew.moya.exceptions.PlaceAlreadyTakenException;
import fi.codecrew.moya.facade.*;
import fi.codecrew.moya.model.*;
......@@ -66,16 +68,15 @@ import fi.codecrew.moya.exceptions.BortalCatchableException;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
/**
*
* @author tuukka
*/
@Stateless
@LocalBean
@DeclareRoles({
MapPermission.S_BUY_PLACES,
MapPermission.S_MANAGE_MAPS,
MapPermission.S_VIEW,
MapPermission.S_MANAGE_OTHERS,
MapPermission.S_BUY_PLACES,
MapPermission.S_MANAGE_MAPS,
MapPermission.S_VIEW,
MapPermission.S_MANAGE_OTHERS,
})
public class PlaceBean implements PlaceBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(PlaceBean.class);
......@@ -132,11 +133,10 @@ public class PlaceBean implements PlaceBeanLocal {
/**
* Calculate the price of reserved places for the user Optional parameter
* newPlace can be given when the place is added to the price calculations;
*
* <p>
* User parameter can be used to select another user than the currently
* logged in user, but if user does not have enough rights an exception will
* be thrown
*
*/
@RolesAllowed(SpecialPermission.S_USER)
......@@ -156,7 +156,9 @@ public class PlaceBean implements PlaceBeanLocal {
}
/** Use place slots */
/**
* Use place slots
*/
@Deprecated()
private BigDecimal addAndCalcPrice(EventUser user, Place newPlace) {
......@@ -208,11 +210,9 @@ public class PlaceBean implements PlaceBeanLocal {
/**
* Reserve the place for user. This reservation will timeout after a while
* buy() method should be called after this when buying place;
*
* @param place
* place to be reserved
* @param user
* User for whom the place should be reserved.
*
* @param place place to be reserved
* @param user User for whom the place should be reserved.
* @return true when successfull. On any error false.
*/
@Override
......@@ -234,8 +234,7 @@ public class PlaceBean implements PlaceBeanLocal {
boolean canReserve = (price.compareTo(balance) <= 0);
logger.debug("Balance {}, price {}", balance, price);
if (!canReserve && !permbean.hasPermission(MapPermission.MANAGE_OTHERS))
{
if (!canReserve && !permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
logger.debug("Did not have enought credits to reserve place! required {} , got {}", price, balance);
return false;
}
......@@ -268,21 +267,20 @@ public class PlaceBean implements PlaceBeanLocal {
}
@Override
@RolesAllowed({ MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_OTHERS })
@RolesAllowed({MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_OTHERS})
public PlaceGroup buySelectedPlaces(EventUser user) throws BortalCatchableException {
return buyOrReserveSelectedPlaces(user, true);
}
@Override
@RolesAllowed({ MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_OTHERS })
@RolesAllowed({MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_OTHERS})
public PlaceGroup buySelectedPlaces(List<Place> selectedPlaces, EventUser user) throws BortalCatchableException {
return buyOrReserveSelectedPlaces(user, selectedPlaces, true);
}
@Override
@RolesAllowed({ MapPermission.S_MANAGE_OTHERS })
@RolesAllowed({MapPermission.S_MANAGE_OTHERS})
public PlaceGroup reserveSelectedPlaces(EventUser eventuser) throws BortalCatchableException {
return buyOrReserveSelectedPlaces(eventuser, false);
}
......@@ -311,10 +309,10 @@ public class PlaceBean implements PlaceBeanLocal {
List<Place> places = placeFacade.findUsersReservations(event, user);
if(selectedPlaces != null) {
if (selectedPlaces != null) {
List<Place> newPlaces = new ArrayList<>();
for(Place p : selectedPlaces) {
if(!p.isReservedFor(permbean.getCurrentUser()) && p.isTaken())
for (Place p : selectedPlaces) {
if (!p.isReservedFor(permbean.getCurrentUser()) && p.isTaken())
continue;
p = placeFacade.reload(p); // persist teh shit
......@@ -331,12 +329,11 @@ public class PlaceBean implements PlaceBeanLocal {
// Check wether we should reserve places via credit or plcaeslot
boolean placePrepaidcredit = places.get(0).getProduct().getProductFlags().contains(ProductFlag.PREPAID_CREDIT);
// PlaceGroup pg = pgbean.createPlaceGroup(user);
if (placePrepaidcredit && createAccountevents)
{
if (placePrepaidcredit && createAccountevents) {
BigDecimal totalprice = addAndCalcPrice(user, null);
BigDecimal balance = user.getAccountBalance();
if (balance.compareTo(totalprice) < 0 && !permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
logger.info("User {} Could not buy things because account balance {} is too low for purchase {}", new Object[] { user, balance, totalprice });
logger.info("User {} Could not buy things because account balance {} is too low for purchase {}", new Object[]{user, balance, totalprice});
return null;
}
......@@ -353,7 +350,7 @@ public class PlaceBean implements PlaceBeanLocal {
boolean associatedToPlace = isUserMember(user, places.get(0).getProduct());
StringBuilder logSb = new StringBuilder();
logSb.append("User Locked ").append(places.size()).append(" places: ");
for (Place p : places) {
if (!p.isReservedFor(user)) {
......@@ -366,8 +363,7 @@ public class PlaceBean implements PlaceBeanLocal {
logSb.append(p.getName()).append(", ");
GroupMembership gm = buy(p, pg);
if (!associatedToPlace)
{
if (!associatedToPlace) {
logger.info("Associating buyer {} to place {}", user, gm);
associatedToPlace = true;
gm.setUser(user);
......@@ -398,12 +394,10 @@ public class PlaceBean implements PlaceBeanLocal {
// If user is not yet associated to this type of product, find it out...
for (int i = 0; i < quantity.intValue(); ++i)
{
for (int i = 0; i < quantity.intValue(); ++i) {
Place freePlace = null;
if (prod.getProductFlags().contains(ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT))
{
if (prod.getProductFlags().contains(ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT)) {
freePlace = new Place();
freePlace.setProduct(prod);
freePlace.setProvidesRole(prod.getProvides());
......@@ -423,8 +417,7 @@ public class PlaceBean implements PlaceBeanLocal {
}
GroupMembership gm = buy(freePlace, pg);
if (!associatedToPlace)
{
if (!associatedToPlace) {
logger.info("Associating buyer {} to place {}", user, gm);
associatedToPlace = true;
gm.setUser(user);
......@@ -440,8 +433,7 @@ public class PlaceBean implements PlaceBeanLocal {
private static boolean isUserMember(EventUser user, Product prod) {
boolean ret = false;
if (user.getGroupMemberships() != null)
{
if (user.getGroupMemberships() != null) {
for (GroupMembership gm : user.getGroupMemberships()) {
if (gm.getPlaceReservation() != null && prod.equals(gm.getPlaceReservation().getProduct())) {
......@@ -466,8 +458,7 @@ public class PlaceBean implements PlaceBeanLocal {
if (pg.getPlaces() == null) {
pg.setPlaces(new ArrayList<Place>());
}
if (!pg.getPlaces().contains(p))
{
if (!pg.getPlaces().contains(p)) {
pg.getPlaces().add(p);
}
return membership;
......@@ -482,13 +473,12 @@ public class PlaceBean implements PlaceBeanLocal {
/**
* Release reservation from user
*
* @param place
* The place to be released
*
* @param place The place to be released
* @return true when successfull, on any erroro false.
*/
@Override
@RolesAllowed({ MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_OTHERS })
@RolesAllowed({MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_OTHERS})
public boolean releasePlace(Place place) {
place = placeFacade.reload(place);
return releasePlacePriv(place) != null;
......@@ -501,7 +491,7 @@ public class PlaceBean implements PlaceBeanLocal {
* @return true when successfull, on any erroro false.
*/
@Override
@RolesAllowed({ MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_OTHERS })
@RolesAllowed({MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_OTHERS})
public boolean userReleasePlace(Place place) {
place = placeFacade.reload(place);
PlaceSlot s = releasePlacePriv(place);
......@@ -604,12 +594,12 @@ public class PlaceBean implements PlaceBeanLocal {
pdf.setTitle("Place");
float pointInMillim = (25.4f / 72.0f); // 1 point is 1/72 inches. 1 inch
// = 25.4mm
// = 25.4mm
float pagex = width / pointInMillim;
float pagey = height / pointInMillim;
for (Place place : places) {
Page page = new Page(pdf, new float[] { pagex, pagey });
Page page = new Page(pdf, new float[]{pagex, pagey});
// place code
com.pdfjet.Font font = new com.pdfjet.Font(pdf, CoreFont.HELVETICA);
......@@ -618,7 +608,7 @@ public class PlaceBean implements PlaceBeanLocal {
TextLine textLine = new TextLine(font);
textLine.setText(place.getName());
textLine.setPosition(5, 15);
textLine.setColor(new int[] { 0, 0, 0 });
textLine.setColor(new int[]{0, 0, 0});
textLine.drawOn(page);
double currentX = 42;
......@@ -631,7 +621,7 @@ public class PlaceBean implements PlaceBeanLocal {
textLine = new TextLine(font);
textLine.setText(place.getPlaceReserver().getUser().getNick());
textLine.setPosition(currentX, 15);
textLine.setColor(new int[] { 0, 0, 0 });
textLine.setColor(new int[]{0, 0, 0});
textLine.drawOn(page);
}
......@@ -642,7 +632,7 @@ public class PlaceBean implements PlaceBeanLocal {
textLine = new TextLine(font);
textLine.setText(barcodeBean.getPlaceTextCode(place));
textLine.setPosition(currentX, (pagey / 2) + font1);
textLine.setColor(new int[] { 0, 0, 0 });
textLine.setColor(new int[]{0, 0, 0});
textLine.drawOn(page);
}
......@@ -865,11 +855,11 @@ public class PlaceBean implements PlaceBeanLocal {
}
if (!manageOthers && !user.equals(src.getCurrentUser())
&& (src.getGroup() == null || !user.equals(src.getGroup().getCreator()))) {
&& (src.getGroup() == null || !user.equals(src.getGroup().getCreator()))) {
throw new EJBAccessException("Trying to move places for another user without permissions!");
}
if (!dst.isBuyable() || dst.isTaken()) {
throw new EJBException("Place already taken!!");
throw new PlaceAlreadyTakenException(dst);
}
// Store values we want to store to the destination place
......@@ -892,7 +882,7 @@ public class PlaceBean implements PlaceBeanLocal {
dst.setPlaceReserver(gmem);
gmem.setPlaceReservation(dst);
}
dst.setGroup(grp);
if (grp != null) {
grp.getPlaces().add(dst);
......
/*
* Copyright Codecrew Ry
*
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.enums.apps;
......@@ -25,6 +25,7 @@ public enum MapPermission implements IAppPermission {
BUY_PLACES, // ("Reserve and buy places from map"),
VIEW, // ("View maps"),
MANAGE_MAPS,
MOVE_PLACES,
//RELEASE_PLACE, // ("Create and modify maps")
;
......@@ -33,14 +34,15 @@ public enum MapPermission implements IAppPermission {
public static final String S_BUY_PLACES = "MAP/BUY_PLACES";
public static final String S_VIEW = "MAP/VIEW";
public static final String S_MANAGE_MAPS = "MAP/MANAGE_MAPS";
public static final String S_RELEASE_PLACE = "MAP/RELEASE_PLACE";
public static final String S_MOVE_PLACES = "MAP/MOVE_PLACES";
private final String fullName;
private final String key;
private static final String I18N_HEADER = "bortalApplication.map.";
private MapPermission() {
key = I18N_HEADER + name();
fullName = new StringBuilder().append(getParent().toString()).append(DELIMITER).append(toString()).toString();
fullName = getParent().toString() + DELIMITER + this.toString();
}
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:map="http://java.sun.com/jsf/composite/cditools/map"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:map="http://java.sun.com/jsf/composite/cditools/map"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:event type="preRenderView"
listener="#{mapPlacechangeView.initView()}" />
<f:viewParam name="userId" value="#{mapPlacechangeView.userId}"/>
<f:event type="preRenderView" listener="#{mapPlacechangeView.initView()}"/>
</f:metadata>
<ui:define name="content">
<h:outputScript target="head" library="seatjs" name="d3.min.js" />
<h:outputScript target="head" library="seatjs" name="d3-tip.js" />
<h:outputScript target="head" library="seatjs" name="seatmap.js" />
<h:outputStylesheet library="seatjs" name="placemap.css" />
<h:outputScript target="head" library="seatjs" name="d3.min.js"/>
<h:outputScript target="head" library="seatjs" name="d3-tip.js"/>
<h:outputScript target="head" library="seatjs" name="seatmap.js"/>
<h:outputStylesheet library="seatjs" name="placemap.css"/>
<!-- Place slot count -->
<h3>
<h:outputText value="#{i18n['placemove.header']}" />
<h:outputText value="#{i18n['placemove.header']}"/>
</h3>
<p:fragment id="placeselector">
<h:form>
<p:dataTable id="slottable" tableStyle="width: auto;" var="slot"
value="#{mapPlacechangeView.slots}">
value="#{mapPlacechangeView.slots}">
<!-- rowStyleClass="#{mapPlacechangeView.srcPlace.contains(slot.place) ? 'selected' : 'unselected'}" -->
<p:column headerText="#{i18n['placemove.productname']}">
<h:outputText value="#{slot.src.product.name}" />
<h:outputText value="#{slot.src.product.name}"/>
</p:column>
<p:column headerText="#{i18n['placemove.placename']}">
<h:outputText renderer="#{!empty slot.src.place}"
value="#{slot.src.place.name}" />
value="#{slot.src.place.name}"/>
</p:column>
<p:column headerText="#{i18n['placemove.placeuser']}">
<h:outputText rendered="#{!empty slot.src.place.currentUser}"
value="#{slot.src.place.currentUser.wholeNmae}" />
value="#{slot.src.place.currentUser.wholeNmae}"/>
<h:outputText rendered="#{empty slot.src.place.currentUser}"
value="-" />
value="-"/>
</p:column>
<p:column headerText="#{i18n['placemove.dstplace']}">
<div style="padding: 0.3em 0;">
<h:outputText renderer="#{!empty slot.dst}"
value="#{slot.dst.name}" />
value="#{slot.dst.name}"/>
</div>
</p:column>
......@@ -66,11 +64,11 @@
actionListener="#{mapPlacechangeView.selectSlot}"
rendered="#{!slot.isMoving()}"
value="#{i18n['placemove.selectSlotForMove']}"
update="placeselector" />
update="placeselector"/>
<p:commandButton
actionListener="#{mapPlacechangeView.unselectSlot}"
rendered="#{slot.moving}" value="#{i18n['placemove.deselect']}"
update="placeselector" />
update="placeselector"/>
</ui:fragment>
</p:column>
......@@ -78,60 +76,58 @@
</h:form>
<script type="text/javascript">
toggleSuccess = #{mapPlacechangeView.toggleSuccess};
var toggleSuccess = #{mapPlacechangeView.toggleSuccess};
</script>
</p:fragment>
<div style="padding: 1em 0;">
<h:form id="placemove">
<p:commandButton
disabled="#{!mapPlacechangeView.isReadyForCommit()}"
rendered="#{ajaxMapView.canUserBuy()}"
value="#{i18n['placemove.commitMove']}"
action="#{mapPlacechangeView.commitMove()}" ajax="false" />
</h:form>
</div>
<div style="padding: 1em 0;">
<h:form id="placemove">
<p:commandButton
disabled="#{!mapPlacechangeView.isReadyForCommit()}"
rendered="#{ajaxMapView.canUserBuy()}"
value="#{i18n['placemove.commitMove']}"
action="#{mapPlacechangeView.commitMove()}" ajax="false"/>
</h:form>
</div>
</p:fragment>
<svg id="seatmap" style="margin: auto; border: 1px solid black;"
width="#{ajaxMapView.map.width}px"
height="#{ajaxMapView.map.height}px" />
width="#{ajaxMapView.map.width}px"
height="#{ajaxMapView.map.height}px"/>
<h:form>
<p:remoteCommand name="toggleDstPlace"
action="#{mapPlacechangeView.toggleDstPlace()}"
update="placeselector" oncomplete="afterToggle()"></p:remoteCommand>
action="#{mapPlacechangeView.toggleDstPlace()}"
update="placeselector" oncomplete="afterToggle()"/>
</h:form>
<script type="text/javascript">
// <![CDATA[
// <![CDATA[
px = placemap({
element: document.getElementById("seatmap"),
moyaurl: "#{request.contextPath}",
map_id: #{ajaxMapView.map.id},
});
px.toggleaction = function(d){
latestPlace = d;
toggleDstPlace([{name:"placeId", value:d.id} ])
};
function afterToggle(){
if(toggleSuccess){
if(latestPlace.state === "F"){
element: document.getElementById("seatmap"),
moyaurl: "#{request.contextPath}",
map_id: #{ajaxMapView.map.id},
});
px.toggleaction = function (d) {
latestPlace = d;
toggleDstPlace([{name: "placeId", value: d.id}])
};
function afterToggle() {
if (toggleSuccess) {
if (latestPlace.state === "F") {
latestPlace.state = "T";
}else {
} else {
latestPlace.state = "F";
}
px.update_placeobj([latestPlace]);
}
}
// ]]>
px.update_placeobj([latestPlace]);
}
}
// ]]>
</script>
</script>
<map:legend />
<map:legend/>
</ui:define>
</ui:composition>
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<ui:param name="thispage" value="page.place.mygroups" />
<ui:param name="thispage" value="page.place.mygroups"/>
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{userView.initView}" />
<f:viewParam name="userid" value="#{userView.userid}"/>
<f:event type="preRenderView" listener="#{userView.initView}"/>
</f:metadata>
<ui:define name="title">
......@@ -16,57 +18,70 @@
<!-- <users:usertabs tabId="groups" /> -->
</ui:define>
<ui:define name="edittab">
<users:usertabs tabId="groups" />
<users:usertabs tabId="groups"/>
</ui:define>
<ui:define name="content">
<h:outputText rendered="#{empty placeGroupView.groupMemberships}" value="#{i18n['placegroupview.noMemberships']}" />
<h:link outcome="/neomap/moveplaces" value="#{i18n['placegroupview.moveUsersPlaces']}">
<f:param name="userId" value="#{userView.user.user.id}"/>
</h:link>
<h:outputText rendered="#{empty placeGroupView.groupMemberships}"
value="#{i18n['placegroupview.noMemberships']}"/>
<h:form rendered="#{!empty placeGroupView.groupMemberships}" id="placelistform">
<h:dataTable value="#{placeGroupView.groupMemberships}" var="member">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['placegroupview.reservationName']}" />
<h:outputText value="#{i18n['placegroupview.reservationName']}"/>
</f:facet>
<h:link value="#{member.placeReservation.name}" outcome="/place/edit">
<f:param name="placeid" value="#{member.placeReservation.id}" />
<f:param name="placeid" value="#{member.placeReservation.id}"/>
</h:link>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['placegroupview.token']}" />
<h:outputText value="#{i18n['placegroupview.token']}"/>
</f:facet>
<h:outputText rendered="#{empty member.user}" value="#{member.inviteToken}" />
<h:link rendered="#{!empty member.user}" value="#{member.user.firstnames} #{member.user.lastname} (#{member.user.nick})" outcome="/place/adminGroups">
<f:param name="userid" value="#{member.user.user.id}" />
<h:outputText rendered="#{empty member.user}" value="#{member.inviteToken}"/>
<h:link rendered="#{!empty member.user}"
value="#{member.user.firstnames} #{member.user.lastname} (#{member.user.nick})"
outcome="/place/adminGroups">
<f:param name="userid" value="#{member.user.user.id}"/>
</h:link>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['placegroupview.groupCreator']}" />
<h:outputText value="#{i18n['placegroupview.groupCreator']}"/>
</f:facet>
<h:link value="#{member.placeGroup.creator.firstnames} #{member.placeGroup.creator.lastname} (#{member.placeGroup.creator.nick})" outcome="/place/adminGroups">
<f:param name="userid" value="#{member.placeGroup.creator.user.id}" />
<h:link
value="#{member.placeGroup.creator.firstnames} #{member.placeGroup.creator.lastname} (#{member.placeGroup.creator.nick})"
outcome="/place/adminGroups">
<f:param name="userid" value="#{member.placeGroup.creator.user.id}"/>
</h:link>
</h:column>
<h:column>
<h:commandButton rendered="#{placeGroupView.canModifyCurrent and placeGroupView.currentMemberUserNotNull}" action="#{placeGroupView.releasePlace()}"
value="#{i18n['placegroupview.releasePlace']}" />
<h:commandButton
rendered="#{placeGroupView.canModifyCurrent and placeGroupView.currentMemberUserNotNull}"
action="#{placeGroupView.releasePlace()}"
value="#{i18n['placegroupview.releasePlace']}"/>
</h:column>
</h:dataTable>
</h:form>
<p>
<input type="button" onclick="location.replace('#{request.contextPath}/PlaceGroupPdf?eventuserId=#{placeGroupView.user.id}');" value="#{i18n['placegroup.printPdf']}" />
<input type="button"
onclick="location.replace('#{request.contextPath}/PlaceGroupPdf?eventuserId=#{placeGroupView.user.id}');"
value="#{i18n['placegroup.printPdf']}"/>
</p>
<h2>#{i18n['placetoken.pageHeader']}</h2>
<p>#{i18n['placetoken.topText']}</p>
<h:form id="placeTokenForm">
<h:outputLabel value="#{i18n['placetoken.token']}:" />
<h:inputText value="#{tokenView.token}" />
<h:commandButton id="commitbtn" action="#{tokenView.saveToken()}" value="#{i18n['placetoken.commit']}" />
<h:outputLabel value="#{i18n['placetoken.token']}:"/>
<h:inputText value="#{tokenView.token}"/>
<h:commandButton id="commitbtn" action="#{tokenView.saveToken()}" value="#{i18n['placetoken.commit']}"/>
</h:form>
<h2>Place slots</h2>
......@@ -74,38 +89,43 @@
<p:dataTable var="slot" value="#{placeGroupView.placeslots}" id="placeslots">
<p:column headerText="#{i18n['placeslot.id']}">
<h:outputText value="#{slot.id}" />
<h:outputText value="#{slot.id}"/>
</p:column>
<p:column headerText="#{i18n['placeslot.state']}">
<h:outputText value="#{slot.bill.expired ? i18n['placeslot.state.expired'] : ( slot.bill.paid ? i18n['placeslot.state.paid'] : i18n['placeslot.state.notPaid'])}" />
<h:outputText
value="#{slot.bill.expired ? i18n['placeslot.state.expired'] : ( slot.bill.paid ? i18n['placeslot.state.paid'] : i18n['placeslot.state.notPaid'])}"/>
</p:column>
<p:column headerText="#{i18n['placeslot.product']}">
<h:outputText value="#{slot.product.name}" />
<h:outputText value="#{slot.product.name}"/>
</p:column>
<p:column headerText="#{i18n['placeslot.place']}">
<h:link value="#{slot.place.name}" rendered="#{!empty slot.place}" outcome="/place/edit">
<f:param name="placeid" value="#{slot.place.id}" />
<f:param name="placeid" value="#{slot.place.id}"/>
</h:link>
</p:column>
<p:column headerText="#{i18n['placeslot.used']}">
<h:outputText value="#{slot.used}">
<f:convertDateTime timeZone="#{sessionHandler.timezone}" pattern="#{sessionHandler.shortDatetimeFormat}" />
<f:convertDateTime timeZone="#{sessionHandler.timezone}"
pattern="#{sessionHandler.shortDatetimeFormat}"/>
</h:outputText>
</p:column>
<p:column headerText="#{i18n['placeslot.bill']}">
<h:link outcome="/bill/showBill" value="#{i18n['bill.billNumber']}: #{slot.bill.id}">
<f:param name="billid" value="#{slot.bill.id}" />
<f:param name="billid" value="#{slot.bill.id}"/>
</h:link>
</p:column>
<p:column>
<p:commandButton rendered="#{empty slot.place and empty slot.used}" value="#{i18n['placeslot.lockSlot']}" actionListener="#{placeGroupView.lockSlot}" update="placeslots" />
<p:commandButton rendered="#{empty slot.place and not empty slot.used}" value="#{i18n['placeslot.releaseSlot']}" actionListener="#{placeGroupView.releaseSlot}" update="placeslots" />
<p:commandButton rendered="#{empty slot.place and empty slot.used}"
value="#{i18n['placeslot.lockSlot']}"
actionListener="#{placeGroupView.lockSlot}" update="placeslots"/>
<p:commandButton rendered="#{empty slot.place and not empty slot.used}"
value="#{i18n['placeslot.releaseSlot']}"
actionListener="#{placeGroupView.releaseSlot}" update="placeslots"/>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
......
......@@ -57,7 +57,7 @@
<h:outputText value="#{dependency.priority}"/>
</h:column>
<h:column>
<p:commandButton action="#{productView.deleteProductDependency}" value="#{i18n['productDependency.delete']}" update=":dependencies"/>
<p:commandButton action="#{productView.deleteProductDependency}" value="#{i18n['product.dependency.delete']}" update=":dependencies"/>
</h:column>
<!-- Not yet in use.
......
......@@ -11,6 +11,7 @@ import javax.faces.context.FacesContext;
import javax.faces.model.ListDataModel;
import javax.inject.Named;
import fi.codecrew.moya.exceptions.PlaceAlreadyTakenException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -80,18 +81,29 @@ public class MapPlacechangeView extends GenericCDIView {
}
public boolean isReadyForCommit() {
// If anything is not selected for commit, we are not ready..
boolean movingAny = false;
for (MoveContainer mc : moveContainers) {
if (mc.isMoving() && mc.getDst() == null) {
return false;
// If we are moving, but destination is not selected, we are not ready..
if (mc.isMoving()) {
movingAny = true;
if (mc.getDst() == null) {
return false;
}
}
}
return true;
return movingAny;
}
public void initView() {
// If we are overriding user, check permission.
if (getSlots() == null) {
if (super.requirePermissions(
super.hasPermission(MapPermission.MOVE_PLACES) ||
super.hasPermission(MapPermission.MANAGE_MAPS)
) && getSlots() == null) {
if (userId != null && super.requirePermissions(MapPermission.MANAGE_OTHERS)) {
user = userbean.findByUserId(userId, false);
} else if (super.requirePermissions(MapPermission.BUY_PLACES)) {
......@@ -102,7 +114,7 @@ public class MapPlacechangeView extends GenericCDIView {
super.beginConversation();
moveContainers = MoveContainer.init(placebean.getPlaceslots(user));
slots = new ListDataModel<MoveContainer>(moveContainers);
slots = new ListDataModel<>(moveContainers);
}
}
......@@ -115,8 +127,22 @@ public class MapPlacechangeView extends GenericCDIView {
change.put(s.getSrc().getPlace(), s.getDst());
}
}
placebean.movePlaces(change);
try {
placebean.movePlaces(change);
} catch (PlaceAlreadyTakenException pt) {
String placename = "";
if (pt.getPlace() != null) {
placename = pt.getPlace().getName();
for (MoveContainer mv : slots) {
if (pt.getPlace().equals(mv.getDst())) {
mv.setDst(null);
}
}
}
super.addFaceMessage("placemove.alreadyTaken", placename);
return null;
}
// slots = null;
// initView();
return "/place/myGroups?faces_redirect=true";
......
......@@ -1876,11 +1876,16 @@ reservequeue.reservingTimeIsUpAlert=Timeslot for your place reservation has time
mapView.reserveTimeLeft=Time to reserve places
queuemgmt.queueEnabled=Queue is ENABLED
queuemgmt.queueDisabled=Queue is DISABLED (enable from Edit event -page)
product.dependency.add=Add product dependency
product.dependency.create=Create
product.dependency.supporter=Depended product
product.dependency.type=Dependency type
product.dependency.priority=Priority
productDependency.delete=Delete
product.dependency.delete=Delete
product.dependency.multiplier=Multiplier
product.dependency.MAX_SUPPORTED_COUNT=Only up to same number of products can be bought
placemove.alreadyTaken=Moving the places was cancelled because place {0} was already taken.
placegroupview.moveUsersPlaces=Move users places
......@@ -1863,11 +1863,15 @@ reservequeue.reservingTimeIsUpAlert=Sinulle varattu varausauka on kulunut loppuu
mapView.reserveTimeLeft=Aikaa varata paikkasi
queuemgmt.queueEnabled=Varausjono ON k\u00E4yt\u00F6ss\u00E4
queuemgmt.queueDisabled=K\u00E4ytt\u00E4j\u00E4jono EI OLE k\u00E4yt\u00F6ss\u00E4 (ota k\u00E4yttoon tapahtuman tiedot -sivulta)
product.dependency.add=Lis\u00E4\u00E4 tuoteriippuvuus
product.dependency.create=Luo uusi
product.dependency.supporter=Tuote josta on riippuvuus
product.dependency.type=Riippuvuuden tyyppi
product.dependency.priority=Prioriteetti
productDependency.delete=Poista
product.dependency.delete=Poista
product.dependency.multiplier=Kerroin
product.dependency.MAX_SUPPORTED_COUNT=Tuotteita voi ostaa enint\u00E4\u00E4n saman m\u00E4\u00E4r\u00E4n
placemove.alreadyTaken=Paikkojen siirto peruuntui koska paikka {0} oli jo varattu.
placegroupview.moveUsersPlaces=Siirrä käyttäjän paikkoja
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!