Commit 91916caf by Liv Haapala

Merge branch 'master' of gitlab.codecrew.fi:codecrew/moya

2 parents 553f27e5 d51cb4ad
Showing with 623 additions and 29 deletions
...@@ -36,8 +36,6 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -36,8 +36,6 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { "ALTER TABLE products ALTER COLUMN vat TYPE NUMERIC(4,3)" }); dbUpdates.add(new String[] { "ALTER TABLE products ALTER COLUMN vat TYPE NUMERIC(4,3)" });
dbUpdates.add(new String[] { "ALTER TABLE actionlog_messages DROP COLUMN crew" }); dbUpdates.add(new String[] { "ALTER TABLE actionlog_messages DROP COLUMN crew" });
dbUpdates.add(new String[] { "delete from application_permissions where application ilike '%terminal%'" }); dbUpdates.add(new String[] { "delete from application_permissions where application ilike '%terminal%'" });
} }
@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,31 @@ public class EventMapBean implements EventMapBeanLocal { ...@@ -78,4 +82,31 @@ 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);
}
} }
...@@ -236,6 +236,7 @@ public class MenuBean implements MenuBeanLocal { ...@@ -236,6 +236,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");
......
...@@ -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;
} }
......
...@@ -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,10 @@ public interface EventMapBeanLocal { ...@@ -17,4 +18,10 @@ public interface EventMapBeanLocal {
EventMap clearPlaces(EventMap map); EventMap clearPlaces(EventMap map);
void deletePlace(Place place);
Place findPlace(Integer id);
Place updatePlace(Place place);
} }
...@@ -10,7 +10,7 @@ public class CashierView extends AbstractView { ...@@ -10,7 +10,7 @@ public class CashierView extends AbstractView {
private static final long serialVersionUID = -4415449134790807417L; private static final long serialVersionUID = -4415449134790807417L;
public void initCreateView() { public void initCreateView() {
if (super.requirePermissions(TerminalPermission.CASHIER)) { if (super.requirePermissions(TerminalPermission.INFO)) {
super.beginConversation(); super.beginConversation();
} }
} }
......
...@@ -10,7 +10,7 @@ public class CustomerView extends AbstractView { ...@@ -10,7 +10,7 @@ public class CustomerView extends AbstractView {
private static final long serialVersionUID = -8746462342138568821L; private static final long serialVersionUID = -8746462342138568821L;
public void initCreateView() { public void initCreateView() {
if (super.requirePermissions(TerminalPermission.CUSTOMER)) { if (super.requirePermissions(TerminalPermission.USER)) {
super.beginConversation(); super.beginConversation();
} }
} }
......
...@@ -18,10 +18,10 @@ public class RedirectView { ...@@ -18,10 +18,10 @@ public class RedirectView {
public void redirectByPermissions() throws Exception { public void redirectByPermissions() throws Exception {
FacesContext fcont = FacesContext.getCurrentInstance(); FacesContext fcont = FacesContext.getCurrentInstance();
if (permissionBean.hasPermission(TerminalPermission.CASHIER)) { if (permissionBean.hasPermission(TerminalPermission.INFO)) {
fcont.getApplication().getNavigationHandler() fcont.getApplication().getNavigationHandler()
.handleNavigation(fcont, null, "/cashier"); .handleNavigation(fcont, null, "/cashier");
} else if (permissionBean.hasPermission(TerminalPermission.CUSTOMER)) { } else if (permissionBean.hasPermission(TerminalPermission.USER)) {
fcont.getApplication().getNavigationHandler() fcont.getApplication().getNavigationHandler()
.handleNavigation(fcont, null, "/customer"); .handleNavigation(fcont, null, "/customer");
} else { } else {
......
...@@ -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>
......
...@@ -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>
......
...@@ -110,8 +110,9 @@ ...@@ -110,8 +110,9 @@
<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
......
...@@ -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?
......
...@@ -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.PlaceGroupBeanLocal;
import fi.codecrew.moya.beans.PlaceMapBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.model.EventMap;
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;
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) {
EventMap map = eventmapbean.find(create.getMapId());
if (map == null) {
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();
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();
}
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
......
...@@ -26,7 +26,7 @@ import fi.codecrew.moya.rest.pojo.UserPermissionRestPojo; ...@@ -26,7 +26,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
...@@ -55,6 +55,7 @@ public class ReaderRestView { ...@@ -55,6 +55,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 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;
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;
}
}
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 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;
}
}
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);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!