Commit 2ceeca89 by Tuukka Kivilahti

Merge branch 'master' of codecrew.fi:codecrew/moya into applicationRestStuff

2 parents ff690cbd 7a882794
Showing with 407 additions and 189 deletions
......@@ -117,7 +117,6 @@ public interface PlaceBeanLocal {
*/
List<Product> getMapProducts(EventMap map);
List<PlaceSlot> getFreePlaceslots(EventUser user, Product product);
List<Place> findPlacePrintlistForUser(EventUser user);
......
......@@ -37,18 +37,15 @@ public class CheckoutBank {
private static final Logger logger = LoggerFactory.getLogger(CheckoutBank.class);
public CheckoutBank(Node bank) {
if (bank.getNodeType() != 1)
{
if (bank.getNodeType() != Node.ELEMENT_NODE) {
throw new RuntimeException("Wrong type of node " + bank + " type " + bank.getNodeType());
}
key = bank.getNodeName();
logger.info("Bank type {}", bank);
NamedNodeMap attrs = bank.getAttributes();
String iconval = null;
String nameval = null;
String urlval = null;
for (int j = 0; j < attrs.getLength(); ++j)
{
for (int j = 0; j < attrs.getLength(); ++j) {
Node attr = attrs.item(j);
if (attr.getNodeName().equals("icon")) {
iconval = attr.getNodeValue();
......@@ -63,18 +60,14 @@ public class CheckoutBank {
url = urlval;
NodeList children = bank.getChildNodes();
for (int i = 0; i < children.getLength(); ++i)
{
for (int i = 0; i < children.getLength(); ++i) {
Node childnode = children.item(i);
if (childnode.getNodeType() == 1)
{
if (childnode.getNodeType() == Node.ELEMENT_NODE) {
String paramName = childnode.getNodeName();
String paramValue = childnode.getTextContent();
getPostParams().add(new Valuepair(paramName, paramValue));
logger.info("Added param for {} name {} value {}", new Object[] { key, paramName, paramValue });
}
}
// System.out.println();
}
......
......@@ -24,6 +24,7 @@ package fi.codecrew.moya.beans;
import java.io.ByteArrayOutputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
......@@ -50,6 +51,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 +65,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 +123,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) {
......@@ -176,7 +174,7 @@ public class PlaceBean implements PlaceBeanLocal {
Map<Product, Integer> mockmap = getPlaceProductcount(places);
BigDecimal total = BigDecimal.ZERO;
BigDecimal total = Bill.BILL_SCALED_ZERO_PRICE;
Calendar now = Calendar.getInstance();
for (Entry<Product, Integer> entry : mockmap.entrySet()) {
......@@ -185,7 +183,7 @@ public class PlaceBean implements PlaceBeanLocal {
total = total.add(productBean.calculateTotal(entry.getKey(), new BigDecimal(entry.getValue()), now, user));
}
}
return total;
return total.setScale(Bill.BILL_PRICE_SCALE, RoundingMode.HALF_UP);
}
private static Map<Product, Integer> getPlaceProductcount(Collection<Place> places) {
......@@ -482,78 +480,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
*
......
......@@ -19,24 +19,23 @@
package fi.codecrew.moya.beans;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ConcurrentSkipListSet;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.LocalBean;
import javax.ejb.Singleton;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.SessionMgmtBeanLocal;
import fi.codecrew.moya.enums.apps.UserPermission;
/**
......@@ -44,6 +43,8 @@ import fi.codecrew.moya.enums.apps.UserPermission;
*/
@Singleton
@LocalBean
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
@DeclareRoles({ UserPermission.S_MANAGE_HTTP_SESSION })
public class SessionMgmtBean implements SessionMgmtBeanLocal {
......@@ -54,7 +55,7 @@ public class SessionMgmtBean implements SessionMgmtBeanLocal {
// TODO Auto-generated constructor stub
}
private final ConcurrentSkipListMap<String, String> sessionUsers = new ConcurrentSkipListMap<String, String>();
private final ConcurrentHashMap<String, String> sessionUsers = new ConcurrentHashMap<String, String>();
private final Set<HttpSession> sessions = Collections.newSetFromMap(new ConcurrentHashMap<HttpSession, Boolean>());
@SuppressWarnings("unused")
......
package fi.codecrew.moya.checkoutfi;
public enum CheckoutFiCheckParam implements CheckoutQueryParam {
// DO NOT CHANGE THE ORDER OF THESE!
// The md5 checksum is calculated from
// these values...
VERSION("0001"),
STAMP(null),
REFERENCE(null),
MERCHANT(null),
AMOUNT(null),
CURRENCY("EUR"),
FORMAT("1"),
ALGORITHM("1"),
// MAC gets added automatically in querybuilder
;
private final String defaultValue;
private CheckoutFiCheckParam(String def) {
defaultValue = def;
}
public String getDefaultValue() {
return defaultValue;
}
}
......@@ -18,7 +18,7 @@
*/
package fi.codecrew.moya.checkoutfi;
public enum CheckoutFiParam {
public enum CheckoutFiPaymentParam implements CheckoutQueryParam {
// DO NOT CHANGE THE ORDER OF THESE!
// The md5 checksum is calculated from
......@@ -45,11 +45,14 @@ public enum CheckoutFiParam {
FAMILYNAME(null),
ADDRESS(null),
POSTCODE(null),
POSTOFFICE(null), ;
POSTOFFICE(null),
// MAC gets added automatically in querybuilder
;
private final String defaultValue;
private CheckoutFiParam(String def) {
private CheckoutFiPaymentParam(String def) {
defaultValue = def;
}
......
package fi.codecrew.moya.checkoutfi;
public interface CheckoutQueryParam {
public String name();
public String getDefaultValue();
}
......@@ -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.beans;
import org.testng.annotations.BeforeTest;
import javax.ejb.embeddable.EJBContainer;
import javax.naming.NamingException;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@Test
public abstract class AbstractEjbTest {
@BeforeTest
......
......@@ -19,8 +19,8 @@
package fi.codecrew.moya.beans;
import org.testng.annotations.Test;
public class BarcodeTests {
@Test
public class BarcodeTest {
@Test
public void tbd() {
}
......
package fi.codecrew.moya.beans;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.http.NameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
import fi.codecrew.moya.checkoutfi.CheckoutFiPaymentParam;
import fi.codecrew.moya.checkoutfi.CheckoutQueryParam;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.BillLine;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.util.CheckoutBank;
public class CheckoutFiBeanTest {
@Test
public void testQuery() {
new CheckoutFiBeanMock().testQuery();
}
@Test
public void testXml() {
new CheckoutFiBeanMock().testXml();
}
@Test
public void testPollXml() throws UnsupportedEncodingException
{
new CheckoutFiBeanMock().testPollXml();
}
public static class CheckoutFiBeanMock extends CheckoutFiBean {
private static final Logger logger = LoggerFactory.getLogger(CheckoutFiBeanTest.class);
public void testQuery() {
QueryBuilder queryBuilder = new QueryBuilder(CheckoutFiPaymentParam.values(), new Date(System.currentTimeMillis() + 60000), "375917", "SAIPPUAKAUPPIAS");
assertTrue("Credentials are valid!", queryBuilder.isCredentialsValid());
final String returnUrl = new StringBuilder()
.append("https://")
.append("localhost")
.append("/MoyaWeb/checkout/")
.toString();
LanEvent lanevent = new LanEvent();
lanevent.setReferenceNumberBase(100000);
Date d = new Date(1427495053008l);
Bill bill = new Bill();
bill.setEvent(lanevent);
bill.setId(67890);
bill.setBillNumber(12345);
bill.setAddr1("Teemu Teekkari");
bill.setAddr2("Hervannantie 1");
bill.setAddr3("33600 Tampere");
bill.setAddr4("FINLAND");
bill.setSentDateTime(d);
Product prod = new Product();
prod.setName("Hurr");
prod.setPrice(new BigDecimal(111.11).setScale(4, RoundingMode.HALF_UP));
bill.getBillLines().add(new BillLine(bill, prod, new BigDecimal(5)));
final String priceInCents = Integer.valueOf(bill.totalPrice().multiply(TO_CENTS).intValue()).toString();
final Map<String, String> requiredParams = new HashMap<>();
requiredParams.put("VERSION", "0001");
requiredParams.put("COUNTRY", "FIN");
requiredParams.put("CURRENCY", "EUR");
requiredParams.put("DEVICE", "10");
requiredParams.put("CONTENT", "1");
requiredParams.put("TYPE", "0");
requiredParams.put("ALGORITHM", "2");
requiredParams.put("LANGUAGE", "FI");
queryBuilder.addParam((CheckoutQueryParam) CheckoutFiPaymentParam.STAMP, getStamp(bill));
requiredParams.put("STAMP", "67890a1427495053");
queryBuilder.addParam(CheckoutFiPaymentParam.AMOUNT, priceInCents);
requiredParams.put("AMOUNT", "55555");
queryBuilder.addParam(CheckoutFiPaymentParam.REFERENCE, bill.getReferenceNumber().toString());
// 112345 + checksum(2)
requiredParams.put("REFERENCE", "1123452");
queryBuilder.addParam(CheckoutFiPaymentParam.MERCHANT, queryBuilder.getMerchantId());
requiredParams.put("MERCHANT", "375917");
queryBuilder.addParam(CheckoutFiPaymentParam.RETURN, returnUrl + "return.jsf");
requiredParams.put("RETURN", "https://localhost/MoyaWeb/checkout/return.jsf");
queryBuilder.addParam(CheckoutFiPaymentParam.CANCEL, returnUrl + "cancel.jsf");
requiredParams.put("CANCEL", "https://localhost/MoyaWeb/checkout/cancel.jsf");
queryBuilder.addParam(CheckoutFiPaymentParam.REJECT, returnUrl + "reject.jsf");
requiredParams.put("REJECT", "https://localhost/MoyaWeb/checkout/reject.jsf");
queryBuilder.addParam(CheckoutFiPaymentParam.DELAYED, returnUrl + "delayed.jsf");
requiredParams.put("DELAYED", "https://localhost/MoyaWeb/checkout/delayed.jsf");
queryBuilder.addParam(CheckoutFiPaymentParam.DELIVERY_DATE, new SimpleDateFormat(DATEFORMAT).format(d));
requiredParams.put("DELIVERY_DATE", "20150328");
requiredParams.put("MAC", "7FBDC5A633794B7292E6B02020330E64");
List<NameValuePair> nvpairs = queryBuilder.getNameValuePairs();
for (NameValuePair p : nvpairs) {
assertTrue("Missing required param: " + p.getName() + " val " + p.getValue(), requiredParams.containsKey(p.getName()));
String val = requiredParams.remove(p.getName());
assertEquals("Wrong value for " + p.getName(), val, p.getValue());
}
for (Entry<String, String> p : requiredParams.entrySet()) {
logger.warn("Not found param {} with value {}", p.getKey(), p.getValue());
}
}
@Test
public void testXml()
{
InputStream testfile1 = getClass().getResourceAsStream("checkoutTestfile.xml");
List<CheckoutBank> ret = CheckoutFiBean.parseTokenXml(testfile1);
// Huom! Neopay, ape ja tilisiirto poistettu parsinnassa.
assertEquals(8, ret.size());
for (int i = 0; i < ret.size(); ++i) {
CheckoutBank bnk = ret.get(i);
switch (i) {
case 0:
assertEquals("nordea", bnk.getKey());
assertEquals(17, bnk.getPostParams().size());
break;
case 1:
assertEquals("osuuspankki", bnk.getKey());
assertEquals(13, bnk.getPostParams().size());
break;
case 2:
assertEquals("samlink", bnk.getKey());
assertEquals(13, bnk.getPostParams().size());
break;
case 3:
assertEquals("sampo", bnk.getKey());
assertEquals(9, bnk.getPostParams().size());
break;
case 4:
assertEquals("handelsbanken", bnk.getKey());
assertEquals(13, bnk.getPostParams().size());
break;
case 5:
assertEquals("spankki", bnk.getKey());
assertEquals(17, bnk.getPostParams().size());
break;
case 6:
assertEquals("alandsbanken", bnk.getKey());
assertEquals(18, bnk.getPostParams().size());
break;
case 7:
assertEquals("tapiola", bnk.getKey());
assertEquals(18, bnk.getPostParams().size());
break;
case 8:
assertEquals("neopay", bnk.getKey());
assertEquals(9, bnk.getPostParams().size());
break;
case 9:
assertEquals("tilisiirto", bnk.getKey());
assertEquals(6, bnk.getPostParams().size());
break;
case 10:
assertEquals("ape", bnk.getKey());
assertEquals(4, bnk.getPostParams().size());
break;
default:
fail("Wrong number of banks: " + i);
break;
}
}
}
private static final String pollReturnXML = "<?xml version=\"1.0\"?> <trade> <status> 2 </status></trade> ";
private static final String LATIN1 = "ISO-8859-1";
@Test
public void testPollXml() throws UnsupportedEncodingException
{
String ret = CheckoutFiBean.parsePollXml(new ByteArrayInputStream(pollReturnXML.getBytes(LATIN1)));
assertEquals("2", ret);
}
}
}
......@@ -6,13 +6,13 @@ import org.testng.annotations.Test;
@Test
public class VipBeanTest {
private static final Logger log = LoggerFactory.getLogger(VipBeanTest.class);
private static final Logger log = LoggerFactory.getLogger(VipBeanTest.class);
@Test
public void testVip() {
log.info("testVip");
@Test
public void testVip() {
log.info("testVip");
VipBean vipBean = new VipBean();
}
VipBean vipBean = new VipBean();
}
}
......@@ -42,7 +42,6 @@ import javax.persistence.Table;
public class BillLine extends GenericEntity {
private static final long serialVersionUID = 2L;
private static final BigDecimal DEFAULT_VAT = BigDecimal.ZERO;
/**
* Which bill this bill line belongs to
*/
......@@ -67,8 +66,8 @@ public class BillLine extends GenericEntity {
* How much one(1) unit of this product costs
*
*/
@Column(name = "unit_price", nullable = false, precision = 24, scale = 4)
private BigDecimal unitPrice = BigDecimal.ZERO;
@Column(name = "unit_price", nullable = false, precision = 24, scale = Bill.BILL_PRICE_SCALE)
private BigDecimal unitPrice = Bill.BILL_SCALED_ZERO_PRICE;
/**
*
......@@ -79,8 +78,8 @@ public class BillLine extends GenericEntity {
/**
* How much VAT this product contains ( 0, 0.22 ) etc
*/
@Column(name = "vat", nullable = false, precision = 4, scale = 3)
private BigDecimal vat = DEFAULT_VAT;
@Column(name = "vat", nullable = false, precision = 4, scale = Bill.VAT_SCALE)
private BigDecimal vat = Bill.VAT_SCALED_ZERO;
@JoinColumn(name = "lineProduct_id", referencedColumnName = "id", nullable = true, updatable = false)
@OneToOne
......@@ -111,7 +110,7 @@ public class BillLine extends GenericEntity {
*/
public BigDecimal getLinePriceVatless() {
BigDecimal vatMultiplicand = BigDecimal.ONE.add(getVat());
return getLinePrice().divide(vatMultiplicand, 2, RoundingMode.HALF_UP);
return getLinePrice().divide(vatMultiplicand, Bill.BILL_PRICE_SCALE, RoundingMode.HALF_UP);
}
public BillLine() {
......@@ -157,8 +156,8 @@ public class BillLine extends GenericEntity {
public BillLine(Bill bill2, Product product, Discount disc, BigDecimal count) {
super();
this.bill = bill2;
BigDecimal unitPrice = product.getPrice().subtract(product.getPrice().multiply(disc.getPercentage())).negate().setScale(2, RoundingMode.HALF_UP);
BigDecimal unitPrice = product.getPrice().subtract(product.getPrice().multiply(disc.getPercentage())).negate().setScale(Bill.BILL_PRICE_SCALE, RoundingMode.HALF_UP);
this.name = disc.getShortdesc();
this.unitName = product.getUnitName();
this.quantity = count;
......
......@@ -19,6 +19,7 @@
package fi.codecrew.moya.model;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
......@@ -45,13 +46,15 @@ public class Discount extends GenericEntity {
private static final long serialVersionUID = 1L;
private static final String EVENT_ID = "event_id";
private static final BigDecimal SCALE4_ZERO = BigDecimal.ZERO.setScale(4, RoundingMode.HALF_UP);
private static final BigDecimal SCALE6_ZERO = BigDecimal.ZERO.setScale(6, RoundingMode.HALF_UP);
@ManyToOne()
@JoinColumn(name = EVENT_ID, nullable = false)
private LanEvent event;
@Column(name = "percentage", nullable = false, precision = 9, scale = 6)
private BigDecimal percentage = BigDecimal.ZERO;
private BigDecimal percentage = SCALE6_ZERO;
@Column(name = "code")
private String code;
......@@ -71,22 +74,22 @@ public class Discount extends GenericEntity {
private String shortdesc;
@Column(name = "amount_min", nullable = false, precision = 24, scale = 4)
private BigDecimal amountMin = BigDecimal.ZERO;
private BigDecimal amountMin = SCALE4_ZERO;
@Column(name = "amount_max", nullable = false, precision = 24, scale = 4)
private BigDecimal amountMax = BigDecimal.ZERO;
private BigDecimal amountMax = SCALE4_ZERO;
@Column(name = "active", nullable = false)
private boolean active = false;
@Column(name = "max_num", nullable = false, precision = 24, scale = 4)
private BigDecimal maxNum = BigDecimal.ZERO;
private BigDecimal maxNum = SCALE4_ZERO;
@Column(name = "per_user", nullable = false, precision = 24, scale = 4)
private BigDecimal perUser = BigDecimal.ZERO;
private BigDecimal perUser = SCALE4_ZERO;
@Column(name = "total_count", nullable = false, precision = 24, scale = 4)
private BigDecimal totalCount = BigDecimal.ZERO;
private BigDecimal totalCount = SCALE4_ZERO;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "discount")
private List<DiscountInstance> discountInstances;
......
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);
}
}
}
......@@ -54,7 +54,7 @@ public class EventOrgView extends GenericCDIView {
private transient EventOrganiserBeanLocal eventorgbean;
@EJB
private transient EventBeanLocal eventbean;
private static final Logger logger = LoggerFactory.getLogger(EventOrgView.class);
@LoggedIn
......@@ -155,12 +155,14 @@ public class EventOrgView extends GenericCDIView {
if (eventorg.getEvents() == null) {
eventorg.setEvents(new ArrayList<LanEvent>());
}
setEvent(new LanEvent());
getEvent().setName(eventname);
getEvent().setOrganiser(eventorg);
event = new LanEvent();
event.setName(eventname);
event.setOrganiser(eventorg);
eventname = "";
eventorg.getEvents().add(getEvent());
eventorgbean.save(eventorg);
eventbean.create(event);
//eventorg = eventorgbean.save(eventorg);
return "/eventorg/editEvent";
......@@ -267,12 +269,12 @@ public class EventOrgView extends GenericCDIView {
for (LanEvent lanEvent : eventbean.findAllEvents()) {
if (lanEvent.getStartTime() != null && lanEvent.getEndTime() != null && lanEvent.getTicketSalesBegin() != null) {
DefaultScheduleEvent event = new DefaultScheduleEvent("<"+lanEvent.getId() + "> " + lanEvent.getName() + ": " + I18n.get("event.ticketSale"), lanEvent.getTicketSalesBegin(), lanEvent.getEndTime());
DefaultScheduleEvent event = new DefaultScheduleEvent("<" + lanEvent.getId() + "> " + lanEvent.getName() + ": " + I18n.get("event.ticketSale"), lanEvent.getTicketSalesBegin(), lanEvent.getEndTime());
event.setAllDay(true);
eventsCalendar.addEvent(event);
event.setStyleClass("calendarEventStyle");
event = new DefaultScheduleEvent( "<"+lanEvent.getId() + "> " + lanEvent.getName() + ": " + I18n.get("event.running"), lanEvent.getStartTime(), lanEvent.getEndTime());
event = new DefaultScheduleEvent("<" + lanEvent.getId() + "> " + lanEvent.getName() + ": " + I18n.get("event.running"), lanEvent.getStartTime(), lanEvent.getEndTime());
event.setAllDay(true);
event.setStyleClass("eventRunningCalendar");
eventsCalendar.addEvent(event);
......@@ -285,9 +287,3 @@ public class EventOrgView extends GenericCDIView {
}
}
......@@ -124,7 +124,7 @@ public class EventPropertyView extends GenericCDIView {
}
public String deleteProperty() {
eventbean.deleteProperty(properties.getRowData());
eventorgview.setEvent(eventbean.deleteProperty(properties.getRowData()));
properties = null;
return null;
}
......@@ -237,16 +237,14 @@ public class EventPropertyView extends GenericCDIView {
}
public ListDataModel<LanEventProperty> getProperties() {
if (properties == null && eventorgview != null && eventorgview.getEvent() != null)
{
if (properties == null && eventorgview != null && eventorgview.getEvent() != null) {
properties = new ListDataModel<LanEventProperty>(eventorgview.getEvent().getProperties());
}
return properties;
}
public ListDataModel<LanEventPrivateProperty> getPrivateProperties() {
if (privateProperties == null && eventorgview != null && eventbean.getCurrentEvent().equals(eventorgview.getEvent()))
{
if (privateProperties == null && eventorgview != null && eventbean.getCurrentEvent().equals(eventorgview.getEvent())) {
privateProperties = new ListDataModel<LanEventPrivateProperty>(eventbean.getPrivateProperties());
}
return privateProperties;
......
......@@ -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!