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 3e8ab32c
authored
Jan 11, 2015
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add rest for fetching user and users places with barcode
1 parent
baf69018
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
7 deletions
code/moya-restpojo/pom.xml
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/userinfo/v1/UserReservationRoot.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/UserRestView.java
code/moya-restpojo/pom.xml
View file @
3e8ab32
...
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
moya-restpojo
</artifactId>
<groupId>
fi.codecrew.moya
</groupId>
<version>
1.0.
3
</version>
<version>
1.0.
4
</version>
<build>
<plugins>
<plugin>
...
...
code/moya-restpojo/src/main/java/fi/codecrew/moya/rest/pojo/userinfo/v1/UserReservationRoot.java
View file @
3e8ab32
...
...
@@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
()
public
class
UserReservationRoot
{
private
EventUserRestPojo
user
;
private
List
<
UserReservationPlacePojo
>
reservations
=
new
ArrayList
<
UserReservationPlacePojo
>();
public
UserReservationRoot
()
{
...
...
@@ -40,6 +41,12 @@ public class UserReservationRoot {
this
.
reservations
=
reservations
;
}
public
EventUserRestPojo
getUser
()
{
return
user
;
}
public
void
setUser
(
EventUserRestPojo
user
)
{
this
.
user
=
user
;
}
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/UserRestView.java
View file @
3e8ab32
...
...
@@ -51,11 +51,12 @@ import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PlaceGroupBeanLocal
;
import
fi.codecrew.moya.beans.ReaderBeanLocal
;
import
fi.codecrew.moya.beans.TicketBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.GroupMembership
;
import
fi.codecrew.moya.model.
LanEventPropertyKey
;
import
fi.codecrew.moya.model.
ReaderEvent
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardRestPojo
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.SimpleEventuserRoot
;
...
...
@@ -90,22 +91,47 @@ public class UserRestView {
private
PlaceGroupBeanLocal
placegroupbean
;
@EJB
private
ReaderBeanLocal
readerbean
;
@EJB
private
TicketBeanLocal
ticketbean
;
@POST
@GET
@Path
(
"/reservationswithcode/{code}"
)
public
Response
getPlacesWithCode
(
@PathParam
(
"code"
)
String
code
)
{
EventUser
curruser
=
permbean
.
getCurrentUser
();
ReaderEvent
revent
=
readerbean
.
checkCode
(
"restapi: "
+
curruser
.
getLogin
(),
code
);
if
(
revent
!=
null
&&
revent
.
getUser
()
!=
null
)
{
EventUser
eu
=
revent
.
getUser
();
List
<
GroupMembership
>
gms
=
ticketbean
.
findMembershipPrintlistForUser
(
eu
);
UserReservationRoot
ret
=
new
UserReservationRoot
();
ret
.
setUser
(
PojoUtils
.
initEventUserRestPojo
(
eu
));
for
(
GroupMembership
g
:
gms
)
{
UserReservationPlacePojo
ur
=
new
UserReservationPlacePojo
();
ur
.
setPlaceid
(
g
.
getPlaceReservation
().
getId
());
ur
.
setPlacegiven
(
g
.
getEnteredEvent
()
!=
null
);
ur
.
setPlacename
(
g
.
getPlaceReservation
().
getName
());
ret
.
getReservations
().
add
(
ur
);
}
return
Response
.
ok
(
ret
).
build
();
}
return
Response
.
status
(
Status
.
NOT_FOUND
).
build
();
}
@GET
@Path
(
"/{userid}/reservations"
)
public
Response
usersPlaces
(
@PathParam
(
"userid"
)
Integer
userid
)
{
logger
.
info
(
"user {} is trying to fetch user {}"
,
permbean
.
getCurrentUser
().
getLogin
(),
userid
);
EventUser
eu
=
userbean
.
findByUserId
(
userid
,
false
);
logger
.
info
(
"Trying to fetch reservations for user {}, with useid {}"
,
eu
,
userid
);
if
(
eu
!=
null
)
{
List
<
GroupMembership
>
gms
=
ticketbean
.
findMembershipPrintlistForUser
(
eu
);
UserReservationRoot
ret
=
new
UserReservationRoot
();
logger
.
info
(
"Got membersips {}"
,
gms
);
ret
.
setUser
(
PojoUtils
.
initEventUserRestPojo
(
eu
)
);
for
(
GroupMembership
g
:
gms
)
{
UserReservationPlacePojo
ur
=
new
UserReservationPlacePojo
();
...
...
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