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 4eb74de6
authored
Jan 10, 2015
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first working version, menus still missing
1 parent
c7abafdc
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
302 additions
and
13 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/ProductBeanLocal.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/ProductBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/PlaceFacade.java
code/moya-database/src/main/java/fi/codecrew/moya/model/GroupMembership.java
code/moya-web/WebContent/info/incoming.xhtml
code/moya-web/WebContent/resources/templates/custom_components.css
code/moya-web/src/main/java/fi/codecrew/moya/web/flow/CardlessIncomingView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/flow/IncomingView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/helpers/ProductSummaryWrapper.java
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n.properties
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/ProductBeanLocal.java
View file @
4eb74de
...
...
@@ -91,4 +91,5 @@ public interface ProductBeanLocal {
AccountEvent
markDelivered
(
AccountEvent
e
,
Calendar
c
);
List
<
Product
>
getPlaceProducts
();
}
code/moya-beans/ejbModule/fi/codecrew/moya/beans/ProductBean.java
View file @
4eb74de
...
...
@@ -570,4 +570,10 @@ public class ProductBean implements ProductBeanLocal {
return
e
;
}
@Override
public
List
<
Product
>
getPlaceProducts
()
{
return
placeFacade
.
getPlaceProducts
();
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/facade/PlaceFacade.java
View file @
4eb74de
...
...
@@ -25,12 +25,9 @@ import javax.ejb.EJB;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.persistence.TypedQuery
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Path
;
import
javax.persistence.criteria.Root
;
import
javax.persistence.criteria.Subquery
;
import
javax.persistence.criteria.*
;
import
fi.codecrew.moya.beans.EventBean
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -54,7 +51,7 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PlaceFacade
.
class
);
@EJB
private
EventBean
Local
eventBean
;
private
EventBean
eventBean
;
@EJB
private
PlaceSlotFacade
placeslotfacade
;
...
...
@@ -281,4 +278,30 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
public
List
<
Product
>
getPlaceProducts
()
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
Product
>
cq
=
cb
.
createQuery
(
Product
.
class
);
Root
<
Product
>
root
=
cq
.
from
(
Product
.
class
);
Subquery
<
Integer
>
subq
=
cq
.
subquery
(
Integer
.
class
);
Root
<
Product
>
subroot
=
subq
.
from
(
Product
.
class
);
subq
.
select
(
subroot
.
get
(
Product_
.
id
));
subq
.
distinct
(
true
);
Join
<
Product
,
Place
>
placeJoin
=
subroot
.
join
(
Product_
.
places
);
subq
.
where
(
placeJoin
.
get
(
Place_
.
id
).
isNotNull
(),
cb
.
equal
(
placeJoin
.
get
(
Place_
.
map
).
get
(
EventMap_
.
event
),
eventBean
.
getCurrentEvent
())
);
cq
.
where
(
root
.
get
(
Product_
.
id
).
in
(
subq
));
cq
.
orderBy
(
cb
.
asc
(
root
.
get
(
Product_
.
name
)));
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
}
code/moya-database/src/main/java/fi/codecrew/moya/model/GroupMembership.java
View file @
4eb74de
...
...
@@ -125,6 +125,11 @@ public class GroupMembership extends GenericEntity {
this
.
placeGroup
=
groupsId
;
}
/**
* When user has selected place from map, it will be put on this.
* @return
*/
public
Place
getPlaceReservation
()
{
return
placeReservation
;
}
...
...
@@ -164,6 +169,12 @@ public class GroupMembership extends GenericEntity {
return
inviteToken
;
}
/**
*
* PlaceProduct is part of membership BEFORE user has selected place.
* @return
*/
public
Product
getPlaceProduct
()
{
return
placeProduct
;
}
...
...
code/moya-web/WebContent/info/incoming.xhtml
View file @
4eb74de
...
...
@@ -12,13 +12,6 @@
</f:metadata>
<ui:define
name=
"content"
>
<h:outputScript
library=
"primefaces"
name=
"jquery/jquery.js"
target=
"head"
/>
<script
type=
"text/javascript"
>
</script>
<reader:backendReader
selectvalue=
"#{i18n['barcodeReader.readBarcode']}"
selectaction=
"#{incomingView.polledRead}"
/>
...
...
code/moya-web/WebContent/resources/templates/custom_components.css
View file @
4eb74de
...
...
@@ -11,6 +11,7 @@
}
.shopItem
{
float
:
left
;
width
:
72px
;
...
...
@@ -236,3 +237,12 @@ a.shopItem:active {
border
:
none
;
padding
:
0
0
1px
0
;
}
.usermultisearch
{
width
:
400px
;
}
.usermultisearch
input
{
width
:
390px
;
}
code/moya-web/src/main/java/fi/codecrew/moya/web/flow/CardlessIncomingView.java
0 → 100644
View file @
4eb74de
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
web
.
flow
;
import
fi.codecrew.moya.beans.*
;
import
fi.codecrew.moya.enums.CardState
;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.model.*
;
import
fi.codecrew.moya.utilities.I18n
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.cdiview.reader.ReaderNameContainer
;
import
fi.codecrew.moya.web.cdiview.reader.ReaderView
;
import
fi.codecrew.moya.web.cdiview.user.UserView
;
import
fi.codecrew.moya.web.helpers.ProductSummaryWrapper
;
import
org.primefaces.event.SelectEvent
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.faces.application.FacesMessage
;
import
javax.faces.context.FacesContext
;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.json.JsonObject
;
import
java.security.acl.Group
;
import
java.util.ArrayList
;
import
java.util.List
;
@Named
@ConversationScoped
public
class
CardlessIncomingView
extends
GenericCDIView
{
private
static
final
long
serialVersionUID
=
-
715517L
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CardlessIncomingView
.
class
);
@Inject
private
ReaderView
readerView
;
@Inject
private
UserView
userview
;
@Inject
private
InfoView
infoView
;
@EJB
private
PlaceGroupBeanLocal
placegroupBean
;
@EJB
private
PlaceBeanLocal
placeBean
;
@EJB
private
ProductBeanLocal
productBean
;
private
ListDataModel
<
GroupMembership
>
memberlist
=
null
;
public
void
polledRead
()
{
ReaderEvent
event
=
readerView
.
getReaderEvent
();
if
(
event
==
null
)
return
;
FacesContext
context
=
FacesContext
.
getCurrentInstance
();
EventUser
user
=
event
.
getUser
();
if
(
user
!=
null
)
{
if
(!
user
.
equals
(
userview
.
getUser
()))
{
userview
.
setUser
(
user
);
super
.
navihandler
.
redirectNavigation
(
"cardlessIncoming.jsf?userid="
+
user
.
getUser
().
getId
());
}
else
{
context
.
addMessage
(
null
,
new
FacesMessage
(
I18n
.
get
(
"incomingflow.alreadyShowingUser.title"
),
I18n
.
get
(
"incomingflow.alreadyShowingUser.message"
)));
}
}
}
public
ListDataModel
<
GroupMembership
>
getGroupMemberships
()
{
memberlist
=
new
ListDataModel
<>(
placegroupBean
.
getMembershipsAndCreations
(
userview
.
getSelectedUser
()));
return
memberlist
;
}
public
void
changeUser
(
SelectEvent
event
)
{
if
(
infoView
.
getMultiSearchUser
()
!=
null
)
{
super
.
navihandler
.
redirectNavigation
(
"incoming.jsf?userid="
+
infoView
.
getMultiSearchUser
().
getUser
().
getId
());
infoView
.
setMultiSearchUser
(
null
);
}
}
public
List
<
ProductSummaryWrapper
>
getPlaceSummaries
()
{
List
<
Product
>
allPlaceProducts
=
productBean
.
getPlaceProducts
();
List
<
GroupMembership
>
groupMemberships
=
placegroupBean
.
getMembershipsAndCreations
(
userview
.
getSelectedUser
());
List
<
ProductSummaryWrapper
>
retarray
=
new
ArrayList
<>();
for
(
Product
p
:
allPlaceProducts
)
{
ProductSummaryWrapper
productSummary
=
new
ProductSummaryWrapper
(
p
);
for
(
GroupMembership
gm
:
groupMemberships
)
{
if
(
p
.
equals
(
gm
.
getPlaceReservation
().
getProduct
()))
{
productSummary
.
addOne
();
if
(
gm
.
getEnteredEvent
()
==
null
)
{
productSummary
.
addOneToLeft
();
}
}
}
retarray
.
add
(
productSummary
);
}
return
retarray
;
}
public
void
givePlace
()
{
GroupMembership
row
=
memberlist
.
getRowData
();
if
(
row
!=
null
)
{
placegroupBean
.
markGrouMembershipEntered
(
row
);
memberlist
=
null
;
}
}
public
void
ungivePlace
()
{
GroupMembership
row
=
memberlist
.
getRowData
();
if
(
row
!=
null
)
{
placegroupBean
.
markGrouMembershipNotEntered
(
row
);
memberlist
=
null
;
}
}
public
void
giveEverything
()
{
List
<
GroupMembership
>
memberships
=
placegroupBean
.
getMembershipsAndCreations
(
userview
.
getSelectedUser
());
for
(
GroupMembership
gm
:
memberships
)
{
if
(
gm
.
getEnteredEvent
()
==
null
)
{
placegroupBean
.
markGrouMembershipEntered
(
gm
);
}
}
memberlist
=
null
;
}
public
boolean
isAllGiven
()
{
return
false
;
}
}
code/moya-web/src/main/java/fi/codecrew/moya/web/flow/IncomingView.java
View file @
4eb74de
...
...
@@ -340,4 +340,6 @@ public class IncomingView extends GenericCDIView {
return
null
;
}
}
code/moya-web/src/main/java/fi/codecrew/moya/web/helpers/ProductSummaryWrapper.java
0 → 100644
View file @
4eb74de
package
fi
.
codecrew
.
moya
.
web
.
helpers
;
import
fi.codecrew.moya.model.Product
;
import
java.math.BigDecimal
;
/**
* Created by tuukka on 10.1.2015.
*/
public
class
ProductSummaryWrapper
{
private
Product
product
;
private
BigDecimal
count
;
private
BigDecimal
left
;
public
ProductSummaryWrapper
(
Product
product
)
{
setProduct
(
product
);
}
public
Product
getProduct
()
{
return
product
;
}
public
void
setProduct
(
Product
product
)
{
this
.
product
=
product
;
}
public
BigDecimal
getCount
()
{
if
(
count
==
null
)
count
=
BigDecimal
.
ZERO
;
return
count
;
}
public
void
setCount
(
BigDecimal
count
)
{
this
.
count
=
count
;
}
public
void
addOne
()
{
setCount
(
getCount
().
add
(
BigDecimal
.
ONE
));
}
public
void
addOneToLeft
()
{
setLeft
(
getLeft
().
add
(
BigDecimal
.
ONE
));
}
public
BigDecimal
getLeft
()
{
if
(
left
==
null
)
left
=
BigDecimal
.
ZERO
;
return
left
;
}
public
void
setLeft
(
BigDecimal
left
)
{
this
.
left
=
left
;
}
}
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n.properties
View file @
4eb74de
...
...
@@ -471,3 +471,7 @@ usercart.showoverview = Vie tarkastusn\u00E4kym\u00E4\u00E4n
viewlectures.title
=
Kurssit ja luennot
yes
=
Kyll
\u
00E4
infoview.multisearch
=
K
\u
00E4ytt
\u
00E4j
\u
00E4haku
incomingflow.placesummary
=
Paikkayhteenveto
incomingFlow.leftCount
=
Noutamatta
incomingFlow.ount
=
M
\u
00E4
\u
00E4r
\u
00E4
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
View file @
4eb74de
...
...
@@ -1693,3 +1693,7 @@ voting.create.voteEnd = Voting close
voting.create.voteStart
=
Voting start
yes
=
Yes
infoview.multisearch
=
Usersearch
incomingflow.placesummary
=
Placesummary
incomingFlow.leftCount
=
Ungiven
incomingFlow.ount
=
Count
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
View file @
4eb74de
...
...
@@ -1676,3 +1676,8 @@ voting.create.voteStart = \u00C4\u00E4nestys auki
yes
=
Kyll
\u
00E4
acc_line.place
=
Paikka
infoview.multisearch
=
K
\u
00E4ytt
\u
00E4j
\u
00E4haku
incomingflow.placesummary
=
Paikkayhteenveto
incomingFlow.leftCount
=
Noutamatta
user.unauthenticated
=
incomingFlow.ount
=
M
\u
00E4
\u
00E4r
\u
00E4
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