ch.hsr.bieridee.models
Class ConsumptionModel

java.lang.Object
  extended by ch.hsr.bieridee.models.AbstractModel
      extended by ch.hsr.bieridee.models.AbstractActionModel
          extended by ch.hsr.bieridee.models.ConsumptionModel

public class ConsumptionModel
extends AbstractActionModel

Model to work with and persist the User object.


Constructor Summary
ConsumptionModel(org.neo4j.graphdb.Node node)
          Creates a UserModel, consisting from a User domain object and the corresponding Node.
 
Method Summary
static ConsumptionModel create(BeerModel beerModel, UserModel userModel)
          Creates a new user and returns a new UserModel for it.
static java.util.List<ConsumptionModel> getAll(long beerId)
          Gets all consumptions for the given beer.
static java.util.List<ConsumptionModel> getAll(long beerId, java.lang.String username)
          Gets all consumptions of a specific user for the given beer.
 Consumption getDomainObject()
           
 void setDate(java.util.Date d)
           
 java.lang.String toString()
           
 
Methods inherited from class ch.hsr.bieridee.models.AbstractActionModel
getBeer, getDate, getSecondsAgo, getType, getUser
 
Methods inherited from class ch.hsr.bieridee.models.AbstractModel
getNode
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConsumptionModel

public ConsumptionModel(org.neo4j.graphdb.Node node)
                 throws org.neo4j.graphdb.NotFoundException,
                        WrongNodeTypeException
Creates a UserModel, consisting from a User domain object and the corresponding Node.

Parameters:
node - Ratingnode
Throws:
org.neo4j.graphdb.NotFoundException - Thrown if the given node can not been found
WrongNodeTypeException - Thrown if the given node is not of type user
Method Detail

getDomainObject

public Consumption getDomainObject()
Specified by:
getDomainObject in class AbstractModel

setDate

public void setDate(java.util.Date d)

create

public static ConsumptionModel create(BeerModel beerModel,
                                      UserModel userModel)
Creates a new user and returns a new UserModel for it.

Parameters:
beerModel - The BeerModel.
userModel - The UserModel.
Returns:
The UserModel containing the new user node and the user domain object

getAll

public static java.util.List<ConsumptionModel> getAll(long beerId)
                                               throws org.neo4j.graphdb.NotFoundException,
                                                      WrongNodeTypeException
Gets all consumptions for the given beer.

Parameters:
beerId - The beer to be filterd with
Returns:
A list of ConsumptionModels for the given beer
Throws:
org.neo4j.graphdb.NotFoundException - Thrown if a node could not be found
WrongNodeTypeException - Thronw if a node has the wrong type

getAll

public static java.util.List<ConsumptionModel> getAll(long beerId,
                                                      java.lang.String username)
                                               throws org.neo4j.graphdb.NotFoundException,
                                                      WrongNodeTypeException
Gets all consumptions of a specific user for the given beer.

Parameters:
beerId - The beer to be filterd with
username - The drinker
Returns:
List of ConsumptionModels for the user and the beer
Throws:
org.neo4j.graphdb.NotFoundException - Thrown if a node could not be found
WrongNodeTypeException - Thronw if a node has the wrong type

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object