Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
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 19e1d46e
authored
Jan 10, 2015
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add /user/{userid}/reservations rest api
1 parent
7bfb72c8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
code/moya-web/pom.xml
code/moya-web/src/main/java/fi/codecrew/moya/rest/UserRestView.java
code/moya-web/pom.xml
View file @
19e1d46
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
<dependency>
<dependency>
<groupId>
fi.codecrew.moya
</groupId>
<groupId>
fi.codecrew.moya
</groupId>
<artifactId>
moya-restpojo
</artifactId>
<artifactId>
moya-restpojo
</artifactId>
<version>
${moya.version}
</version>
<version>
1.0.2
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
<parent>
<parent>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/UserRestView.java
View file @
19e1d46
...
@@ -19,10 +19,9 @@
...
@@ -19,10 +19,9 @@
package
fi
.
codecrew
.
moya
.
rest
;
package
fi
.
codecrew
.
moya
.
rest
;
import
java.security.Principal
;
import
java.security.Principal
;
import
java.util.List
;
import
javax.annotation.Resource
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.ejb.SessionContext
;
import
javax.enterprise.context.RequestScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -41,17 +40,20 @@ import javax.ws.rs.core.Response;
...
@@ -41,17 +40,20 @@ import javax.ws.rs.core.Response;
import
javax.ws.rs.core.Response.ResponseBuilder
;
import
javax.ws.rs.core.Response.ResponseBuilder
;
import
javax.ws.rs.core.Response.Status
;
import
javax.ws.rs.core.Response.Status
;
import
org.apache.http.HttpRequest
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.CardTemplateBeanLocal
;
import
fi.codecrew.moya.beans.CardTemplateBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PlaceGroupBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.GroupMembership
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo
;
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.PrintedCardRestPojo
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.SimpleEventuserRoot
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.SimpleEventuserRoot
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.UserReservationPlacePojo
;
import
fi.codecrew.moya.rest.pojo.userinfo.v1.UserReservationRoot
;
import
fi.codecrew.moya.util.UserSearchQuery
;
import
fi.codecrew.moya.util.UserSearchQuery
;
import
fi.codecrew.moya.utilities.SearchQuery.QuerySortOrder
;
import
fi.codecrew.moya.utilities.SearchQuery.QuerySortOrder
;
import
fi.codecrew.moya.utilities.SearchResult
;
import
fi.codecrew.moya.utilities.SearchResult
;
...
@@ -76,6 +78,27 @@ public class UserRestView {
...
@@ -76,6 +78,27 @@ public class UserRestView {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserRestView
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserRestView
.
class
);
@EJB
private
PlaceGroupBeanLocal
placegroupbean
;
@GET
@Path
(
"/{userid}/reservations"
)
public
Response
usersPlaces
(
@QueryParam
(
"userid"
)
Integer
userid
)
{
EventUser
eu
=
userbean
.
findByUserId
(
userid
,
false
);
if
(
eu
!=
null
)
{
List
<
GroupMembership
>
gms
=
placegroupbean
.
getMemberships
(
eu
);
UserReservationRoot
ret
=
new
UserReservationRoot
();
for
(
GroupMembership
g
:
gms
)
{
UserReservationPlacePojo
ur
=
new
UserReservationPlacePojo
();
ur
.
setPlaceid
(
g
.
getPlaceReservation
().
getId
());
ur
.
setPlacegiven
(
g
.
getEnteredEvent
()
!=
null
);
ur
.
setPlacename
(
g
.
getPlaceReservation
().
getName
());
}
return
Response
.
ok
(
ret
).
build
();
}
return
Response
.
status
(
Status
.
NOT_FOUND
).
build
();
}
@POST
@POST
@Path
(
"/auth"
)
@Path
(
"/auth"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
@Produces
({
MediaType
.
APPLICATION_JSON
})
...
...
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