Commit a7172bc6 by Tuukka Kivilahti

Merge branch 'master' into barcodefuckup

Conflicts:
	code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
2 parents 1af72970 8a2b16a8
Showing with 971 additions and 127 deletions
...@@ -44,6 +44,7 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -44,6 +44,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { "ALTER TABLE reader_events ADD COLUMN products_id integer REFERENCES products(id) DEFAULT null;"}); dbUpdates.add(new String[] { "ALTER TABLE reader_events ADD COLUMN products_id integer REFERENCES products(id) DEFAULT null;"});
dbUpdates.add(new String[] { "ALTER TABLE reader_events ADD COLUMN type text NOT NULL;"}); dbUpdates.add(new String[] { "ALTER TABLE reader_events ADD COLUMN type text NOT NULL;"});
dbUpdates.add(new String[] { "ALTER TABLE reader_events DROP COLUMN gamepoint;"}); dbUpdates.add(new String[] { "ALTER TABLE reader_events DROP COLUMN gamepoint;"});
} }
@EJB @EJB
......
...@@ -3,18 +3,19 @@ package fi.codecrew.moya.beans; ...@@ -3,18 +3,19 @@ package fi.codecrew.moya.beans;
import javax.annotation.security.DeclareRoles; import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed; import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.EJBAccessException;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.facade.EventFacade; import fi.codecrew.moya.facade.EventFacade;
import fi.codecrew.moya.facade.EventMapFacade; import fi.codecrew.moya.facade.EventMapFacade;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.facade.PlaceFacade;
import fi.codecrew.moya.beans.EventMapBeanLocal;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.model.EventMap; import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Place;
/** /**
* Session Bean implementation class EventMapBean * Session Bean implementation class EventMapBean
...@@ -31,6 +32,9 @@ public class EventMapBean implements EventMapBeanLocal { ...@@ -31,6 +32,9 @@ public class EventMapBean implements EventMapBeanLocal {
@EJB @EJB
private EventFacade eventfacade; private EventFacade eventfacade;
@EJB
private PlaceFacade placefacade;
private static final Logger logger = LoggerFactory.getLogger(EventMapBean.class); private static final Logger logger = LoggerFactory.getLogger(EventMapBean.class);
@Override @Override
...@@ -78,4 +82,39 @@ public class EventMapBean implements EventMapBeanLocal { ...@@ -78,4 +82,39 @@ public class EventMapBean implements EventMapBeanLocal {
return leMap; return leMap;
} }
@Override
@RolesAllowed(MapPermission.S_MANAGE_MAPS)
public void deletePlace(Place place) {
place = placefacade.reload(place);
LanEvent currentEvent = eventbean.getCurrentEvent();
if (!currentEvent.equals(place.getMap().getEvent())) {
throw new EJBAccessException("Deleting placce for wrong event!");
}
}
@Override
@RolesAllowed(MapPermission.S_MANAGE_MAPS)
public Place findPlace(Integer id) {
Place place = placefacade.find(id);
LanEvent currentEvent = eventbean.getCurrentEvent();
if (!currentEvent.equals(place.getMap().getEvent())) {
throw new EJBAccessException("Fetcing place for wrong event!");
}
return place;
}
@Override
@RolesAllowed(MapPermission.S_MANAGE_MAPS)
public Place updatePlace(Place place) {
return placefacade.merge(place);
}
@Override
@RolesAllowed(MapPermission.S_MANAGE_MAPS)
public void createPlace(Place place) {
EventMap map = eventmapfacade.reload(place.getMap());
map.getPlaces().add(place);
place.setMap(map);
}
} }
...@@ -105,12 +105,15 @@ public class MenuBean implements MenuBeanLocal { ...@@ -105,12 +105,15 @@ public class MenuBean implements MenuBeanLocal {
userkauppa.addPage(menuitemfacade.findOrCreate("/shop/createBill"), BillPermission.CREATE_BILL); userkauppa.addPage(menuitemfacade.findOrCreate("/shop/createBill"), BillPermission.CREATE_BILL);
userkauppa.addPage(menuitemfacade.findOrCreate("/foodwave/list"), ShopPermission.SHOP_FOODWAVE); userkauppa.addPage(menuitemfacade.findOrCreate("/foodwave/list"), ShopPermission.SHOP_FOODWAVE);
userkauppa.addPage(menuitemfacade.findOrCreate("/bill/list"), BillPermission.VIEW_OWN); userkauppa.addPage(menuitemfacade.findOrCreate("/bill/list"), BillPermission.VIEW_OWN);
userkauppa.addPage(menuitemfacade.findOrCreate("/bill/edit"), BillPermission.VIEW_OWN).setVisible(false);
userkauppa.addPage(menuitemfacade.findOrCreate("/bill/showBill"), BillPermission.VIEW_OWN).setVisible(false);
userkauppa.addPage(menuitemfacade.findOrCreate("/user/accountEvents"), UserPermission.VIEW_ACCOUNTEVENTS); userkauppa.addPage(menuitemfacade.findOrCreate("/user/accountEvents"), UserPermission.VIEW_ACCOUNTEVENTS);
MenuNavigation userPlaces = usermenu.addPage(null, null); MenuNavigation userPlaces = usermenu.addPage(null, null);
userPlaces.setKey("topnavi.userplaces"); userPlaces.setKey("topnavi.userplaces");
userPlaces.addPage(menuitemfacade.findOrCreate("/place/placemap"), MapPermission.VIEW); userPlaces.addPage(menuitemfacade.findOrCreate("/place/placemap"), MapPermission.VIEW);
userPlaces.addPage(menuitemfacade.findOrCreate("/place/myGroups"), MapPermission.BUY_PLACES); userPlaces.addPage(menuitemfacade.findOrCreate("/place/myGroups"), MapPermission.BUY_PLACES);
userPlaces.addPage(menuitemfacade.findOrCreate("/place/edit"), MapPermission.MANAGE_OTHERS).setVisible(false);
MenuNavigation usercompetitions = usermenu.addPage(null, null); MenuNavigation usercompetitions = usermenu.addPage(null, null);
usercompetitions.setKey("topnavi.competitions"); usercompetitions.setKey("topnavi.competitions");
...@@ -236,6 +239,7 @@ public class MenuBean implements MenuBeanLocal { ...@@ -236,6 +239,7 @@ public class MenuBean implements MenuBeanLocal {
contentnavi.addPage(menuitemfacade.findOrCreate("/pages/list"), ContentPermission.MANAGE_PAGES); contentnavi.addPage(menuitemfacade.findOrCreate("/pages/list"), ContentPermission.MANAGE_PAGES);
contentnavi.addPage(menuitemfacade.findOrCreate("/pages/create"), ContentPermission.MANAGE_PAGES); contentnavi.addPage(menuitemfacade.findOrCreate("/pages/create"), ContentPermission.MANAGE_PAGES);
contentnavi.addPage(menuitemfacade.findOrCreate("/pages/edit"), null).setVisible(false); contentnavi.addPage(menuitemfacade.findOrCreate("/pages/edit"), null).setVisible(false);
contentnavi.addPage(menuitemfacade.findOrCreate("/pages/manage"), null).setVisible(false);
MenuNavigation lognavi = adminevent.addPage(null, null); MenuNavigation lognavi = adminevent.addPage(null, null);
lognavi.setKey("topnavi.log"); lognavi.setKey("topnavi.log");
......
...@@ -182,7 +182,8 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -182,7 +182,8 @@ 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; * Reserve the place for user. This reservation will timeout after a while
* buy() method should be called after this when buying place;
* *
* @param place * @param place
* place to be reserved * place to be reserved
...@@ -196,24 +197,33 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -196,24 +197,33 @@ public class PlaceBean implements PlaceBeanLocal {
place = placeFacade.find(place.getId()); place = placeFacade.find(place.getId());
user = eventUserFacade.find(user.getId()); user = eventUserFacade.find(user.getId());
boolean ret = false; boolean ret = false;
if (place.isBuyable() && !place.isTaken()) {
place.setCurrentUser(user); // when admin click's place, he reserves it -> just ignore it
place.setReleaseTime(Calendar.getInstance()); if (!place.isTaken() || (permbean.hasPermission(MapPermission.MANAGE_OTHERS) && permbean.getCurrentUser().equals(place.getCurrentUser()) )) {
place.getReleaseTime().add(Calendar.MINUTE, RESERVE_MINUTES); if (place.isBuyable() || permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
// Create timeout service to timeout the reserved place in if(!place.isBuyable()) {
// RESERVE_MINUTES place.setBuyable(true);
boolean foundTimeout = false;
for (Timer t : ts.getTimers()) {
if (t.getInfo().equals(PLACE_RESERVE_TIMEOUTER)) {
foundTimeout = true;
} }
place.setCurrentUser(user);
place.setReleaseTime(Calendar.getInstance());
place.getReleaseTime().add(Calendar.MINUTE, RESERVE_MINUTES);
// Create timeout service to timeout the reserved place in
// RESERVE_MINUTES
boolean foundTimeout = false;
for (Timer t : ts.getTimers()) {
if (t.getInfo().equals(PLACE_RESERVE_TIMEOUTER)) {
foundTimeout = true;
}
}
if (!foundTimeout) {
logger.info("Place timeout calculator not started. Starting new.");
ts.createTimer(new Date(), 1000 * 60, PLACE_RESERVE_TIMEOUTER);
}
ret = true;
} }
if (!foundTimeout) {
logger.info("Place timeout calculator not started. Starting new.");
ts.createTimer(new Date(), 1000 * 60, PLACE_RESERVE_TIMEOUTER);
}
ret = true;
} }
return ret; return ret;
} }
......
...@@ -34,20 +34,19 @@ import fi.codecrew.moya.model.LanEventPropertyKey; ...@@ -34,20 +34,19 @@ import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.PlaceGroup; import fi.codecrew.moya.model.PlaceGroup;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
import fi.codecrew.moya.utilities.BarcodeUtils; import fi.codecrew.moya.utilities.BarcodeUtils;
import fi.codecrew.moya.utilities.I18n;
/** /**
* Session Bean implementation class PlaceGroupBean * Session Bean implementation class PlaceGroupBean
*/ */
@Stateless @Stateless
@DeclareRoles({ SpecialPermission.S_USER, MapPermission.S_BUY_PLACES }) @DeclareRoles({ SpecialPermission.S_USER, MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_MAPS })
public class PlaceGroupBean implements PlaceGroupBeanLocal { public class PlaceGroupBean implements PlaceGroupBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(PlaceGroupBean.class); private static final Logger logger = LoggerFactory.getLogger(PlaceGroupBean.class);
private static final int YSTART = 30; private static final int YSTART = 30;
@EJB @EJB
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
@EJB @EJB
private BarcodeBeanLocal barcodeBean; private BarcodeBeanLocal barcodeBean;
...@@ -87,7 +86,7 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -87,7 +86,7 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
// } // }
@Override @Override
@RolesAllowed(SpecialPermission.S_USER) @RolesAllowed({ SpecialPermission.S_USER, MapPermission.S_MANAGE_MAPS })
public List<GroupMembership> getMembershipsAndCreations(EventUser user) { public List<GroupMembership> getMembershipsAndCreations(EventUser user) {
if (user == null) { if (user == null) {
user = permbean.getCurrentUser(); user = permbean.getCurrentUser();
...@@ -99,7 +98,7 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -99,7 +98,7 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
} }
@Override @Override
@RolesAllowed(SpecialPermission.S_USER) @RolesAllowed({ SpecialPermission.S_USER, MapPermission.S_MANAGE_MAPS })
public List<GroupMembership> getMemberships(EventUser user) { public List<GroupMembership> getMemberships(EventUser user) {
if (user == null) { if (user == null) {
user = permbean.getCurrentUser(); user = permbean.getCurrentUser();
...@@ -133,59 +132,57 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -133,59 +132,57 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
} }
@Override @Override
@RolesAllowed(SpecialPermission.S_USER) @RolesAllowed({ SpecialPermission.S_USER, MapPermission.S_MANAGE_MAPS })
public void getGroupMembershipPdf(EventUser usr, OutputStream ostream) { public void getGroupMembershipPdf(EventUser usr, OutputStream ostream) {
List<GroupMembership> memberships = getMembershipsAndCreations(usr); List<GroupMembership> memberships = getMembershipsAndCreations(usr);
LanEventProperty tmpProperty = eventbean.getProperty(LanEventPropertyKey.PLACECODE_FROM_USER); LanEventProperty tmpProperty = eventbean.getProperty(LanEventPropertyKey.PLACECODE_FROM_USER);
boolean placecodeFromUser = false; boolean placecodeFromUser = false;
if (tmpProperty != null && tmpProperty.isBooleanValue()) if (tmpProperty != null && tmpProperty.isBooleanValue())
{ {
placecodeFromUser = true; placecodeFromUser = true;
} }
tmpProperty = eventbean.getProperty(LanEventPropertyKey.PLACECODE_PRINT_ONLY_OWN); tmpProperty = eventbean.getProperty(LanEventPropertyKey.PLACECODE_PRINT_ONLY_OWN);
boolean printOnlyOwn = false; boolean printOnlyOwn = false;
if (tmpProperty != null && tmpProperty.isBooleanValue()) if (tmpProperty != null && tmpProperty.isBooleanValue())
{ {
printOnlyOwn = true; printOnlyOwn = true;
} }
try { try {
PDF pdf = new PDF(ostream); PDF pdf = new PDF(ostream);
Font font = new Font(pdf, CoreFont.TIMES_ROMAN); Font font = new Font(pdf, CoreFont.TIMES_ROMAN);
Font bigfont = new Font(pdf, CoreFont.TIMES_ROMAN); Font bigfont = new Font(pdf, CoreFont.TIMES_ROMAN);
bigfont.setSize(15); bigfont.setSize(15);
Font titlefont = new Font(pdf, CoreFont.TIMES_ROMAN); Font titlefont = new Font(pdf, CoreFont.TIMES_ROMAN);
titlefont.setSize(20); titlefont.setSize(20);
Page page = new Page(pdf, A4.PORTRAIT); Page page = new Page(pdf, A4.PORTRAIT);
int y = YSTART; int y = YSTART;
String titletext = "Lipputositteet"; String titletext = "Lipputositteet";
if(printOnlyOwn || memberships.size() <= 1) { if (printOnlyOwn || memberships.size() <= 1) {
titletext = "Lipputosite"; titletext = "Lipputosite";
} }
TextLine topic = new TextLine(titlefont, titletext); TextLine topic = new TextLine(titlefont, titletext);
topic.setPosition(230, y); topic.setPosition(230, y);
topic.drawOn(page); topic.drawOn(page);
y += 30; y += 30;
for (GroupMembership membership : memberships) { for (GroupMembership membership : memberships) {
if (y > 750) { if (y > 750) {
page = new Page(pdf, A4.PORTRAIT); page = new Page(pdf, A4.PORTRAIT);
y = YSTART; y = YSTART;
} }
if(printOnlyOwn && (membership.getUser() == null || !membership.getUser().equals(usr))) { if (printOnlyOwn && (membership.getUser() == null || !membership.getUser().equals(usr))) {
continue; continue;
} }
...@@ -194,16 +191,16 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -194,16 +191,16 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
// PNGImage(BarcodeBean.getBarcode(membership.getInviteToken())); // PNGImage(BarcodeBean.getBarcode(membership.getInviteToken()));
// logger.debug("Jpeg: " + jpeg.getWidth() + " h. " + // logger.debug("Jpeg: " + jpeg.getWidth() + " h. " +
// jpeg.getHeight()); // jpeg.getHeight());
if(placecodeFromUser) { if (placecodeFromUser) {
if(membership.getUser() != null) { if (membership.getUser() != null) {
Image image = new Image(pdf, barcodeBean.getUserBarcode(membership.getUser()), ImageType.PNG); Image image = new Image(pdf, barcodeBean.getUserBarcode(membership.getUser()), ImageType.PNG);
image.scaleBy(0.8); image.scaleBy(0.8);
image.setPosition(50, y); image.setPosition(50, y);
image.drawOn(page); image.drawOn(page);
} else { } else {
TextLine nouser = new TextLine(bigfont, "EMPTY PLACE" ); TextLine nouser = new TextLine(bigfont, "EMPTY PLACE");
nouser.setPosition(85, y+10); nouser.setPosition(85, y + 10);
nouser.drawOn(page); nouser.drawOn(page);
} }
} else { } else {
...@@ -212,8 +209,6 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -212,8 +209,6 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
image.setPosition(50, y); image.setPosition(50, y);
image.drawOn(page); image.drawOn(page);
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (membership.getPlaceReservation().getName() != null) if (membership.getPlaceReservation().getName() != null)
...@@ -246,24 +241,22 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -246,24 +241,22 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
y += 130; y += 130;
} }
if (y > 750) { if (y > 750) {
page = new Page(pdf, A4.PORTRAIT); page = new Page(pdf, A4.PORTRAIT);
y = YSTART; y = YSTART;
} }
String footertext = "Nämä lipputositteenne tulee olla tulostettuna paperille kun saavutte tapahtumaan."; String footertext = "Nämä lipputositteenne tulee olla tulostettuna paperille kun saavutte tapahtumaan.";
if(printOnlyOwn || memberships.size() <= 1) { if (printOnlyOwn || memberships.size() <= 1) {
footertext = "Tämä henkilökohtainen lipputositteesi tulee olla mukana tulostettuna paperille kun saavut tapahtumaan."; footertext = "Tämä henkilökohtainen lipputositteesi tulee olla mukana tulostettuna paperille kun saavut tapahtumaan.";
} }
TextLine footer = new TextLine(font, footertext); TextLine footer = new TextLine(font, footertext);
footer.setPosition(50, y); footer.setPosition(50, y);
footer.drawOn(page); footer.drawOn(page);
pdf.flush(); pdf.flush();
} catch (Exception e) { } catch (Exception e) {
logger.info("Error getting printing group memberships", e); logger.info("Error getting printing group memberships", e);
...@@ -272,19 +265,20 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -272,19 +265,20 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
} }
@Override @Override
@RolesAllowed(SpecialPermission.S_USER) @RolesAllowed({ SpecialPermission.S_USER, MapPermission.S_MANAGE_MAPS })
public void releaseAndGenerateToken(GroupMembership gmem) { public void releaseAndGenerateToken(GroupMembership gmem) {
gmem = gmemfacade.find(gmem.getId()); gmem = gmemfacade.reload(gmem);
if (!(permbean.getCurrentUser().getId().equals(gmem.getPlaceGroup().getCreator().getId()) || permbean.hasPermission(MapPermission.MANAGE_OTHERS))) { if (!(permbean.getCurrentUser().getId().equals(gmem.getPlaceGroup().getCreator().getId()) || permbean.hasPermission(MapPermission.MANAGE_OTHERS))) {
loggerbean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "User tried to release and generate group membership: " + gmem); loggerbean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "User tried to release and generate group membership: " + gmem);
throw new EJBAccessException("Not enough rights to release token"); throw new EJBAccessException("Not enough rights to release token");
} }
gmem.setUser(null); gmem.setUser(null);
gmem.setInviteToken(gmemfacade.createInviteToken()); gmem.setInviteToken(gmemfacade.createInviteToken());
logger.info("Place released. {} new token {}", gmem.getInviteToken());
} }
@Override @Override
@RolesAllowed(SpecialPermission.S_USER) @RolesAllowed({ SpecialPermission.S_USER, MapPermission.S_MANAGE_MAPS })
public List<PlaceGroup> getPlacegroups(EventUser user) { public List<PlaceGroup> getPlacegroups(EventUser user) {
return pgfacade.find(user); return pgfacade.find(user);
} }
...@@ -299,6 +293,6 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -299,6 +293,6 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
public void markGrouMembershipNotEntered(GroupMembership membership) { public void markGrouMembershipNotEntered(GroupMembership membership) {
membership.setEnteredEvent(null); membership.setEnteredEvent(null);
membership = gmemfacade.merge(membership); membership = gmemfacade.merge(membership);
} }
} }
...@@ -91,7 +91,7 @@ public class ProductBean implements ProductBeanLocal { ...@@ -91,7 +91,7 @@ public class ProductBean implements ProductBeanLocal {
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
@EJB @EJB
private BillLineFacade billLineFacade; private BillLineFacade billLineFacade;
@EJB @EJB
private ProductPBean productPBean; private ProductPBean productPBean;
...@@ -100,7 +100,7 @@ public class ProductBean implements ProductBeanLocal { ...@@ -100,7 +100,7 @@ public class ProductBean implements ProductBeanLocal {
@EJB @EJB
private PlaceBean placebean; private PlaceBean placebean;
@EJB @EJB
private DiscountBean discountBean; private DiscountBean discountBean;
...@@ -174,7 +174,6 @@ public class ProductBean implements ProductBeanLocal { ...@@ -174,7 +174,6 @@ public class ProductBean implements ProductBeanLocal {
ret.put(prod.getId(), lim); ret.put(prod.getId(), lim);
// logger.info("Added product limit {} to {}", lim, prod); // logger.info("Added product limit {} to {}", lim, prod);
} }
System.out.println(ret);
return ret; return ret;
} }
......
...@@ -175,8 +175,13 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -175,8 +175,13 @@ public class ReaderBean implements ReaderBeanLocal {
@Override @Override
public List<ReaderEvent> getReaderEvents(Integer readerId) { public List<ReaderEvent> getReaderEvents(Integer readerId) {
return getReaderEvents(readerId, 20);
}
@Override
public List<ReaderEvent> getReaderEvents(Integer readerId, Integer count) {
Reader reader = readerfacade.find(readerId); Reader reader = readerfacade.find(readerId);
return readerEventFacade.findLastEvents(reader, 20); return readerEventFacade.findLastEvents(reader, count);
} }
@Override @Override
...@@ -271,4 +276,9 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -271,4 +276,9 @@ public class ReaderBean implements ReaderBeanLocal {
return ret; return ret;
} }
@Override
public List<ReaderEvent> getReaderEventsAfterEvent(Integer readerId, Integer eventId) {
Reader reader = getReader(readerId);
return readerEventFacade.findEventsAfterEvent(reader, eventId);
}
} }
...@@ -31,8 +31,26 @@ public class ReaderEventFacade extends IntegerPkGenericFacade<ReaderEvent> { ...@@ -31,8 +31,26 @@ public class ReaderEventFacade extends IntegerPkGenericFacade<ReaderEvent> {
cq.orderBy(cb.desc(root.get(ReaderEvent_.time))); cq.orderBy(cb.desc(root.get(ReaderEvent_.time)));
TypedQuery<ReaderEvent> q = getEm().createQuery(cq); TypedQuery<ReaderEvent> q = getEm().createQuery(cq);
q.setMaxResults(count); if (count > 0) {
q.setMaxResults(count);
}
return q.getResultList(); return q.getResultList();
} }
public List<ReaderEvent> findEventsAfterEvent(Reader reader, Integer eventId) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<ReaderEvent> cq = cb.createQuery(ReaderEvent.class);
Root<ReaderEvent> root = cq.from(ReaderEvent.class);
cq.where(cb.equal(root.get(ReaderEvent_.reader), reader),
cb.gt(root.get(ReaderEvent_.id), eventId));
cq.orderBy(cb.desc(root.get(ReaderEvent_.time)));
TypedQuery<ReaderEvent> q = getEm().createQuery(cq);
return q.getResultList();
}
} }
...@@ -3,6 +3,7 @@ package fi.codecrew.moya.beans; ...@@ -3,6 +3,7 @@ package fi.codecrew.moya.beans;
import javax.ejb.Local; import javax.ejb.Local;
import fi.codecrew.moya.model.EventMap; import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.Place;
@Local @Local
public interface EventMapBeanLocal { public interface EventMapBeanLocal {
...@@ -17,4 +18,12 @@ public interface EventMapBeanLocal { ...@@ -17,4 +18,12 @@ public interface EventMapBeanLocal {
EventMap clearPlaces(EventMap map); EventMap clearPlaces(EventMap map);
void deletePlace(Place place);
Place findPlace(Integer id);
Place updatePlace(Place place);
void createPlace(Place create);
} }
...@@ -42,4 +42,8 @@ public interface ReaderBeanLocal { ...@@ -42,4 +42,8 @@ public interface ReaderBeanLocal {
ReaderEvent checkCode(String readerIdent, String code); ReaderEvent checkCode(String readerIdent, String code);
List<ReaderEvent> getReaderEvents(Integer readerId, Integer count);
List<ReaderEvent> getReaderEventsAfterEvent(Integer readerId, Integer eventId);
} }
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
import java.math.BigDecimal;
import java.sql.Time;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
...@@ -25,9 +27,13 @@ import javax.validation.constraints.NotNull; ...@@ -25,9 +27,13 @@ import javax.validation.constraints.NotNull;
import org.eclipse.persistence.annotations.OptimisticLocking; import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType; import org.eclipse.persistence.annotations.OptimisticLockingType;
import org.eclipse.persistence.annotations.PrivateOwned; import org.eclipse.persistence.annotations.PrivateOwned;
import org.eclipse.persistence.annotations.TimeOfDay;
import org.eclipse.persistence.jpa.jpql.parser.DateTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.sun.xml.ws.commons.xmlutil.Converter;
import fi.codecrew.moya.enums.Gender; import fi.codecrew.moya.enums.Gender;
import fi.codecrew.moya.utilities.PasswordFunctions; import fi.codecrew.moya.utilities.PasswordFunctions;
...@@ -366,5 +372,41 @@ public class User extends GenericEntity implements IUser { ...@@ -366,5 +372,41 @@ public class User extends GenericEntity implements IUser {
public void setLicenseCodes(List<LicenseCode> codes) { public void setLicenseCodes(List<LicenseCode> codes) {
this.licenseCodes = codes; this.licenseCodes = codes;
} }
public BigDecimal getAge() {
BigDecimal age = new BigDecimal(0);
if(birthday != null) {
Calendar calBirthday = Calendar.getInstance();
calBirthday.setTime(birthday);
Calendar calNow = Calendar.getInstance();
int yearB = calBirthday.get(Calendar.YEAR);
int yearNow = calNow.get(Calendar.YEAR);
int years = yearNow - yearB -1;
int dayOfYearBirthDay = calBirthday.get(Calendar.DAY_OF_YEAR);
int dayOfYear = calNow.get(Calendar.DAY_OF_YEAR);
int days = 0;
if(dayOfYearBirthDay > dayOfYear) {
calBirthday.set(Calendar.YEAR, yearNow - 1);
days = 365 - calBirthday.get(Calendar.DAY_OF_YEAR) + dayOfYear;
} else {
days = dayOfYear - dayOfYearBirthDay;
}
BigDecimal decimalYears = new BigDecimal(years);
float fraction = (float)((float)days/(float)365);
BigDecimal decimalDays = new BigDecimal(fraction);
age = age.add(decimalYears);
age = age.add(decimalDays);
System.out.print("Years: " + years + "\n");
System.out.print("Days: " + days + "\n");
System.out.print("Fraction of days: " + fraction + "\n");
}
return age;
}
} }
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<f:event type="preRenderView" listener="#{sitePageView.initManage}" /> <f:event type="preRenderView" listener="#{sitePageView.initManage}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<pages:edit commitaction="#{sitePageView.saveSite()}" commitvalue="#{i18n['sitepage.save']}" /> <pages:edit commitaction="#{sitePageView.saveSite()}" commitvalue="#{i18n['sitepage.save']}" />
</ui:define> </ui:define>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "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" <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:map="http://java.sun.com/jsf/composite/cditools/map" xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/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">
<h:body> <h:body>
......
...@@ -100,6 +100,12 @@ ...@@ -100,6 +100,12 @@
<h:outputText value="#{user.firstnames}" /> <h:outputText value="#{user.firstnames}" />
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header">
<h:outputText value="#{i18n['user.lastName']}" />
</f:facet>
<h:outputText value="#{user.lastname}"/>
</h:column>
<h:column>
<h:commandButton action="#{placeView.reserveForUser()}" value="#{i18n['place.reserveForUser']}" /> <h:commandButton action="#{placeView.reserveForUser()}" value="#{i18n['place.reserveForUser']}" />
</h:column> </h:column>
</h:dataTable> </h:dataTable>
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
</f:facet> </f:facet>
<h:outputText value="#{bill.billNumber}" /> <h:outputText value="#{bill.billNumber}" />
</p:column> </p:column>
<p:column> <p:column rendered="#{billListView.canWriteBill}">
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['bill.referencenumber']}" /> <h:outputText value="${i18n['bill.referencenumber']}" />
</f:facet> </f:facet>
...@@ -88,6 +88,9 @@ ...@@ -88,6 +88,9 @@
</h:commandButton> </h:commandButton>
<h:outputText rendered="#{bill.paidDate != null}" value="#{i18n['bill.isPaid']}" /> <h:outputText rendered="#{bill.paidDate != null}" value="#{i18n['bill.isPaid']}" />
</p:column> </p:column>
<p:column rendered="#{!billListView.canWriteBill}">
<h:outputText rendered="#{bill.paidDate != null}" value="#{i18n['bill.isPaid']}" />
</p:column>
</p:dataTable> </p:dataTable>
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
</h:panelGrid> </h:panelGrid>
<p:editor value="#{cont.content}" /> <p:editor value="#{cont.content}" height="800" />
</div> </div>
</ui:repeat> </ui:repeat>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<p:overlayPanel id="chartPanel" for="webcamButton" hideEffect="fade"> <p:overlayPanel id="chartPanel" for="webcamButton" hideEffect="fade">
<p:photoCam widgetVar="pc" listener="#{userView.oncapture}" update="@all" /> <p:photoCam widgetVar="pc" listener="#{userView.oncapture}" update="@all" />
<p:commandButton type="button" value="Capture" onclick="PF('pc').capture()" onerror="location.reload(true);" /> <p:commandButton type="button" value="Capture" onclick="PF('pc').capture()" onerror="location.reload(true);" />
</p:overlayPanel> </p:overlayPanel>
...@@ -112,8 +112,21 @@ ...@@ -112,8 +112,21 @@
<br /> <br />
<p:commandButton ajax="false" rendered="#{cc.attrs.creating or userView.canSave}" id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" onerror="location.reload(true);"/> <p:commandButton ajax="false" rendered="#{cc.attrs.creating or userView.canSave}" id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" onerror="location.reload(true);" />
<br />
<br />
<p:lightBox iframe="true">
<h:outputLink value="http://codecrew.fi/rekisteriseloste.html" title="#{i18n['registerleaflet.title']}">
<h:outputText value="Rekisteriseloste" />
</h:outputLink>
</p:lightBox>
<br />
</h:panelGroup> </h:panelGroup>
</h:panelGrid> </h:panelGrid>
......
...@@ -86,59 +86,90 @@ ...@@ -86,59 +86,90 @@
<table> <table>
<ui:fragment rendered="#{!cc.attrs.creating}"> <ui:fragment rendered="#{!cc.attrs.creating}">
<tr> <tr>
<td colspan="2"><h:outputLabel for="login" value="#{i18n['user.login']}" /><br /> <h:outputText value="#{userView.selectedUser.login}" id="login" /></td> <td colspan="2"><b><h:outputLabel for="login" value="#{i18n['user.login']}" /></b><br />
<h:outputText value="#{userView.selectedUser.login}" id="login" />
</td>
</tr> </tr>
</ui:fragment> </ui:fragment>
<tr> <tr>
<td colspan="2"><h:outputLabel value="#{i18n['user.nick']}" for="nick" /> <br /> <p:inplace emptyLabel="#{i18n['user.insert']}"> <td colspan="2"><b><h:outputLabel value="#{i18n['user.nick']}" for="nick" /> </b><br />
<p:inputText size="45" id="nick" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.nick}" /> <p:inplace emptyLabel="#{i18n['user.insert']}">
</p:inplace></td> <p:inputText size="45" id="nick" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.nick}" />
</p:inplace>
</td>
</tr> </tr>
<tr> <tr>
<td><h:outputLabel value="#{i18n['user.firstNames']}" for="firstnames" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}"> <td><b><h:outputLabel value="#{i18n['user.firstNames']}" for="firstnames" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText size="22" id="firstnames" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.firstnames}" /> <p:inputText size="22" id="firstnames" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.firstnames}" />
</p:inplace></td> </p:inplace>
<td><h:outputLabel value="#{i18n['user.lastName']}" for="lastname" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}"> </td>
<td><b><h:outputLabel value="#{i18n['user.lastName']}" for="lastname" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText size="30" id="lastname" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.lastname}" /> <p:inputText size="30" id="lastname" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.lastname}" />
</p:inplace></td> </p:inplace>
</td>
</tr> </tr>
<tr> <tr>
<td><h:outputLabel for="birthday" value="#{i18n['user.birthday']}" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}"> <td colspan="2"><b><h:outputLabel value="#{i18n['user.sex']}" for="sex" /></b> <br />
<p:calendar id="birthday" navigator="true" yearRange="c-80:c-0" value="#{userView.selectedUser.birthday}"> <p:selectOneMenu disabled="#{!cc.attrs.creating and !userView.canSave}" id="sex" value="#{userView.selectedUser.gender}">
<f:convertDateTime pattern="#{sessionHandler.dateFormat}" timeZone="#{sessionHandler.timezone}" />
</p:calendar>
</p:inplace> <h:message for="birthday" /></td>
<td><h:outputLabel value="#{i18n['user.sex']}" for="sex" /> <br /> <p:selectOneMenu disabled="#{!cc.attrs.creating and !userView.canSave}" id="sex" value="#{userView.selectedUser.gender}">
<f:selectItem id="undefined" itemLabel="#{i18n['user.sex.UNDEFINED']}" itemValue="UNDEFINED" /> <f:selectItem id="undefined" itemLabel="#{i18n['user.sex.UNDEFINED']}" itemValue="UNDEFINED" />
<f:selectItem id="male" itemLabel="#{i18n['user.sex.MALE']}" itemValue="MALE" /> <f:selectItem id="male" itemLabel="#{i18n['user.sex.MALE']}" itemValue="MALE" />
<f:selectItem id="female" itemLabel="#{i18n['user.sex.FEMALE']}" itemValue="FEMALE" /> <f:selectItem id="female" itemLabel="#{i18n['user.sex.FEMALE']}" itemValue="FEMALE" />
</p:selectOneMenu></td> </p:selectOneMenu>
</td>
</tr>
<tr>
<td><b><h:outputLabel for="birthday" value="#{i18n['user.birthday']}" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:calendar id="birthday" navigator="true" yearRange="c-80:c-0" value="#{userView.selectedUser.birthday}">
<f:convertDateTime pattern="#{sessionHandler.dateFormat}" timeZone="#{sessionHandler.timezone}" />
</p:calendar>
</p:inplace> <h:message for="birthday" />
</td>
<td><b><h:outputLabel for="age" value="#{i18n['user.age']}" /></b><br />
<h:outputText value="#{userView.selectedUser.user.age}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
</h:outputText>
</td>
</tr> </tr>
</table> </table>
<table> <table>
<tr> <tr>
<td colspan="2"><p:outputLabel value="#{i18n['user.address']}" for="address" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}"> <td colspan="2"><b><p:outputLabel value="#{i18n['user.address']}" for="address" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText size="45" id="address" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.address}" /> <p:inputText size="45" id="address" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.address}" />
</p:inplace></td> </p:inplace>
</td>
</tr> </tr>
<tr> <tr>
<td><p:outputLabel value="#{i18n['user.zipCode']}" for="zip" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}"> <td><b><p:outputLabel value="#{i18n['user.zipCode']}" for="zip" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText styleClass="ui-input" size="7" id="zip" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.zip}" /> <p:inputText styleClass="ui-input" size="7" id="zip" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.zip}" />
</p:inplace> <p:message for="zip" /></td> </p:inplace> <p:message for="zip" />
<td><p:outputLabel value="#{i18n['user.town']}" for="town" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}"> </td>
<td><b><p:outputLabel value="#{i18n['user.town']}" for="town" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText styleClass="ui-input" size="25" id="town" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.town}" /> <p:inputText styleClass="ui-input" size="25" id="town" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.town}" />
</p:inplace> <p:message for="town" /></td> </p:inplace> <p:message for="town" />
</td>
</tr> </tr>
<tr> <tr>
<td colspan="2"><h:outputLabel value="#{i18n['user.email']}" for="email" /> <br /> <p:inplace emptyLabel="#{i18n['user.insert']}"> <td colspan="2"><b><h:outputLabel value="#{i18n['user.email']}" for="email" /></b> <br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText validator="#{userValidator.validateEmail}" size="45" id="email" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.email}" /> <p:inputText validator="#{userValidator.validateEmail}" size="45" id="email" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.email}" />
</p:inplace></td> </p:inplace>
</td>
</tr> </tr>
<tr> <tr>
<td><p:outputLabel value="#{i18n['user.phone']}" for="phone" /><br /> <p:inplace emptyLabel="#{i18n['user.insert']}"> <td><b><p:outputLabel value="#{i18n['user.phone']}" for="phone" /></b><br />
<p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText styleClass="ui-input" size="7" id="phone" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.phone}" /> <p:inputText styleClass="ui-input" size="7" id="phone" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.phone}" />
</p:inplace> <p:message for="phone" /></td> </p:inplace> <p:message for="phone" />
</td>
</tr> </tr>
</table> </table>
......
...@@ -103,15 +103,16 @@ ...@@ -103,15 +103,16 @@
<nav> <nav>
<div id="menu"> <div id="menu">
<p:panelMenu model="#{primeMenuView.menuModel}" /> <p:panelMenu model="#{primeMenuView.menuModel}" />
<h:link style="font-size: 10px;" rendered="#{readerView.shopToOthers}" outcome="/shop/showReaderEvents" value="Readers" /> <h:link style="font-size: 10px;" rendered="#{readerView.shopToOthers}" outcome="/shop/showReaderEvents" value="Readers" />
</div> </div>
</nav> </nav>
<section id="main" class="flex2"> <section id="main" class="flex2">
<div class="container top"> <div class="container top">
<h:form id="selectLanguage"> <h:form id="selectLanguage">
<p:selectOneButton id="langselect" styleClass="languageSelector" value="#{sessionStore.locale}" onchange="this.form.submit()" converter="#{localeConverter}"> <p:selectOneButton id="langselect" styleClass="languageSelector" value="#{sessionStore.locale}" immediate="true" converter="#{localeConverter}">
<f:selectItems value="#{localeSelectorView.availableLocales}" var="loc" itemValue="#{loc.locale}" itemLabel="#{loc.locale.displayName}" /> <f:selectItems value="#{localeSelectorView.availableLocales}" var="loc" itemValue="#{loc.locale}" itemLabel="#{loc.locale.displayName}" />
<p:ajax update="@all" event="change" />
</p:selectOneButton> </p:selectOneButton>
</h:form> </h:form>
......
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "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" <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:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui">
xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body> <h:body>
<ui:composition template="#{sessionHandler.template}"> <ui:composition template="#{sessionHandler.template}">
<f:metadata> <f:metadata>
<f:event type="preRenderView" listener="#{userView.initCreateView}" /> <f:event type="preRenderView" listener="#{userView.initCreateView}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<users:create creating="true" commitaction="#{userView.createUser()}" commitvalue="#{i18n['user.create']}" /> <users:create creating="true" commitaction="#{userView.createUser()}" commitvalue="#{i18n['user.create']}" />
</ui:define> </ui:define>
</ui:composition> </ui:composition>
......
...@@ -156,7 +156,8 @@ global.notauthorized = You don't have enough rights to enter this site. ...@@ -156,7 +156,8 @@ global.notauthorized = You don't have enough rights to enter this site.
global.save = Save global.save = Save
httpsession.creationTime = Created httpsession.creationTime = Created
incomingflow.giveplace = Merkitse annetuksi
incomingflow.giveplace = Merkitse annetuksi
lanEventPrivateProperty.defaultValue = Default value lanEventPrivateProperty.defaultValue = Default value
lanEventPrivateProperty.editProperty = Edit property lanEventPrivateProperty.editProperty = Edit property
...@@ -220,6 +221,8 @@ productshop.minusTen = -10 ...@@ -220,6 +221,8 @@ productshop.minusTen = -10
productshop.plusOne = +1 productshop.plusOne = +1
productshop.plusTen = +10 productshop.plusTen = +10
registerleaflet.title = Rekisteriseloste
resetMail.header = Reset lost password resetMail.header = Reset lost password
resetMail.username = Username resetMail.username = Username
......
...@@ -799,6 +799,8 @@ readerevent.tagname = Tag ...@@ -799,6 +799,8 @@ readerevent.tagname = Tag
readerview.cards = Card ( printcount ) readerview.cards = Card ( printcount )
registerleaflet.title = Register leaflet
resetMail.body = You can change a forgotten password by inserting your username or email address to the field below. A link where you can change the password will be sent to the email address associated to that. resetMail.body = You can change a forgotten password by inserting your username or email address to the field below. A link where you can change the password will be sent to the email address associated to that.
resetMail.email = Email address resetMail.email = Email address
resetMail.header = Reset lost password resetMail.header = Reset lost password
...@@ -1151,6 +1153,7 @@ user.accountBalance = Account balance ...@@ -1151,6 +1153,7 @@ user.accountBalance = Account balance
user.accountEventHeader = Account events user.accountEventHeader = Account events
user.accountevents = Account events user.accountevents = Account events
user.address = Address user.address = Address
user.age = Age
user.bank = Bank user.bank = Bank
user.bankaccount = Bank number user.bankaccount = Bank number
user.birthday = Birthday user.birthday = Birthday
......
...@@ -785,6 +785,8 @@ readerevent.tagname = Tagi ...@@ -785,6 +785,8 @@ readerevent.tagname = Tagi
readerview.cards = Kortit ( tulostuslkm ) readerview.cards = Kortit ( tulostuslkm )
registerleaflet.title = Rekisteriseloste
resetMail.body = Voit vaihtaa unohtuneen salasanan sy\u00F6tt\u00E4m\u00E4ll\u00E4 k\u00E4ytt\u00E4j\u00E4tunnuksesi tai tunnukseen liitetyn s\u00E4hk\u00F6postiosoitteen allaolevaan kentt\u00E4\u00E4n. Tunnukseen liitettyyn s\u00E4hk\u00F6postiosoitteeseen l\u00E4hetet\u00E4\u00E4n kertak\u00E4ytt\u00F6inen osoite jossa voit vaihtaa sy\u00F6tt\u00E4m\u00E4si k\u00E4ytt\u00E4j\u00E4tunnuksen salasanan. resetMail.body = Voit vaihtaa unohtuneen salasanan sy\u00F6tt\u00E4m\u00E4ll\u00E4 k\u00E4ytt\u00E4j\u00E4tunnuksesi tai tunnukseen liitetyn s\u00E4hk\u00F6postiosoitteen allaolevaan kentt\u00E4\u00E4n. Tunnukseen liitettyyn s\u00E4hk\u00F6postiosoitteeseen l\u00E4hetet\u00E4\u00E4n kertak\u00E4ytt\u00F6inen osoite jossa voit vaihtaa sy\u00F6tt\u00E4m\u00E4si k\u00E4ytt\u00E4j\u00E4tunnuksen salasanan.
resetMail.email = S\u00E4hk\u00F6postiosoite resetMail.email = S\u00E4hk\u00F6postiosoite
resetMail.header = Salasana unohtunut? resetMail.header = Salasana unohtunut?
...@@ -1136,9 +1138,10 @@ user.accountBalance = Tilin saldo ...@@ -1136,9 +1138,10 @@ user.accountBalance = Tilin saldo
user.accountEventHeader = Tilitapahtumat user.accountEventHeader = Tilitapahtumat
user.accountevents = Tilitapahtumat user.accountevents = Tilitapahtumat
user.address = Osoite user.address = Osoite
user.age = Ik
user.bank = Pankki user.bank = Pankki
user.bankaccount = Pankkitili user.bankaccount = Pankkitili
user.birthday = Syntym\u00E4p\u00E4iv\u00E4 user.birthday = Syntym\u00E4aika
user.cardPower = K\u00E4ytt\u00E4j\u00E4tyyppi user.cardPower = K\u00E4ytt\u00E4j\u00E4tyyppi
user.changePassword = Vaihda salasana user.changePassword = Vaihda salasana
user.changepassword.forUser = K\u00E4ytt\u00E4j\u00E4lle user.changepassword.forUser = K\u00E4ytt\u00E4j\u00E4lle
......
...@@ -36,7 +36,7 @@ public class AccountEventRestView { ...@@ -36,7 +36,7 @@ public class AccountEventRestView {
private ProductBeanLocal productBean; private ProductBeanLocal productBean;
@GET @GET
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" })
@Path("/boughtTimecount/{productId}") @Path("/boughtTimecount/{productId}")
public ArrayList<HcSeriesRoot> boughtTimecount(@PathParam("productId") Integer productId) { public ArrayList<HcSeriesRoot> boughtTimecount(@PathParam("productId") Integer productId) {
......
package fi.codecrew.moya.rest;
import java.io.ByteArrayInputStream;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.EventMapBeanLocal;
import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.PlaceGroupBeanLocal;
import fi.codecrew.moya.beans.PlaceMapBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.exceptions.BortalCatchableException;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.rest.pojo.MapRoot;
import fi.codecrew.moya.rest.pojo.PlaceInputPojo;
import fi.codecrew.moya.rest.pojo.PlaceOutPojo;
import fi.codecrew.moya.rest.pojo.PlaceRoot;
@RequestScoped
@Path("/placeadmin")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON })
public class MapAdminView {
@EJB
private EventMapBeanLocal eventmapbean;
@EJB
private PlaceMapBeanLocal placemapbean;
@EJB
private PlaceGroupBeanLocal pgbean;
@EJB
private EventBeanLocal eventbean;
@EJB
private ProductBeanLocal productbean;
@EJB
private UserBeanLocal eventuserbean;
@EJB
private transient PlaceBeanLocal placebean;
private static final Logger logger = LoggerFactory.getLogger(MapAdminView.class);
@GET
@Path("/background/{mapId}")
public Response getMapBg(@PathParam("mapId") Integer mapid)
{
EventMap map = placemapbean.findMap(mapid);
ByteArrayInputStream istream = new ByteArrayInputStream(map.getMapData());
return Response.ok().entity(istream).type("image/jpeg").build();
}
@GET
@Path("/maps")
public MapRoot getAllMaps() {
MapRoot ret = MapRoot.parseMaps(eventbean.getCurrentEvent().getEventMaps());
logger.info("getallmaps called! {}", ret);
return ret;
}
@GET
@Path("/places/{mapId}")
public PlaceRoot getPlaces(@PathParam("mapId") Integer mapid) {
EventMap map = placemapbean.findMap(mapid);
PlaceRoot ret = new PlaceRoot(map);
logger.info("returning map {} entity {}", mapid, ret);
return ret;
}
@DELETE
@Path("/place/{id}")
public Response deletePlace(@PathParam("id") Integer id) {
Place place = eventmapbean.findPlace(id);
eventmapbean.deletePlace(place);
return Response.ok().build();
}
@POST
@Path("/place/")
public Response createPlace(PlaceInputPojo create) {
logger.info("Finding map with id {}", create.getMapId());
EventMap map = eventmapbean.find(create.getMapId());
if (map == null) {
logger.warn("No map found!");
return Response.serverError().entity("Error with mapId").build();
}
Place place = new Place();
place.setMap(map);
setPlaceValues(place, create);
if (create.getProductId() != null && (place.getProduct() == null || !place.getProduct().getId().equals(create.getProductId())))
return Response.serverError().entity("Product id unknown!").build();
logger.info("Creating new place {}", place.getName());
eventmapbean.createPlace(place);
return Response.ok().entity(new PlaceOutPojo(place)).build();
}
@PUT
@Path("/place/{id}")
public Response updatePlace(@PathParam("id") Integer id, PlaceInputPojo update) {
if (update == null || id == null) {
return Response.serverError().entity("'id' field is required!").build();
}
Place place = eventmapbean.findPlace(id);
if (place == null) {
return Response.serverError().entity("place not found with id: " + id).build();
}
setPlaceValues(place, update);
if (update.getProductId() != null && (place.getProduct() == null || !place.getProduct().getId().equals(update.getProductId())))
return Response.serverError().entity("Product id unknown!").build();
place = eventmapbean.updatePlace(place);
return Response.ok(new PlaceOutPojo(place)).build();
}
@PUT
@Path("/place/{placeId}/release")
public Response releasePlace(@PathParam("placeId") Integer placeId) {
Place place = eventmapbean.findPlace(placeId);
if (place == null) {
return Response.serverError().entity("Place not found!").build();
}
logger.info("Releasing place {}", place);
placebean.unbuyPlace(place);
return Response.ok().build();
}
@PUT
@Path("/place/{placeId}/reserve/{eventuserId}")
public Response reserve(@PathParam("placeId") Integer placeId, @PathParam("eventuserId") Integer eventuserId) {
Place place = eventmapbean.findPlace(placeId);
EventUser eventuser = eventuserbean.findByEventUserId(eventuserId);
if (placebean.reservePlace(place, eventuser))
{
try {
placebean.buySelectedPlaces(eventuser);
return Response.ok().build();
} catch (BortalCatchableException e) {
logger.warn("Wtf! Bortalerror");
}
}
return Response.serverError().build();
}
private void setPlaceValues(Place place, PlaceInputPojo update) {
if (update.getName() != null)
place.setName(update.getName());
if (update.getMapX() != null)
place.setMapX(update.getMapX());
if (update.getMapY() != null)
place.setMapY(update.getMapY());
if (update.getWidth() != null)
place.setWidth(update.getWidth());
if (update.getHeight() != null)
place.setHeight(update.getHeight());
if (update.getBuyable() != null)
place.setBuyable(update.getBuyable());
if (update.getDisabled() != null)
place.setDisabled(update.getDisabled());
if (update.getProductId() != null) {
Product product = productbean.findById(update.getProductId());
if (product != null) {
place.setProduct(product);
}
}
}
}
...@@ -22,7 +22,7 @@ import fi.codecrew.moya.model.PlaceGroup; ...@@ -22,7 +22,7 @@ import fi.codecrew.moya.model.PlaceGroup;
@RequestScoped @RequestScoped
@Path("/map") @Path("/map")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" })
public class MapRestView { public class MapRestView {
@EJB @EJB
...@@ -32,7 +32,6 @@ public class MapRestView { ...@@ -32,7 +32,6 @@ public class MapRestView {
@GET @GET
@Path("/dateJson") @Path("/dateJson")
@Produces("text/javascript")
public String getAllCards() { public String getAllCards() {
EventMap map = placemapbean.getActiveMap(); EventMap map = placemapbean.getActiveMap();
......
...@@ -26,7 +26,7 @@ import fi.codecrew.moya.rest.pojo.PrintedCardRestPojo; ...@@ -26,7 +26,7 @@ import fi.codecrew.moya.rest.pojo.PrintedCardRestPojo;
@RequestScoped @RequestScoped
@Path("/card") @Path("/card")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" })
public class PrinterRestView { public class PrinterRestView {
@EJB @EJB
......
package fi.codecrew.moya.rest; package fi.codecrew.moya.rest;
import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
...@@ -26,7 +28,7 @@ import fi.codecrew.moya.rest.pojo.UserPermissionRestPojo; ...@@ -26,7 +28,7 @@ import fi.codecrew.moya.rest.pojo.UserPermissionRestPojo;
@RequestScoped @RequestScoped
@Path("/reader") @Path("/reader")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" })
public class ReaderRestView { public class ReaderRestView {
@EJB @EJB
...@@ -42,6 +44,26 @@ public class ReaderRestView { ...@@ -42,6 +44,26 @@ public class ReaderRestView {
return new ReaderRestRoot(ReaderRestPojo.parse(readerbean.getReaders())); return new ReaderRestRoot(ReaderRestPojo.parse(readerbean.getReaders()));
} }
/**
* Returns events after the designated eventid. If eventid == 0 return last
* 20, eventid < 0 return all
*/
@GET
@Path("/readerevents/{readerId}/{eventId}")
public ReaderEventRestRoot getReaderevents(@PathParam("readerId") Integer readerId, @PathParam("eventId") Integer eventId) {
List<ReaderEvent> events = null;
if (eventId != null && eventId > 0) {
events = readerbean.getReaderEventsAfterEvent(readerId, eventId);
} else {
int count = 20;
if (eventId == null || eventId == 0)
count = 0;
events = readerbean.getReaderEvents(readerId, count);
}
return new ReaderEventRestRoot(ReaderEventRestPojo.parse(events));
}
@GET @GET
@Path("/LastEventusers") @Path("/LastEventusers")
public ReaderEventRestRoot getLastEventusers() public ReaderEventRestRoot getLastEventusers()
...@@ -55,6 +77,7 @@ public class ReaderRestView { ...@@ -55,6 +77,7 @@ public class ReaderRestView {
// //
// } // }
// TBD: WTF! - Tarttis varmaan käydä ajatuksella läpi.. - Tuomari 2014-02-28
@GET @GET
@Path("/EventRole/{reader}/{tagId}/{roleid}") @Path("/EventRole/{reader}/{tagId}/{roleid}")
public Response eventRole(@PathParam("reader") String reader, @PathParam("tagId") String tag, @PathParam("roleid") Integer roleId) { public Response eventRole(@PathParam("reader") String reader, @PathParam("tagId") String tag, @PathParam("roleid") Integer roleId) {
......
package fi.codecrew.moya.rest;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.rest.pojo.SimpleEventuserRoot;
import fi.codecrew.moya.util.UserSearchQuery;
import fi.codecrew.moya.utilities.SearchResult;
@RequestScoped
@Path("/user")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" })
public class UserRestView {
@EJB
private UserBeanLocal userbean;
@GET
@Path("/eventusers")
public SimpleEventuserRoot getEventUsers() {
UserSearchQuery q = new UserSearchQuery();
q.setPagesize(0);
SearchResult<EventUser> users = userbean.getThisEventsUsers(q);
return SimpleEventuserRoot.parse(users.getResults());
}
}
package fi.codecrew.moya.rest.pojo;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import fi.codecrew.moya.model.EventMap;
@XmlRootElement
public class MapRoot {
private List<MapPojo> maps;
public MapRoot() {
}
public MapRoot(List<MapPojo> ret) {
this.setMaps(ret);
}
public List<MapPojo> getMaps() {
return maps;
}
public void setMaps(List<MapPojo> maps) {
this.maps = maps;
}
public static class MapPojo {
private EventMap map;
public MapPojo() {
super();
}
public MapPojo(EventMap m) {
this();
this.map = m;
}
@XmlElement(name = "name")
public String getName() {
return map.getName();
}
@XmlElement(name = "id")
public Integer getId() {
return map.getId();
}
}
public static MapRoot parseMaps(List<EventMap> eventMaps) {
List<MapPojo> ret = new ArrayList<>();
for (EventMap m : eventMaps) {
ret.add(new MapPojo(m));
}
return new MapRoot(ret);
}
}
package fi.codecrew.moya.rest.pojo;
public class PlaceInputPojo {
private Integer id;
private String name;
private Integer mapX;
private Integer mapY;
private Integer width;
private Integer height;
private Boolean buyable;
private Boolean disabled;
private Integer productId;
private Integer mapId;
private Boolean taken;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getMapX() {
return mapX;
}
public void setMapX(Integer mapX) {
this.mapX = mapX;
}
public Integer getMapY() {
return mapY;
}
public void setMapY(Integer mapY) {
this.mapY = mapY;
}
public Integer getWidth() {
return width;
}
public void setWidth(Integer width) {
this.width = width;
}
public Integer getHeight() {
return height;
}
public void setHeight(Integer height) {
this.height = height;
}
public Boolean getBuyable() {
return buyable;
}
public void setBuyable(Boolean buyable) {
this.buyable = buyable;
}
public Boolean getDisabled() {
return disabled;
}
public void setDisabled(Boolean disabled) {
this.disabled = disabled;
}
public Integer getProductId() {
return productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public Integer getMapId() {
return mapId;
}
public void setMapId(Integer mapId) {
this.mapId = mapId;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Boolean getTaken() {
return taken;
}
public void setTaken(Boolean taken) {
this.taken = taken;
}
}
package fi.codecrew.moya.rest.pojo;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import fi.codecrew.moya.model.Place;
public class PlaceOutPojo {
private Place place;
public PlaceOutPojo() {
}
public PlaceOutPojo(Place p) {
this.place = p;
}
public static List<PlaceOutPojo> parse(List<Place> places) {
List<PlaceOutPojo> ret = new ArrayList<>();
for (Place p : places)
{
ret.add(new PlaceOutPojo(p));
}
return ret;
}
@XmlElement
public Integer getProductId()
{
Integer ret = null;
if (place.getProduct() != null)
ret = place.getProduct().getId();
return ret;
}
@XmlElement
public Integer getId() {
return place.getId();
}
@XmlElement
public String getDescription() {
return place.getDescription();
}
@XmlElement
public String getName() {
return place.getName();
}
@XmlElement
public Integer getMapX() {
return place.getMapX();
}
@XmlElement
public Integer getMapY() {
return place.getMapY();
}
@XmlElement
public String getDetails() {
return place.getDetails();
}
@XmlElement
public String getCode() {
return place.getCode();
}
@XmlElement
public Integer getHeight() {
return place.getHeight();
}
@XmlElement
public Integer getWidth() {
return place.getWidth();
}
@XmlElement
public boolean isTaken() {
return place.isTaken();
}
@XmlElement
public boolean isBuyable() {
return place.isBuyable();
}
@XmlElement
public Calendar getReleaseTime() {
return place.getReleaseTime();
}
@XmlElement
public boolean isDisabled() {
return place.isDisabled();
}
@XmlElement
public Integer getReserverId()
{
Integer ret = null;
if (place.getPlaceReserver() != null && place.getPlaceReserver().getPlaceGroup() != null && place.getPlaceReserver().getPlaceGroup().getCreator() != null)
ret = place.getPlaceReserver().getPlaceGroup().getCreator().getId();
return ret;
}
@XmlElement
public Integer getMapId() {
Integer ret = null;
if (place.getMap() != null) {
ret = place.getMap().getId();
}
return ret;
}
@XmlElement
public Integer getEventuserId()
{
Integer ret = null;
if (place.getPlaceReserver() != null && place.getPlaceReserver().getUser() != null)
ret = place.getPlaceReserver().getUser().getId();
return ret;
}
}
package fi.codecrew.moya.rest.pojo;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.rest.pojo.MapRoot.MapPojo;
@XmlRootElement
public class PlaceRoot {
public PlaceRoot()
{
}
public PlaceRoot(EventMap map2) {
this.map = new MapPojo(map2);
setPlaces(PlaceOutPojo.parse(map2.getPlaces()));
}
private MapPojo map;
private List<PlaceOutPojo> places;
public MapPojo getMap() {
return map;
}
public void setMap(MapPojo map) {
this.map = map;
}
public List<PlaceOutPojo> getPlaces() {
return places;
}
public void setPlaces(List<PlaceOutPojo> places) {
this.places = places;
}
}
...@@ -76,4 +76,12 @@ public class ReaderEventRestPojo { ...@@ -76,4 +76,12 @@ public class ReaderEventRestPojo {
} }
return ret; return ret;
} }
public PrintedCardRestPojo getPrintedCard() {
return printedCard;
}
public void setPrintedCard(PrintedCardRestPojo printedCard) {
this.printedCard = printedCard;
}
} }
package fi.codecrew.moya.rest.pojo;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import fi.codecrew.moya.model.EventUser;
@XmlRootElement()
public class SimpleEventuserRoot {
private List<EventUserRestPojo> eventusers;
public SimpleEventuserRoot() {
}
public SimpleEventuserRoot(ArrayList<EventUserRestPojo> list) {
this.eventusers = list;
}
public List<EventUserRestPojo> getEventusers() {
return eventusers;
}
public void setEventusers(List<EventUserRestPojo> eventusers) {
this.eventusers = eventusers;
}
public static SimpleEventuserRoot parse(List<EventUser> users) {
ArrayList<EventUserRestPojo> list = new ArrayList<>();
for (EventUser u : users)
{
list.add(new EventUserRestPojo(u));
}
return new SimpleEventuserRoot(list);
}
}
...@@ -60,7 +60,8 @@ public class PlaceMap extends HttpServlet { ...@@ -60,7 +60,8 @@ public class PlaceMap extends HttpServlet {
private static final String PARAMETER_EVENT_MAP_ID = "mapid"; private static final String PARAMETER_EVENT_MAP_ID = "mapid";
/** /**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
* *
* @param request * @param request
* servlet request * servlet request
...@@ -246,7 +247,7 @@ public class PlaceMap extends HttpServlet { ...@@ -246,7 +247,7 @@ public class PlaceMap extends HttpServlet {
} }
Color color = null; Color color = null;
if (!p.isBuyable()) { if (!p.isBuyable()) {
logger.info("Locking place."); logger.debug("Setting color as locked place.");
color = LOCKED_COLOR; color = LOCKED_COLOR;
} }
...@@ -272,7 +273,7 @@ public class PlaceMap extends HttpServlet { ...@@ -272,7 +273,7 @@ public class PlaceMap extends HttpServlet {
logger.error("Cannot convert string {} to color.", p.getProduct().getColor()); logger.error("Cannot convert string {} to color.", p.getProduct().getColor());
} }
} else { } else {
logger.info("Nothing special for this place. Color should be default."); logger.debug("Nothing special for this place. Color should be default.");
} }
......
...@@ -91,12 +91,18 @@ public class PrimeMenuView extends GenericCDIView { ...@@ -91,12 +91,18 @@ public class PrimeMenuView extends GenericCDIView {
{ {
menuModel = new DefaultMenuModel(); menuModel = new DefaultMenuModel();
MenuNavigation selectedTop = layoutview.getSelectedTopmenu(); MenuNavigation selectedTop = layoutview.getSelectedTopmenu();
if (selectedTop == null)
if (selectedTop == null) {
return null; return null;
}
int testid = 3;
for (MenuNavigation m : selectedTop.getChildren()) { for (MenuNavigation m : selectedTop.getChildren()) {
if (m.getItem() != null && m.getChildren().isEmpty()) { if (m.getItem() != null && m.getChildren().isEmpty()) {
DefaultMenuItem menuitem = mkMenuitem(m); DefaultMenuItem menuitem = mkMenuitem(m);
if (menuitem != null) { if (menuitem != null) {
menuModel.addElement(menuitem); menuModel.addElement(menuitem);
} }
......
...@@ -44,14 +44,19 @@ public class UserCartView extends GenericCDIView { ...@@ -44,14 +44,19 @@ public class UserCartView extends GenericCDIView {
public StreamedContent getDownloadCsv() { public StreamedContent getDownloadCsv() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("firstname").append(CSV_SEPARATOR); sb.append("Firstname").append(CSV_SEPARATOR);
sb.append("lastname").append(CSV_SEPARATOR); sb.append("Lastname").append(CSV_SEPARATOR);
sb.append("nick").append(CSV_SEPARATOR); sb.append("Nick").append(CSV_SEPARATOR);
sb.append("login").append(CSV_SEPARATOR); sb.append("Login").append(CSV_SEPARATOR);
sb.append("birthday").append(CSV_SEPARATOR); sb.append("Birthday").append(CSV_SEPARATOR);
sb.append("phone").append(CSV_SEPARATOR); sb.append("Age").append(CSV_SEPARATOR);
sb.append("email").append(CSV_SEPARATOR); sb.append("Phone").append(CSV_SEPARATOR);
sb.append("places").append(CSV_SEPARATOR); sb.append("Email").append(CSV_SEPARATOR);
sb.append("Street").append(CSV_SEPARATOR);
sb.append("Zip").append(CSV_SEPARATOR);
sb.append("City").append(CSV_SEPARATOR);
sb.append("Places").append(CSV_SEPARATOR);
sb.append("\n"); sb.append("\n");
for (EventUser uc : usercart) for (EventUser uc : usercart)
{ {
...@@ -60,8 +65,12 @@ public class UserCartView extends GenericCDIView { ...@@ -60,8 +65,12 @@ public class UserCartView extends GenericCDIView {
sb.append(uc.getNick()).append(CSV_SEPARATOR); sb.append(uc.getNick()).append(CSV_SEPARATOR);
sb.append(uc.getLogin()).append(CSV_SEPARATOR); sb.append(uc.getLogin()).append(CSV_SEPARATOR);
sb.append(uc.getBirthday() != null ? dateformat.format(uc.getBirthday()) : "").append(CSV_SEPARATOR); sb.append(uc.getBirthday() != null ? dateformat.format(uc.getBirthday()) : "").append(CSV_SEPARATOR);
sb.append(uc.getUser().getAge()).append(CSV_SEPARATOR);
sb.append(uc.getPhone()).append(CSV_SEPARATOR); sb.append(uc.getPhone()).append(CSV_SEPARATOR);
sb.append(uc.getEmail()).append(CSV_SEPARATOR); sb.append(uc.getEmail()).append(CSV_SEPARATOR);
sb.append(uc.getAddress()).append(CSV_SEPARATOR);
sb.append(uc.getZip()).append(CSV_SEPARATOR);
sb.append(uc.getUser().getTown()).append(CSV_SEPARATOR);
for (GroupMembership gm : uc.getGroupMemberships()) for (GroupMembership gm : uc.getGroupMemberships())
{ {
if (gm.getPlaceReservation() != null) if (gm.getPlaceReservation() != null)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!