Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
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 c98a3433
authored
Dec 20, 2015
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Product rest functions
1 parent
89cff9f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/ProductRestView.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/ProductPojo.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/ProductRestView.java
0 → 100644
View file @
c98a343
package
fi
.
codecrew
.
moya
.
rest
.
v2
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
com.wordnik.swagger.annotations.Api
;
import
fi.codecrew.moya.beans.ProductBeanLocal
;
import
fi.codecrew.moya.rest.v2.pojo.ProductPojo
;
@RequestScoped
@Path
(
"/v2/product"
)
@Api
(
value
=
"/v2/user"
,
description
=
"Product operations"
)
public
class
ProductRestView
{
@EJB
private
ProductBeanLocal
prodbean
;
@GET
@Path
(
"/all"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
Response
getAllProducts
()
{
List
<
ProductPojo
>
ret
=
ProductPojo
.
convert
(
prodbean
.
findProductsForEvent
());
return
Response
.
ok
(
ret
).
build
();
}
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/ProductPojo.java
0 → 100644
View file @
c98a343
package
fi
.
codecrew
.
moya
.
rest
.
v2
.
pojo
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
com.wordnik.swagger.annotations.ApiModel
;
import
fi.codecrew.moya.model.Product
;
/**
* Created by jkj on 2015-05-31.
*/
@XmlRootElement
()
@ApiModel
(
description
=
"Product"
)
public
class
ProductPojo
{
public
Integer
id
;
public
String
description
;
public
BigDecimal
price
;
public
String
name
;
public
static
ProductPojo
convert
(
Product
prod
)
{
ProductPojo
ret
=
new
ProductPojo
();
ret
.
id
=
prod
.
getId
();
ret
.
name
=
prod
.
getName
();
ret
.
price
=
prod
.
getPrice
();
ret
.
description
=
prod
.
getDescription
();
return
ret
;
}
public
static
List
<
ProductPojo
>
convert
(
List
<
Product
>
prods
)
{
ArrayList
<
ProductPojo
>
ret
=
new
ArrayList
<>();
for
(
Product
p
:
prods
)
{
ret
.
add
(
convert
(
p
));
}
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