Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 21035cd4
authored
Nov 18, 2016
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Place moving, etc
1 parent
067ffb02
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
673 additions
and
26 deletions
ProductPojo.java
ProductRestView.java
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/PlaceBeanLocal.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/ApiApplicationFacade.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/PlaceSlotFacade.java
code/moya-web/WebContent/neomap/moveplaces.xhtml
code/moya-web/WebContent/neomap/viewAll.xhtml
code/moya-web/WebContent/resources/seatjs/seatmap.js
code/moya-web/WebContent/shop/shopClosed.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/rest/placemap/v1/EventInfoRestViewV1.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/placemap/v1/PlacechangeRestViewV1.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/UserRestViewV2.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/MapPlacechangeView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
ProductPojo.java
0 → 100644
View file @
21035cd
package
fi
.
codecrew
.
moya
.
rest
.
v2
.
pojo
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
com.wordnik.swagger.annotations.ApiModel
;
import
fi.codecrew.moya.model.Product
;
@XmlRootElement
()
@ApiModel
(
description
=
"Product"
)
public
class
ProductPojo
{
public
Integer
id
;
public
String
description
;
public
BigDecimal
price
;
public
String
name
;
public
static
ProductPojo
convert
(
Product
prod
)
{
ProductPojo
ret
=
new
ProductPojo
();
ret
.
id
=
prod
.
getId
();
ret
.
name
=
prod
.
getName
();
ret
.
price
=
prod
.
getPrice
();
ret
.
description
=
prod
.
getDescription
();
return
ret
;
}
public
static
List
<
ProductPojo
>
convert
(
List
<
Product
>
prods
)
{
ArrayList
<
ProductPojo
>
ret
=
new
ArrayList
<>();
for
(
Product
p
:
prods
)
{
ret
.
add
(
convert
(
p
));
}
return
ret
;
}
}
ProductRestView.java
0 → 100644
View file @
21035cd
package
fi
.
codecrew
.
moya
.
rest
.
v2
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
com.wordnik.swagger.annotations.Api
;
import
fi.codecrew.moya.beans.ProductBeanLocal
;
import
fi.codecrew.moya.rest.v2.pojo.ProductPojo
;
@RequestScoped
@Path
(
"/v2/product"
)
@Api
(
value
=
"/v2/product"
,
description
=
"Product operations"
)
public
class
ProductRestView
{
@EJB
private
ProductBeanLocal
prodbean
;
@GET
@Path
(
"/all"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
Response
getAllProducts
()
{
List
<
ProductPojo
>
ret
=
ProductPojo
.
convert
(
prodbean
.
findProductsForEvent
());
return
Response
.
ok
(
ret
).
build
();
}
}
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/PlaceBeanLocal.java
View file @
21035cd
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
javax.ejb.Local
;
import
javax.ejb.Local
;
...
@@ -153,4 +154,6 @@ public interface PlaceBeanLocal {
...
@@ -153,4 +154,6 @@ public interface PlaceBeanLocal {
*/
*/
boolean
isUnlockedPlaces
(
EventUser
user
);
boolean
isUnlockedPlaces
(
EventUser
user
);
void
movePlaces
(
HashMap
<
Place
,
Place
>
change
);
}
}
\ No newline at end of file
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
View file @
21035cd
...
@@ -143,8 +143,7 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -143,8 +143,7 @@ public class PlaceBean implements PlaceBeanLocal {
@Override
@Override
/** Use place slots */
/** Use place slots */
@Deprecated
@Deprecated
public
BigDecimal
getTotalReservationPrice
(
Place
newPlace
)
public
BigDecimal
getTotalReservationPrice
(
Place
newPlace
)
{
{
return
addAndCalcPrice
(
permbean
.
getCurrentUser
(),
newPlace
);
return
addAndCalcPrice
(
permbean
.
getCurrentUser
(),
newPlace
);
}
}
...
@@ -152,8 +151,7 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -152,8 +151,7 @@ public class PlaceBean implements PlaceBeanLocal {
@Override
@Override
/** Use place slots */
/** Use place slots */
@Deprecated
@Deprecated
public
BigDecimal
getTotalReservationPrice
(
EventUser
user
,
Place
newPlace
)
public
BigDecimal
getTotalReservationPrice
(
EventUser
user
,
Place
newPlace
)
{
{
return
addAndCalcPrice
(
user
,
newPlace
);
return
addAndCalcPrice
(
user
,
newPlace
);
}
}
...
@@ -493,10 +491,14 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -493,10 +491,14 @@ public class PlaceBean implements PlaceBeanLocal {
@RolesAllowed
({
MapPermission
.
S_BUY_PLACES
,
MapPermission
.
S_MANAGE_OTHERS
})
@RolesAllowed
({
MapPermission
.
S_BUY_PLACES
,
MapPermission
.
S_MANAGE_OTHERS
})
public
boolean
releasePlace
(
Place
place
)
{
public
boolean
releasePlace
(
Place
place
)
{
place
=
placeFacade
.
reload
(
place
);
place
=
placeFacade
.
reload
(
place
);
EventUser
user
=
permbean
.
getCurrentUser
();
return
releasePlacePriv
(
place
)
!=
null
;
}
if
(
place
.
getGroup
()
!=
null
||
(!
permbean
.
hasPermission
(
MapPermission
.
MANAGE_OTHERS
)
&&
!
place
.
getCurrentUser
().
equals
(
user
)))
{
private
PlaceSlot
releasePlacePriv
(
Place
place
)
{
return
false
;
EventUser
user
=
permbean
.
getCurrentUser
();
if
(
place
.
getGroup
()
!=
null
||
place
.
getCurrentUser
()
==
null
||
(!
permbean
.
hasPermission
(
MapPermission
.
MANAGE_OTHERS
)
&&
!
place
.
getCurrentUser
().
equals
(
user
)))
{
return
null
;
}
}
place
.
setCurrentUser
(
null
);
place
.
setCurrentUser
(
null
);
...
@@ -507,9 +509,7 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -507,9 +509,7 @@ public class PlaceBean implements PlaceBeanLocal {
slot
.
setPlace
(
null
);
slot
.
setPlace
(
null
);
slot
.
setUsed
(
null
);
slot
.
setUsed
(
null
);
}
}
return
slot
;
return
true
;
}
}
@Override
@Override
...
@@ -544,8 +544,7 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -544,8 +544,7 @@ public class PlaceBean implements PlaceBeanLocal {
place
.
setCurrentUser
(
null
);
place
.
setCurrentUser
(
null
);
place
.
setReserveTime
(
null
);
place
.
setReserveTime
(
null
);
if
(
place
.
getPlaceReserver
()
!=
null
)
if
(
place
.
getPlaceReserver
()
!=
null
)
{
{
GroupMembership
res
=
place
.
getPlaceReserver
();
GroupMembership
res
=
place
.
getPlaceReserver
();
if
(
res
.
getPlaceGroup
().
getMembers
()
!=
null
)
{
if
(
res
.
getPlaceGroup
().
getMembers
()
!=
null
)
{
...
@@ -821,18 +820,49 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -821,18 +820,49 @@ public class PlaceBean implements PlaceBeanLocal {
return
ret
;
return
ret
;
}
}
@Override
public
boolean
isUnlockedPlaces
(
EventUser
user
)
{
List
<
Place
>
places
=
placeFacade
.
findUsersReservations
(
user
.
getEvent
(),
user
);
for
(
Place
p
:
places
)
{
if
(
p
.
isReservedFor
(
user
))
{
return
true
;
}
}
return
false
;
}
/**
* Allow user to move their places around.
*/
@Override
@Override
public
boolean
isUnlockedPlaces
(
EventUser
user
)
{
public
void
movePlaces
(
HashMap
<
Place
,
Place
>
change
)
{
List
<
Place
>
places
=
placeFacade
.
findUsersReservations
(
user
.
getEvent
(),
user
);
EventUser
user
=
permbean
.
getCurrentUser
();
boolean
manageOthers
=
permbean
.
hasPermission
(
MapPermission
.
MANAGE_OTHERS
);
for
(
Place
p
:
places
)
{
for
(
Entry
<
Place
,
Place
>
s
:
change
.
entrySet
())
{
if
(
p
.
isReservedFor
(
user
))
{
Place
src
=
placeFacade
.
reload
(
s
.
getKey
());
return
true
;
if
(!
manageOthers
&&
!
user
.
equals
(
src
.
getCurrentUser
())
}
&&
(
src
.
getGroup
()
==
null
||
!
user
.
equals
(
src
.
getGroup
().
getCreator
())))
{
}
throw
new
EJBAccessException
(
"Trying to move places for another user without permissions!"
);
}
Place
dst
=
placeFacade
.
reload
(
s
.
getValue
());
if
(!
dst
.
isBuyable
()
||
dst
.
isTaken
())
{
throw
new
EJBException
(
"Place already taken!!"
);
}
PlaceSlot
srcSlot
=
releasePlacePriv
(
src
);
if
(
srcSlot
!=
null
)
{
// this place was reserved via a slot...
srcSlot
.
setPlace
(
dst
);
srcSlot
.
setUsed
(
new
Date
());
}
return
false
;
dst
.
setCurrentUser
(
user
);
}
dst
.
setReserveTime
(
Calendar
.
getInstance
());
}
}
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/facade/ApiApplicationFacade.java
View file @
21035cd
...
@@ -40,7 +40,6 @@ public class ApiApplicationFacade extends IntegerPkGenericFacade<ApiApplication>
...
@@ -40,7 +40,6 @@ public class ApiApplicationFacade extends IntegerPkGenericFacade<ApiApplication>
}
}
@EJB
public
ApiApplication
findByAppid
(
String
appId
)
{
public
ApiApplication
findByAppid
(
String
appId
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
ApiApplication
>
q
=
cb
.
createQuery
(
ApiApplication
.
class
);
CriteriaQuery
<
ApiApplication
>
q
=
cb
.
createQuery
(
ApiApplication
.
class
);
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/facade/PlaceSlotFacade.java
View file @
21035cd
...
@@ -109,6 +109,7 @@ public class PlaceSlotFacade extends IntegerPkGenericFacade<PlaceSlot> {
...
@@ -109,6 +109,7 @@ public class PlaceSlotFacade extends IntegerPkGenericFacade<PlaceSlot> {
CriteriaQuery
<
PlaceSlot
>
q
=
cb
.
createQuery
(
PlaceSlot
.
class
);
CriteriaQuery
<
PlaceSlot
>
q
=
cb
.
createQuery
(
PlaceSlot
.
class
);
Root
<
PlaceSlot
>
root
=
q
.
from
(
PlaceSlot
.
class
);
Root
<
PlaceSlot
>
root
=
q
.
from
(
PlaceSlot
.
class
);
Path
<
Bill
>
bill
=
root
.
get
(
PlaceSlot_
.
bill
);
Path
<
Bill
>
bill
=
root
.
get
(
PlaceSlot_
.
bill
);
q
.
where
(
cb
.
equal
(
bill
.
get
(
Bill_
.
user
),
user
),
q
.
where
(
cb
.
equal
(
bill
.
get
(
Bill_
.
user
),
user
),
cb
.
isNotNull
(
bill
.
get
(
Bill_
.
paidDate
)));
cb
.
isNotNull
(
bill
.
get
(
Bill_
.
paidDate
)));
...
...
code/moya-web/WebContent/neomap/moveplaces.xhtml
0 → 100644
View file @
21035cd
<!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"
xmlns:f=
"http://java.sun.com/jsf/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"
xmlns:p=
"http://primefaces.org/ui"
>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{mapPlacechangeView.initView()}"
/>
</f:metadata>
<ui:define
name=
"content"
>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"d3.min.js"
/>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"d3-tip.js"
/>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"seatmap.js"
/>
<h:outputStylesheet
library=
"seatjs"
name=
"placemap.css"
/>
<!-- Place slot count -->
<h3>
<h:outputText
value=
"#{i18n['mapView.yourPlaces']}"
/>
</h3>
<p:fragment
id=
"placeselector"
>
<h:form>
<p:dataTable
id=
"slottable"
tableStyle=
"width: auto;"
var=
"slot"
value=
"#{mapPlacechangeView.slots}"
>
<!-- rowStyleClass="#{mapPlacechangeView.srcPlace.contains(slot.place) ? 'selected' : 'unselected'}" -->
<p:column
headerText=
"#{i18n['mapView.productcount.productname']}"
>
<h:outputText
value=
"#{slot.src.product.name}"
/>
</p:column>
<p:column
headerText=
"#{i18n['mapView.productcount.unused']}"
>
<h:outputText
renderer=
"#{!empty slot.src.place}"
value=
"#{slot.src.place.name}"
/>
</p:column>
<p:column
headerText=
"#{i18n['mapView.productcount.selected']}"
>
<h:outputText
renderer=
"#{!empty slot.moving}"
value=
"#{slot.moving}"
/>
</p:column>
<p:column
headerText=
"#{i18n['mapView.productcount.selected']}"
>
<h:outputText
renderer=
"#{!empty slot.dst}"
value=
"#{slot.dst.name}"
/>
</p:column>
<p:column>
<ui:fragment
rendered=
"#{empty slot.dst}"
>
<p:commandButton
actionListener=
"#{mapPlacechangeView.selectSlot}"
rendered=
"#{!slot.isMoving()}"
value=
"#{i18n['placemove.selectSlotForMove']}"
update=
"placeselector"
/>
<p:commandButton
actionListener=
"#{mapPlacechangeView.unselectSlot}"
rendered=
"#{slot.moving}"
value=
"#{i18n['placemove.deselect']}"
update=
"placeselector"
/>
</ui:fragment>
</p:column>
</p:dataTable>
</h:form>
<script
type=
"text/javascript"
>
toggleSuccess
=
#
{
mapPlacechangeView
.
toggleSuccess
};
</script>
</p:fragment>
<h:form
id=
"placemove"
>
<p:commandButton
rendered=
"#{ajaxMapView.canUserBuy()}"
value=
"#{i18n['mapPlacechange.commitMove']}"
actionListener=
"#{mapPlacechangeView.commitMove()}"
/>
</h:form>
<svg
id=
"seatmap"
style=
"margin: auto; border: 1px solid black;"
width=
"#{ajaxMapView.map.width}px"
height=
"#{ajaxMapView.map.height}px"
/>
<h:form>
<p:remoteCommand
name=
"toggleDstPlace"
action=
"#{mapPlacechangeView.toggleDstPlace()}"
update=
"placeselector"
oncomplete=
"afterToggle()"
></p:remoteCommand>
</h:form>
<script
type=
"text/javascript"
>
// <![CDATA[
px
=
placemap
({
element
:
document
.
getElementById
(
"seatmap"
),
moyaurl
:
"#{request.contextPath}"
,
map_id
:
#
{
ajaxMapView
.
map
.
id
},
});
px
.
toggleaction
=
function
(
d
){
latestPlace
=
d
;
toggleDstPlace
([{
name
:
"placeId"
,
value
:
d
.
id
}
])
};
function
afterToggle
(){
if
(
toggleSuccess
){
if
(
latestPlace
.
state
===
"F"
){
latestPlace
.
state
=
"T"
;
}
else
{
latestPlace
.
state
=
"F"
;
}
px
.
update_placeobj
([
latestPlace
]);
}
}
// ]]>
</script>
<map:legend
/>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/moya-web/WebContent/neomap/viewAll.xhtml
0 → 100644
View file @
21035cd
<!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"
xmlns:f=
"http://java.sun.com/jsf/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"
xmlns:p=
"http://primefaces.org/ui"
>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{ajaxMapView.initViewMap()}"
/>
</f:metadata>
<ui:param
name=
"thispage"
value=
"page.place.placemap"
/>
<ui:define
name=
"content"
>
<!-- <h:form>
<p:remoteCommand name="placeClicker" update=":fbdiag"
action="#{ajaxMapView.placeClicked()}" />
</h:form>
-->
<p:dialog
rendered=
"#{ajaxMapView.isMgmtPermission()}"
visible=
"#{!empty ajaxMapView.place}"
id=
"fbdiag"
>
Clicked place name : #{ajaxMapView.place.name};
<h:link
rendered=
"#{!empty ajaxMapView.place}"
outcome=
"/place/edit"
>
<f:param
name=
"placeid"
value=
"#{ajaxMapView.place.id}"
/>
Muokkaa
</h:link>
</p:dialog>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"d3.min.js"
/>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"d3-tip.js"
/>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"seatmap.js"
/>
<h:outputStylesheet
library=
"seatjs"
name=
"placemap.css"
/>
<ui:fragment
rendered=
"#{not ajaxMapView.queueEnabled}"
>
<div
style=
"margin: 5px;"
>
<h:form
id=
"placeselectform"
>
<p:commandButton
rendered=
"#{ajaxMapView.canUserBuy()}"
value=
"#{i18n['mapView.buyPlaces']}"
action=
"#{ajaxMapView.buySelectedPlaces()}"
ajax=
"false"
/>
</h:form>
</div>
</ui:fragment>
<button
onclick=
"px.update()"
>
#{i18n['neomap.updateMap']}
</button>
<br
/>
<svg
id=
"seatmap"
style=
"margin: auto; border: 1px solid black;"
width=
"#{ajaxMapView.map.width}px"
height=
"#{ajaxMapView.map.height}px"
/>
<script
type=
"text/javascript"
>
// If queue is enabled, do not allow clicking of places.
px
=
placemap
({
element
:
document
.
getElementById
(
"seatmap"
),
moyaurl
:
"#{request.contextPath}"
,
map_id
:
#
{
ajaxMapView
.
map
.
id
},
placeurl
:
"/rest/placemap/v1/#{ajaxMapView.map.id}/allplaces"
,
});
px
.
toggleaction
=
#
{
ajaxMapView
.
queueEnabled
?
'undefined'
:
'px.toggle_place'
};
</script>
<map:legend
/>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/moya-web/WebContent/resources/seatjs/seatmap.js
View file @
21035cd
...
@@ -438,6 +438,10 @@ function placemap(opts)
...
@@ -438,6 +438,10 @@ function placemap(opts)
}
}
};
};
px
.
update_placeobj
=
function
(
d
)
{
draw_places
(
d
,
false
);
}
px
.
update_place
=
function
(
place_id
)
px
.
update_place
=
function
(
place_id
)
{
{
if
(
place_id
===
undefined
)
place_id
=
px
.
clicked_place
;
if
(
place_id
===
undefined
)
place_id
=
px
.
clicked_place
;
...
...
code/moya-web/WebContent/shop/shopClosed.xhtml
0 → 100644
View file @
21035cd
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"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"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:p=
"http://primefaces.org/ui"
>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
</f:metadata>
<ui:define
name=
"title"
>
<h1>
#{i18n['page.product.shopClosed.header']}
</h1>
</ui:define>
<ui:define
name=
"content"
>
Shop Closed!!
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/moya-web/src/main/java/fi/codecrew/moya/rest/placemap/v1/EventInfoRestViewV1.java
0 → 100644
View file @
21035cd
package
fi
.
codecrew
.
moya
.
rest
.
placemap
.
v1
;
import
javax.enterprise.context.RequestScoped
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.core.MediaType
;
@RequestScoped
@Path
(
"/placemap/v1"
)
@Consumes
({
MediaType
.
APPLICATION_JSON
})
@Produces
({
MediaType
.
APPLICATION_JSON
+
"; charset=UTF-8"
})
public
class
EventInfoRestViewV1
{
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/placemap/v1/PlacechangeRestViewV1.java
0 → 100644
View file @
21035cd
package
fi
.
codecrew
.
moya
.
rest
.
placemap
.
v1
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Inject
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.POST
;
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
javax.ws.rs.core.Response.ResponseBuilder
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.BarcodeBeanLocal
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PlaceBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
import
fi.codecrew.moya.beans.map.QueueBeanLocal
;
import
fi.codecrew.moya.enums.apps.MapPermission
;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.model.EventMap
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.Place
;
import
fi.codecrew.moya.rest.PojoUtils
;
import
fi.codecrew.moya.rest.pojo.placemap.v1.IntegerRoot
;
import
fi.codecrew.moya.rest.pojo.placemap.v1.PlacemapMapRootPojo
;
import
fi.codecrew.moya.rest.pojo.placemap.v1.SimplePlacePojo
;
import
fi.codecrew.moya.rest.pojo.placemap.v1.SimplePlacelistRoot
;
import
fi.codecrew.moya.utilities.PasswordFunctions
;
import
fi.codecrew.moya.web.cdiview.map.MapPlacechangeView
;
import
fi.codecrew.moya.web.cdiview.map.MapPlacechangeView.MoveContainer
;
import
fi.codecrew.moya.web.cdiview.user.UserView
;
@RequestScoped
@Path
(
"/placemove/v1"
)
@Consumes
({
MediaType
.
APPLICATION_JSON
})
@Produces
({
MediaType
.
APPLICATION_JSON
+
"; charset=UTF-8"
})
public
class
PlacechangeRestViewV1
{
@Inject
private
MapPlacechangeView
placechangeView
;
@EJB
private
PermissionBeanLocal
permbean
;
@GET
@Path
(
"/destinations"
)
public
SimplePlacelistRoot
getDestinations
()
{
List
<
Place
>
dsts
=
new
ArrayList
<>();
for
(
MoveContainer
mc
:
placechangeView
.
getMoveContainers
())
{
dsts
.
add
(
mc
.
getDst
());
}
SimplePlacelistRoot
ret
=
PojoUtils
.
parseSimplePlaces
(
dsts
,
permbean
.
getCurrentUser
(),
false
);
for
(
SimplePlacePojo
p
:
ret
.
getPlaces
())
{
p
.
setState
(
"T"
);
}
return
ret
;
}
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/UserRestViewV2.java
View file @
21035cd
...
@@ -48,7 +48,7 @@ public class UserRestViewV2 {
...
@@ -48,7 +48,7 @@ public class UserRestViewV2 {
PojoFactoryV2
pojoFactory
;
PojoFactoryV2
pojoFactory
;
@GET
@GET
@Path
(
"/"
)
@Path
(
"/
get
"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@ApiOperation
(
value
=
"Find user"
,
response
=
UserPojo
.
class
)
@ApiOperation
(
value
=
"Find user"
,
response
=
UserPojo
.
class
)
public
Response
getEventUser
(
@QueryParam
(
"email"
)
@ApiParam
(
"Email address"
)
String
email
,
public
Response
getEventUser
(
@QueryParam
(
"email"
)
@ApiParam
(
"Email address"
)
String
email
,
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/MapPlacechangeView.java
0 → 100644
View file @
21035cd
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
map
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.faces.context.FacesContext
;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Named
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.PlaceBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
import
fi.codecrew.moya.enums.apps.MapPermission
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Place
;
import
fi.codecrew.moya.model.PlaceSlot
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
@Named
@ConversationScoped
public
class
MapPlacechangeView
extends
GenericCDIView
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MapPlacechangeView
.
class
);
private
static
final
long
serialVersionUID
=
1L
;
private
Integer
userId
;
private
EventUser
user
;
@EJB
private
UserBeanLocal
userbean
;
@EJB
private
PlaceBeanLocal
placebean
;
private
ListDataModel
<
MoveContainer
>
slots
;
private
List
<
MoveContainer
>
moveContainers
;
private
boolean
toggleSuccess
;
public
static
class
MoveContainer
{
private
boolean
moving
=
false
;
private
final
PlaceSlot
src
;
private
Place
dst
;
public
MoveContainer
(
PlaceSlot
p
)
{
this
.
src
=
p
;
}
public
static
List
<
MoveContainer
>
init
(
List
<
PlaceSlot
>
placeslots
)
{
ArrayList
<
MoveContainer
>
ret
=
new
ArrayList
<>();
for
(
PlaceSlot
p
:
placeslots
)
{
ret
.
add
(
new
MoveContainer
(
p
));
}
return
ret
;
}
public
boolean
isMoving
()
{
return
moving
;
}
public
void
setMoving
(
boolean
moving
)
{
this
.
moving
=
moving
;
}
public
Place
getDst
()
{
return
dst
;
}
public
void
setDst
(
Place
dst
)
{
this
.
dst
=
dst
;
}
public
PlaceSlot
getSrc
()
{
return
src
;
}
}
public
void
initView
()
{
// If we are overriding user, check permission.
if
(
getSlots
()
==
null
)
{
if
(
userId
!=
null
&&
super
.
requirePermissions
(
MapPermission
.
MANAGE_OTHERS
))
{
user
=
userbean
.
findByUserId
(
userId
,
false
);
}
else
if
(
super
.
requirePermissions
(
MapPermission
.
BUY_PLACES
))
{
user
=
permbean
.
getCurrentUser
();
}
else
{
return
;
}
super
.
beginConversation
();
moveContainers
=
MoveContainer
.
init
(
placebean
.
getPlaceslots
(
user
));
slots
=
new
ListDataModel
<
MoveContainer
>(
moveContainers
);
}
}
public
void
commitMove
(){
HashMap
<
Place
,
Place
>
change
=
new
HashMap
<
Place
,
Place
>();
for
(
MoveContainer
s
:
slots
){
if
(
s
.
isMoving
()
&&
s
.
getDst
()
!=
null
){
change
.
put
(
s
.
getSrc
().
getPlace
(),
s
.
getDst
());
}
}
placebean
.
movePlaces
(
change
);
}
public
void
toggleDstPlace
()
{
Map
<
String
,
String
>
paramMap
=
FacesContext
.
getCurrentInstance
().
getExternalContext
().
getRequestParameterMap
();
Integer
placeId
=
new
Integer
(
paramMap
.
get
(
"placeId"
));
Place
place
=
placebean
.
find
(
placeId
);
setToggleSuccess
(
false
);
for
(
MoveContainer
mc
:
getMoveContainers
())
{
if
(
place
.
equals
(
mc
.
getSrc
().
getPlace
()))
{
setSlotState
(
mc
,
!
mc
.
isMoving
());
return
;
}
if
(
place
.
equals
(
mc
.
getDst
()))
{
setToggleSuccess
(
true
);
mc
.
setDst
(
null
);
return
;
}
}
if
(!
place
.
isBuyable
()
||
place
.
isTaken
())
{
return
;
}
for
(
MoveContainer
mc
:
moveContainers
)
{
if
(
mc
.
isMoving
()
&&
mc
.
dst
==
null
&&
mc
.
getSrc
().
getProduct
().
equals
(
place
.
getProduct
()))
{
setToggleSuccess
(
true
);
mc
.
setDst
(
place
);
return
;
}
}
}
public
String
selectSlot
()
{
setSlotState
(
slots
.
getRowData
(),
true
);
return
null
;
}
private
void
setSlotState
(
MoveContainer
mc
,
boolean
moving
)
{
if
(!
moving
&&
mc
.
getDst
()
!=
null
)
{
return
;
}
mc
.
setMoving
(
moving
);
}
public
String
unselectSlot
()
{
setSlotState
(
getSlots
().
getRowData
(),
false
);
return
null
;
}
public
Integer
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
public
EventUser
getUser
()
{
return
user
;
}
public
void
setUser
(
EventUser
user
)
{
this
.
user
=
user
;
}
public
List
<
MoveContainer
>
getMoveContainers
()
{
return
moveContainers
;
}
public
void
setMoveContainers
(
List
<
MoveContainer
>
moveContainers
)
{
this
.
moveContainers
=
moveContainers
;
}
public
ListDataModel
<
MoveContainer
>
getSlots
()
{
return
slots
;
}
public
void
setSlots
(
ListDataModel
<
MoveContainer
>
slots
)
{
this
.
slots
=
slots
;
}
public
boolean
isToggleSuccess
()
{
return
toggleSuccess
;
}
public
void
setToggleSuccess
(
boolean
toggleSuccess
)
{
this
.
toggleSuccess
=
toggleSuccess
;
}
}
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
View file @
21035cd
...
@@ -20,6 +20,7 @@ package fi.codecrew.moya.web.cdiview.shop;
...
@@ -20,6 +20,7 @@ package fi.codecrew.moya.web.cdiview.shop;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
...
@@ -27,6 +28,8 @@ import java.util.Map;
...
@@ -27,6 +28,8 @@ import java.util.Map;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.faces.application.NavigationHandler
;
import
javax.faces.context.FacesContext
;
import
javax.faces.model.ListDataModel
;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.inject.Named
;
...
@@ -41,6 +44,7 @@ import fi.codecrew.moya.beans.UserBeanLocal;
...
@@ -41,6 +44,7 @@ import fi.codecrew.moya.beans.UserBeanLocal;
import
fi.codecrew.moya.enums.apps.ShopPermission
;
import
fi.codecrew.moya.enums.apps.ShopPermission
;
import
fi.codecrew.moya.model.Bill
;
import
fi.codecrew.moya.model.Bill
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LanEventProperty
;
import
fi.codecrew.moya.model.LanEventProperty
;
import
fi.codecrew.moya.model.LanEventPropertyKey
;
import
fi.codecrew.moya.model.LanEventPropertyKey
;
import
fi.codecrew.moya.model.Product
;
import
fi.codecrew.moya.model.Product
;
...
@@ -118,7 +122,19 @@ public class ProductShopView extends GenericCDIView {
...
@@ -118,7 +122,19 @@ public class ProductShopView extends GenericCDIView {
public
void
initBillView
()
{
public
void
initBillView
()
{
if
(
requirePermissions
(
ShopPermission
.
LIST_USERPRODUCTS
)
&&
shoppingcart
==
null
)
{
if
(
requirePermissions
(
ShopPermission
.
LIST_USERPRODUCTS
)
&&
shoppingcart
==
null
)
{
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productList
(
productBean
.
listUserShoppableProducts
(),
userView
.
getSelectedUser
()));
LanEvent
event
=
eventbean
.
getCurrentEvent
();
Date
now
=
new
Date
();
if
((
event
.
getTicketSalesBegin
()
!=
null
&&
now
.
before
(
event
.
getTicketSalesBegin
()))
||
(
event
.
getEndTime
()
!=
null
&&
now
.
after
(
event
.
getEndTime
())))
{
FacesContext
fc
=
FacesContext
.
getCurrentInstance
();
NavigationHandler
nh
=
fc
.
getApplication
().
getNavigationHandler
();
nh
.
handleNavigation
(
fc
,
null
,
"/shop/shopClosed?faces-redirect=true"
);
return
;
}
shoppingcart
=
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productList
(
productBean
.
listUserShoppableProducts
(),
userView
.
getSelectedUser
()));
for
(
ProductShopItem
item
:
shoppingcart
)
{
for
(
ProductShopItem
item
:
shoppingcart
)
{
psiHelper
.
updateProductShopItemCount
(
item
);
psiHelper
.
updateProductShopItemCount
(
item
);
...
@@ -301,8 +317,7 @@ public class ProductShopView extends GenericCDIView {
...
@@ -301,8 +317,7 @@ public class ProductShopView extends GenericCDIView {
ret
=
ret
.
add
(
getCash
());
ret
=
ret
.
add
(
getCash
());
ret
=
ret
.
subtract
(
getCartPrice
());
ret
=
ret
.
subtract
(
getCartPrice
());
logger
.
info
(
"User accountbalance {}, cash{}, total {}. retBalance {}"
,
logger
.
info
(
"User accountbalance {}, cash{}, total {}. retBalance {}"
,
new
Object
[]
{
userView
.
getSelectedUser
().
getAccountBalance
(),
getCash
(),
new
Object
[]
{
userView
.
getSelectedUser
().
getAccountBalance
(),
getCash
(),
getCartPrice
(),
ret
});
getCartPrice
(),
ret
});
return
ret
;
return
ret
;
}
}
...
@@ -320,6 +335,10 @@ public class ProductShopView extends GenericCDIView {
...
@@ -320,6 +335,10 @@ public class ProductShopView extends GenericCDIView {
}
}
public
String
commitBillCart
()
{
public
String
commitBillCart
()
{
for
(
ProductShopItem
i
:
shoppingcart
){
psiHelper
.
updateProductShopItemCount
(
i
);
}
updateAllCartLimits
();
updateAllCartLimits
();
logger
.
debug
(
"Committing billCart"
);
logger
.
debug
(
"Committing billCart"
);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment