public class PetStoreService extends AbstractPersistenceService
Uses JPA persistence to store and retrieve PetStore DTOs.
JPA beans are defined in
Constructor and Description |
---|
PetStoreService() |
Modifier and Type | Method and Description |
---|---|
Order |
create(CreateOrder c)
Creates a new order in the database.
|
Pet |
create(CreatePet c)
Creates a new pet in the database.
|
User |
create(User c)
Creates a new user in the database.
|
Map<PetStatus,Integer> |
getInventory()
Returns a summary of pet statuses and counts.
|
Order |
getOrder(long id)
Returns the order with the specified ID.
|
List<Order> |
getOrders()
Returns all orders in the database.
|
Pet |
getPet(long id)
Returns the pet with the specified ID.
|
List<Pet> |
getPets()
Returns all pets in the database.
|
Collection<Pet> |
getPetsByStatus(PetStatus[] status)
Returns all pets with the specified statuses.
|
Collection<Pet> |
getPetsByTags(String[] tags)
Returns all pets with the specified tags.
|
User |
getUser(String username)
Returns the user with the specified username.
|
List<User> |
getUsers()
Returns all users in the database.
|
PetStoreService |
initDirect(PrintWriter w)
Initialize the petstore database using JPA.
|
PetStoreService |
initViaRest(PrintWriter w)
Initialize the petstore database by using a remote resource interface against our REST.
|
boolean |
isValid(String username,
String password)
Returns
|
void |
removeOrder(long id)
Removes an order from the database.
|
void |
removePet(long id)
Removes a pet from the database.
|
void |
removeUser(String username)
Removes a user from the database.
|
Order |
update(Order o)
Updates an order in the database.
|
Pet |
update(UpdatePet u)
Updates a pet in the database.
|
User |
update(User u)
Updates a user in the database.
|
public PetStoreService()
public PetStoreService initDirect(PrintWriter w) throws ParseException, IOException
w
- Console output.ParseException
- Malformed input encountered.IOException
- File could not be read from file system.public PetStoreService initViaRest(PrintWriter w) throws ParseException, IOException
w
- Console output.ParseException
- Malformed input encountered.IOException
- Thrown by client stream.public Pet getPet(long id) throws IdNotFound
id
- The pet ID.IdNotFound
- If pet was not found.public Order getOrder(long id) throws IdNotFound
id
- The order ID.IdNotFound
- If order was not found.public User getUser(String username) throws InvalidUsername, IdNotFound
username
- The username.InvalidUsername
- Username was not valid.IdNotFound
- If order was not found.public List<Pet> getPets()
public List<Order> getOrders()
public List<User> getUsers()
public Pet create(CreatePet c)
c
- The pet input data.Pet
object.public Order create(CreateOrder c)
c
- The order input data.Order
object.public User create(User c)
c
- The user input data.User
object.public Pet update(UpdatePet u) throws IdNotFound
u
- The update information.Pet
object.IdNotFound
- Pet was not found.public Order update(Order o) throws IdNotFound
o
- The update information.Order
object.IdNotFound
- Order was not found.public User update(User u) throws IdNotFound, InvalidUsername
u
- The update information.User
object.IdNotFound
- User was not found.InvalidUsername
- The username was not valid.public void removePet(long id) throws IdNotFound
id
- The pet ID.IdNotFound
- Pet was not found.public void removeOrder(long id) throws IdNotFound
id
- The order ID.IdNotFound
- Order was not found.public void removeUser(String username) throws IdNotFound
username
- The username.IdNotFound
- User was not found.public Collection<Pet> getPetsByStatus(PetStatus[] status)
status
- Pet statuses.public Collection<Pet> getPetsByTags(String[] tags) throws InvalidTag
tags
- Pet tags.InvalidTag
- Tag name was invalid.public Map<PetStatus,Integer> getInventory()
Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.