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 8f96083b
authored
Nov 08, 2014
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial version of placemap rest api
1 parent
608b617d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
154 additions
and
0 deletions
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/placemap/v1/PlacemapRestViewV1.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/pojo/placemap/SimplePlacePojo.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/pojo/placemap/SimplePlacelistRoot.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
View file @
8f96083
This diff is collapsed.
Click to expand it.
code/moya-web/src/main/java/fi/codecrew/moya/rest/placemap/v1/PlacemapRestViewV1.java
0 → 100644
View file @
8f96083
package
fi
.
codecrew
.
moya
.
rest
.
placemap
.
v1
;
import
java.util.ArrayList
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.core.MediaType
;
import
fi.codecrew.moya.beans.PlaceBeanLocal
;
import
fi.codecrew.moya.model.EventMap
;
import
fi.codecrew.moya.model.Place
;
import
fi.codecrew.moya.rest.pojo.placemap.SimplePlacePojo
;
import
fi.codecrew.moya.rest.pojo.placemap.SimplePlacelistRoot
;
@RequestScoped
@Path
(
"/placemap/v1"
)
@Consumes
({
MediaType
.
APPLICATION_JSON
})
@Produces
({
MediaType
.
APPLICATION_JSON
+
"; charset=UTF-8"
})
public
class
PlacemapRestViewV1
{
@EJB
private
PlaceBeanLocal
placebean
;
@GET
@Path
(
"{id}/places"
)
public
SimplePlacelistRoot
getPlaces
(
@PathParam
(
"id"
)
Integer
mapId
)
{
EventMap
map
=
placebean
.
findMap
(
mapId
);
return
SimplePlacelistRoot
.
wrap
(
map
.
getPlaces
(),
null
);
}
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/pojo/placemap/SimplePlacePojo.java
0 → 100644
View file @
8f96083
package
fi
.
codecrew
.
moya
.
rest
.
pojo
.
placemap
;
import
javax.xml.bind.annotation.XmlElement
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Place
;
public
class
SimplePlacePojo
{
private
Place
place
;
private
EventUser
user
;
public
SimplePlacePojo
(
Place
place
,
EventUser
user
)
{
super
();
this
.
place
=
place
;
this
.
user
=
user
;
}
public
SimplePlacePojo
()
{
super
();
}
@XmlElement
(
name
=
"id"
)
public
Integer
getId
()
{
return
place
.
getId
();
}
@XmlElement
(
name
=
"name"
)
public
String
getName
()
{
return
place
.
getName
();
}
@XmlElement
(
name
=
"state"
)
public
String
getState
()
{
String
ret
=
null
;
switch
(
place
.
getState
(
user
))
{
case
DISABLED:
ret
=
"D"
;
break
;
case
FREE:
ret
=
"F"
;
break
;
case
LOCKED:
ret
=
"L"
;
break
;
case
MY_PLACE:
ret
=
"P"
;
break
;
case
RESERVED:
ret
=
"R"
;
break
;
case
TEMP_RESERVED_FORME:
ret
=
"T"
;
break
;
default
:
break
;
}
return
ret
;
}
@XmlElement
(
name
=
"x"
)
public
Integer
getX
()
{
return
place
.
getMapX
();
}
@XmlElement
(
name
=
"y"
)
public
Integer
getY
()
{
return
place
.
getMapY
();
}
@XmlElement
(
name
=
"w"
)
public
Integer
getWidth
()
{
return
place
.
getWidth
();
}
@XmlElement
(
name
=
"h"
)
public
Integer
getHeight
()
{
return
place
.
getHeight
();
}
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/pojo/placemap/SimplePlacelistRoot.java
0 → 100644
View file @
8f96083
package
fi
.
codecrew
.
moya
.
rest
.
pojo
.
placemap
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Place
;
@XmlRootElement
public
class
SimplePlacelistRoot
{
private
List
<
SimplePlacePojo
>
places
;
public
List
<
SimplePlacePojo
>
getPlaces
()
{
return
places
;
}
public
void
setPlaces
(
List
<
SimplePlacePojo
>
places
)
{
this
.
places
=
places
;
}
public
static
SimplePlacelistRoot
wrap
(
List
<
Place
>
places
,
EventUser
user
)
{
SimplePlacelistRoot
ret
=
new
SimplePlacelistRoot
();
ArrayList
<
SimplePlacePojo
>
placeList
=
new
ArrayList
<
SimplePlacePojo
>();
ret
.
setPlaces
(
placeList
);
for
(
Place
p
:
places
)
{
placeList
.
add
(
new
SimplePlacePojo
(
p
,
user
));
}
return
ret
;
}
}
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