Commit 2c3e6382 by Tuukka Kivilahti

Merge branch 'asdasd' into 'master'

Rest fix

See merge request !237
2 parents f73d55d4 bf90958f
...@@ -30,6 +30,7 @@ import javax.persistence.criteria.*; ...@@ -30,6 +30,7 @@ import javax.persistence.criteria.*;
import fi.codecrew.moya.beans.EventBean; import fi.codecrew.moya.beans.EventBean;
import fi.codecrew.moya.model.*; import fi.codecrew.moya.model.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -64,9 +65,11 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> { ...@@ -64,9 +65,11 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
Root<Place> root = cq.from(Place.class); Root<Place> root = cq.from(Place.class);
LanEvent event = eventBean.getCurrentEvent();
cq.where( cq.where(
cb.equal(root.get(Place_.id), id), cb.equal(root.get(Place_.id), id),
cb.equal(root.get(Place_.map).get(EventMap_.event), eventBean.getCurrentEvent()) cb.or(cb.equal(root.get(Place_.map).get(EventMap_.event), event),
cb.equal(root.get(Place_.product).get(Product_.event), event))
); );
return super.getSingleNullableResult(getEm().createQuery(cq)); return super.getSingleNullableResult(getEm().createQuery(cq));
} }
...@@ -306,18 +309,17 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> { ...@@ -306,18 +309,17 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
subq.where( subq.where(
placeJoin.get(Place_.id).isNotNull(), placeJoin.get(Place_.id).isNotNull(),
cb.equal(placeJoin.get(Place_.map).get(EventMap_.event), eventBean.getCurrentEvent()) cb.equal(placeJoin.get(Place_.map).get(EventMap_.event), eventBean.getCurrentEvent())
); );
ProductFlag[] flags = {ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT}; ProductFlag[] flags = { ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT };
cq.where( cq.where(
cb.or( cb.or(
root.get(Product_.id).in(subq), root.get(Product_.id).in(subq),
root.get(Product_.productFlags).in(Arrays.asList(flags)) root.get(Product_.productFlags).in(Arrays.asList(flags))
), ),
cb.equal(root.get(Product_.event), eventBean.getCurrentEvent()) cb.equal(root.get(Product_.event), eventBean.getCurrentEvent())
); );
cq.orderBy(cb.asc(root.get(Product_.name))); cq.orderBy(cb.asc(root.get(Product_.name)));
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>moya-restpojo</artifactId> <artifactId>moya-restpojo</artifactId>
<groupId>fi.codecrew.moya</groupId> <groupId>fi.codecrew.moya</groupId>
<version>1.0.5</version> <version>1.0.6</version>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!