Commit e964b200 by Tuomas Riihimäki

Merge branch 'karttafix' into 'master'

Karttafix

jotain muutoksia karttajutukkeeseen

See merge request !255
2 parents 6ae71ff6 c5dd538d
......@@ -117,7 +117,6 @@ public interface PlaceBeanLocal {
*/
List<Product> getMapProducts(EventMap map);
List<PlaceSlot> getFreePlaceslots(EventUser user, Product product);
List<Place> findPlacePrintlistForUser(EventUser user);
......
......@@ -50,6 +50,7 @@ import javax.ejb.Timer;
import javax.ejb.TimerService;
import javax.xml.registry.infomodel.Slot;
import fi.codecrew.moya.facade.*;
import fi.codecrew.moya.model.*;
import org.slf4j.Logger;
......@@ -63,13 +64,6 @@ import com.pdfjet.TextLine;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.exceptions.BortalCatchableException;
import fi.codecrew.moya.facade.EventMapFacade;
import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.GroupMembershipFacade;
import fi.codecrew.moya.facade.PlaceFacade;
import fi.codecrew.moya.facade.PlaceGroupFacade;
import fi.codecrew.moya.facade.PlaceSlotFacade;
import fi.codecrew.moya.facade.UserFacade;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
/**
......@@ -128,6 +122,9 @@ public class PlaceBean implements PlaceBeanLocal {
@EJB
private PlaceSlotFacade placeSlotFacade;
@EJB
private BillFacade billFacade;
@Override
@RolesAllowed(MapPermission.S_MANAGE_MAPS)
public Place mergeChanges(Place place) {
......@@ -482,77 +479,6 @@ public class PlaceBean implements PlaceBeanLocal {
return placeFacade.setBuyable(map, like, b);
}
// @Override
// @RolesAllowed("MAP/READ")
// public Place find(EventPk id) {
// return placeFacade.find(id);
// }
// @Override
// public void checkMemberships() {
// List<Place> all = placeFacade.findAll(eventBean.getCurrentEvent());
// for (Place p : all) {
// if (p.getGroup() != null && p.getPlaceReserver() == null) {
// LanEvent event = eventBean.getCurrentEvent();
// String token = gmemfacade.createInviteToken(event);
//
// GroupMembership gm = new GroupMembership(event, p.getGroup(), p, token);
// p.getGroup().getMembers().add(gm);
// p.setPlaceReserver(gm);
//
// }
//
// }
//
// }
// @Override
// @RolesAllowed("SHOP/EXECUTE")
// public Place lockPlace(User user, Place place) throws
// PermissionDeniedException {
// if (place.isTaken()) {
// logger.warn("Place {} is already taken", place);
// // throw new PermissionDeniedException(secubean,
// // permbean.getCurrentUser(), "Place already taken!");
// return null;
// }
//
// LanEvent ev = eventBean.getCurrentEvent();
// PlaceGroup pg = new PlaceGroup(ev, Calendar.getInstance(),
// Calendar.getInstance(), true);
// pg.setCreator(user);
//
// user.getPlaceGroups().add(pg);
//
// place.reserve(user);
// place.buy(pg);
//
// GroupMembership newgm = new GroupMembership(ev, pg, place,
// gmemfacade.createInviteToken(ev));
//
// pg.getMembers().add(newgm);
//
// boolean foundGm = false;
// for (GroupMembership gm : user.getGroupMemberships()) {
// logger.debug("Checking users gm:s found: {}", gm);
// if (gm.getId().getEventId().equals(ev.getId())) {
// foundGm = true;
// break;
// }
// }
// logger.debug("Foundgm {}", foundGm);
// if (!foundGm) {
// logger.debug("Membership not found. associating");
// newgm.setUser(user);
// user.getGroupMemberships().add(newgm);
//
// userbean.mergeChanges(user);
// }
// pgfacade.create(pg);
// place = placeFacade.merge(place);
//
// return place;
// }
/**
* Release reservation from user
......@@ -798,6 +724,8 @@ public class PlaceBean implements PlaceBeanLocal {
return placeFacade.getMapProducts(map);
}
@Override
public List<PlaceSlot> getFreePlaceslots(EventUser user, EventMap map) {
user = eventUserFacade.reload(user);
......
......@@ -110,6 +110,9 @@ public class PlaceSlotFacade extends IntegerPkGenericFacade<PlaceSlot> {
Path<Bill> bill = root.get(PlaceSlot_.bill);
q.where(cb.equal(bill.get(Bill_.user), user),
cb.isNotNull(bill.get(Bill_.paidDate)));
q.orderBy(cb.asc(root.get(PlaceSlot_.place)));
return getEm().createQuery(q).getResultList();
}
......
package fi.codecrew.moya.model;
import java.util.Calendar;
import java.util.Date;
import javax.persistence.Entity;
......@@ -37,6 +38,19 @@ public class PlaceSlot extends GenericEntity {
@Lob
private String description;
public PlaceSlot(Product product, Bill bill, String description) {
this();
this.product = product;
this.bill = bill;
this.description = description;
}
public PlaceSlot() {
this.created = Calendar.getInstance().getTime();
}
public Date getCreated() {
return created;
}
......
......@@ -66,35 +66,36 @@
<h2>Place slots</h2>
<h:form>
<p:dataTable var="slot" value="#{placeGroupView.placeslots}">
<p:column headerText="#{i18n['placeslot.id']}">
<h:outputText value="#{slot.id}" />
</p:column>
<p:column headerText="#{i18n['placeslot.state']}">
<h:outputText value="#{slot.bill.expired ? i18n['placeslot.state.expired'] : ( slot.bill.paid ? i18n['placeslot.state.paid'] : i18n['placeslot.state.notPaid'])}" />
</p:column>
<p:column headerText="#{i18n['placeslot.product']}">
<h:outputText value="#{slot.product.name}" />
</p:column>
<p:column headerText="#{i18n['placeslot.place']}">
<h:outputText rendered="#{!empty slot.place}" value="#{slot.place.name}" />
</p:column>
<p:column headerText="#{i18n['placeslot.used']}">
<h:outputText value="#{slot.used}">
<f:convertDateTime timeZone="#{sessionHandler.timezone}" pattern="#{sessionHandler.shortDatetimeFormat}" />
</h:outputText>
</p:column>
<p:column headerText="#{i18n['placeslot.bill']}">
<h:link outcome="/bill/showBill" value="#{i18n['bill.billNumber']}: #{slot.bill.id}">
<f:param name="billid" value="#{slot.bill.id}" />
</h:link>
</p:column>
<p:column >
<h:commandButton rendered="#{empty slot.place and empty slot.used}" value="#{i18n['placeslot.lockSlot']}" ajax="false" action="#{placeGroupView.lockSlot}" />
<h:commandButton rendered="#{empty slot.place and not empty slot.used}" value="#{i18n['placeslot.releaseSlot']}" ajax="false" action="#{placeGroupView.releaseSlot}" />
</p:column>
</p:dataTable>
</h:form>
<p:dataTable var="slot" value="#{placeGroupView.placeslots}" id="placeslots">
<p:column headerText="#{i18n['placeslot.id']}">
<h:outputText value="#{slot.id}" />
</p:column>
<p:column headerText="#{i18n['placeslot.state']}">
<h:outputText value="#{slot.bill.expired ? i18n['placeslot.state.expired'] : ( slot.bill.paid ? i18n['placeslot.state.paid'] : i18n['placeslot.state.notPaid'])}" />
</p:column>
<p:column headerText="#{i18n['placeslot.product']}">
<h:outputText value="#{slot.product.name}" />
</p:column>
<p:column headerText="#{i18n['placeslot.place']}">
<h:outputText rendered="#{!empty slot.place}" value="#{slot.place.name}" />
</p:column>
<p:column headerText="#{i18n['placeslot.used']}">
<h:outputText value="#{slot.used}">
<f:convertDateTime timeZone="#{sessionHandler.timezone}" pattern="#{sessionHandler.shortDatetimeFormat}" />
</h:outputText>
</p:column>
<p:column headerText="#{i18n['placeslot.bill']}">
<h:link outcome="/bill/showBill" value="#{i18n['bill.billNumber']}: #{slot.bill.id}">
<f:param name="billid" value="#{slot.bill.id}" />
</h:link>
</p:column>
<p:column >
<p:commandButton rendered="#{empty slot.place and empty slot.used}" value="#{i18n['placeslot.lockSlot']}" actionListener="#{placeGroupView.lockSlot}" update="placeslots" />
<p:commandButton rendered="#{empty slot.place and not empty slot.used}" value="#{i18n['placeslot.releaseSlot']}" actionListener="#{placeGroupView.releaseSlot}" update="placeslots" />
</p:column>
</p:dataTable>
</h:form>
......
......@@ -90,7 +90,7 @@ public class PlacemapRestViewV1 {
EventMap map = placebean.findMap(id);
byte[] data = map.getMapData();
ResponseBuilder ret = Response.ok(data, "image/png");
ResponseBuilder ret = Response.ok(data, map.getMimeType());
ret.expires(new Date(System.currentTimeMillis() + 6 * 60 * 60 * 1000));
return ret.build();
......
......@@ -18,6 +18,7 @@
*/
package fi.codecrew.moya.web.cdiview.map;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
......@@ -28,6 +29,7 @@ import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.imageio.ImageIO;
import javax.inject.Named;
import org.primefaces.model.DefaultStreamedContent;
......@@ -133,7 +135,19 @@ public class MapManageView extends GenericCDIView {
}
map.setMapData(bytes);
map.setMimeType(bgFile.getContentType());
map = eventmapBean.saveMap(map);
try {
BufferedImage image = ImageIO.read(new ByteArrayInputStream(map.getMapData()));
map.setWidth(image.getWidth());
map.setHeight(image.getHeight());
map = eventmapBean.saveMap(map);
} catch (IOException e) {
addFaceMessage("map.upload.failed");
}
return null;
}
......
......@@ -29,10 +29,7 @@ import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.PlaceGroupBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.beans.*;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.model.*;
import fi.codecrew.moya.web.annotations.SelectedUser;
......@@ -79,8 +76,12 @@ public class PlacegroupView extends GenericCDIView {
@EJB
private PlaceBeanLocal placeslotBean;
@EJB
private ProductBeanLocal productBean;
private ListDataModel<PlaceSlot> placeslots;
public String editGroup() {
setGroup(placegroups.getRowData());
setPlacelist(new ListDataModel<Place>(group.getPlaces()));
......@@ -211,18 +212,16 @@ public class PlacegroupView extends GenericCDIView {
return null;
}
public String lockSlot() {
public void lockSlot() {
PlaceSlot row = placeslots.getRowData();
placeslotBean.lockSlot(row);
placeslots = null;
return null;
}
public String releaseSlot() {
public void releaseSlot() {
PlaceSlot row = placeslots.getRowData();
placeslotBean.releaseSlot(row);
placeslots = null;
return null;
}
public ListDataModel<PlaceGroup> getPlacegroups() {
......@@ -318,4 +317,9 @@ public class PlacegroupView extends GenericCDIView {
inviteMails.put(row.getId(), inviteMail);
}
}
}
......@@ -522,3 +522,7 @@ bortalApplication.vip.VIEW=View VIP list
bortalApplication.vip.USAGE=Use VIP list
bortalApplication.vip.EDIT=Edit VIP list
bortalApplication.event.VIEW_STATISTICS=View event statistics
eventmap.width=Kartan leveys (px)
eventmap.height=Kartan korkeus (px)
eventmap.uploaderror=Virhe lis\u00E4tess\u00E4 karttapohjaa
placeslot.add=Lis\u00E4\u00E4 placeslot
......@@ -1739,3 +1739,7 @@ bortalApplication.vip.VIEW=View VIP list
bortalApplication.vip.USAGE=Use VIP list
bortalApplication.vip.EDIT=Edit VIP list
bortalApplication.event.VIEW_STATISTICS=View event statistics
eventmap.width=Map width (px)
eventmap.height=Map height (px)
eventmap.uploaderror=Error when adding map
placeslot.add=Add placeslot
......@@ -1718,8 +1718,12 @@ cardObjectData.delete=Poista
cardTextData.delete=Poista
placegroup.noPlacegroups=Sinulla t\u00E4ytyy olla paikkoja ett\u00E4 voit n\u00E4hd\u00E4 lippusi
bortalApplication.VIP=VIP-lista
bortalApplication.vip.VIEW=Näytä VIP-lista
bortalApplication.vip.USAGE=Käytä VIP-listaa
bortalApplication.vip.VIEW=N\u00E4yt\u00E4 VIP-lista
bortalApplication.vip.USAGE=K\u00E4yt\u00E4 VIP-listaa
bortalApplication.vip.EDIT=Muokkaa VIP-listaa
bortalApplication.event.VIEW_STATISTICS=Näytä tapahtuman tilastot
lecture.showParticipants=Näytä osallistujat
bortalApplication.event.VIEW_STATISTICS=N\u00E4yt\u00E4 tapahtuman tilastot
lecture.showParticipants=N\u00E4yt\u00E4 osallistujat
eventmap.width=Kartan leveys (px)
eventmap.height=Kartan korkeus (px)
eventmap.uploaderror=Virhe lis\u00E4tt\u00E4ess\u00E4 karttapohjaa
placeslot.add=Lis\u00E4\u00E4 placeslot
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!