Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e908f55b
authored
Jan 26, 2015
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add rest functions for giving out places
1 parent
b5eedaea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
code/moya-web/src/main/java/fi/codecrew/moya/rest/UserRestView.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/UserRestView.java
View file @
e908f55
...
...
@@ -50,12 +50,14 @@ import com.wordnik.swagger.annotations.ApiParam;
import
fi.codecrew.moya.beans.CardTemplateBeanLocal
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PlaceBeanLocal
;
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.Place
;
import
fi.codecrew.moya.model.ReaderEvent
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardRestPojo
;
...
...
@@ -95,6 +97,50 @@ public class UserRestView {
@EJB
private
TicketBeanLocal
ticketbean
;
@EJB
private
PlaceBeanLocal
placebean
;
@POST
@Path
(
"/giveplace/{placeId}"
)
public
Response
setPlacesGivenStatus
(
@PathParam
(
"placeId"
)
Integer
id
,
@FormParam
(
"action"
)
String
status
)
{
Place
place
=
placebean
.
find
(
id
);
if
(
place
==
null
)
{
ResponseBuilder
resp
=
Response
.
status
(
Status
.
BAD_REQUEST
);
resp
.
entity
(
"Place not found with id: "
+
id
);
return
resp
.
build
();
}
GroupMembership
gm
=
place
.
getPlaceReserver
();
if
(
gm
==
null
)
{
ResponseBuilder
resp
=
Response
.
status
(
Status
.
BAD_REQUEST
);
resp
.
entity
(
"No group membership for place: "
+
id
);
return
resp
.
build
();
}
ResponseBuilder
resp
=
Response
.
ok
();
switch
(
status
)
{
case
"give"
:
gm
=
placegroupbean
.
markGroupMembershipEntered
(
gm
);
break
;
case
"ungive"
:
gm
=
placegroupbean
.
markGroupMembershipNotEntered
(
gm
);
break
;
default
:
resp
=
Response
.
status
(
Status
.
BAD_REQUEST
);
resp
.
status
(
Status
.
BAD_REQUEST
);
resp
.
entity
(
"Unknown status"
+
status
+
" possible values: 'give' and 'ungive'"
);
return
resp
.
build
();
}
resp
.
entity
(
PojoUtils
.
initUserReservationPlace
(
gm
));
return
resp
.
build
();
}
@GET
@Path
(
"/reservationswithcode/{code}"
)
public
Response
getPlacesWithCode
(
@PathParam
(
"code"
)
String
code
)
{
...
...
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