ch.hsr.bieridee.models
Class RatingModel

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

public class RatingModel
extends AbstractActionModel

Model to work with and persist the User object.


Constructor Summary
RatingModel(org.neo4j.graphdb.Node node)
          Creates a UserModel, consisting from a User domain object and the corresponding Node.
 
Method Summary
static RatingModel create(int value, BeerModel beerModel, UserModel userModel)
          Creates a new user and returns a new UserModel for it.
static java.util.List<RatingModel> createModelsFromNodes(java.util.List<org.neo4j.graphdb.Node> ratingNodes)
          Creates RatingModels from ratingnodes.
static RatingModel getCurrent(BeerModel beerModel, UserModel userModel)
          Gets the active rating for the given user and the given beer.
 Rating getDomainObject()
           
 int getRating()
           
 void setDate(java.util.Date d)
           
 void setRating(int rating)
           
 
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, toString, wait, wait, wait
 

Constructor Detail

RatingModel

public RatingModel(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 be found
WrongNodeTypeException - Thrown if the given node is not of type user
Method Detail

getDomainObject

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

setDate

public void setDate(java.util.Date d)

setRating

public void setRating(int rating)

getRating

public int getRating()

create

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

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

getCurrent

public static RatingModel getCurrent(BeerModel beerModel,
                                     UserModel userModel)
                              throws org.neo4j.graphdb.NotFoundException,
                                     WrongNodeTypeException
Gets the active rating for the given user and the given beer.

Parameters:
beerModel - The beermodel
userModel - The usermodel
Returns:
The active rating
Throws:
org.neo4j.graphdb.NotFoundException - Thrown if the given node can not be found
WrongNodeTypeException - Thrown if the given node is not of type user

createModelsFromNodes

public static java.util.List<RatingModel> createModelsFromNodes(java.util.List<org.neo4j.graphdb.Node> ratingNodes)
                                                         throws org.neo4j.graphdb.NotFoundException,
                                                                WrongNodeTypeException
Creates RatingModels from ratingnodes.

Parameters:
ratingNodes - The nodes
Returns:
A list of RatingModels
Throws:
org.neo4j.graphdb.NotFoundException - Thrown if the given node can not be found
WrongNodeTypeException - Thrown if the given node is not of type user