ch.hsr.bieridee.models
Class BreweryModel

java.lang.Object
  extended by ch.hsr.bieridee.models.AbstractModel
      extended by ch.hsr.bieridee.models.BreweryModel

public class BreweryModel
extends AbstractModel

Model to work and persist the brewery object.


Constructor Summary
BreweryModel(long breweryId)
          Creates a BreweryModel by id.
BreweryModel(org.neo4j.graphdb.Node node)
          Creates a BreweryModel by Node.
 
Method Summary
static BreweryModel create(java.lang.String name, java.lang.String description, java.lang.String picture, java.lang.String size)
          Creates a new Brewery and saves it persistent into the database.
static java.util.List<BreweryModel> getAll()
          Gets a list of all breweries as BreweryModels.
static java.util.List<BreweryModel> getAll(int items, int skip)
           
static java.util.List<BreweryModel> getAll(java.lang.String brewerySize)
          Gets a list of BeweryModels filtered by brewerySize.
static java.util.List<BreweryModel> getAll(java.lang.String brewerySize, int items, int skip)
           
 java.lang.String getDescription()
           
 Brewery getDomainObject()
           
 long getId()
           
 java.lang.String getName()
           
 org.neo4j.graphdb.Node getNode()
           
 java.lang.String getPicture()
           
 java.lang.String getSize()
           
static BreweryModel getUnknown()
          Gets the BreweryModel for an unknown brewery.
 boolean isUnknown()
           
 void setDescription(java.lang.String description)
           
 void setId(long id)
           
 void setName(java.lang.String name)
           
 void setPicture(java.lang.String picture)
           
 void setSize(java.lang.String size)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BreweryModel

public BreweryModel(long breweryId)
             throws WrongNodeTypeException,
                    org.neo4j.graphdb.NotFoundException
Creates a BreweryModel by id.

Parameters:
breweryId - The id of the desired brewery
Throws:
WrongNodeTypeException - Thrown when the given id does not reference a brewery node
org.neo4j.graphdb.NotFoundException - Thrown when the given id does not reference an existing node

BreweryModel

public BreweryModel(org.neo4j.graphdb.Node node)
             throws WrongNodeTypeException,
                    org.neo4j.graphdb.NotFoundException
Creates a BreweryModel by Node.

Parameters:
node - the node containing Brewery properties.
Throws:
WrongNodeTypeException - Thrown when the given node is not of type beertype
org.neo4j.graphdb.NotFoundException - Thrown when the given id does not reference an existing node
Method Detail

isUnknown

public boolean isUnknown()

getDomainObject

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

getNode

public org.neo4j.graphdb.Node getNode()
Overrides:
getNode in class AbstractModel

getId

public long getId()

getDescription

public java.lang.String getDescription()

getPicture

public java.lang.String getPicture()

getName

public java.lang.String getName()

getSize

public java.lang.String getSize()

setId

public void setId(long id)

setName

public void setName(java.lang.String name)

setSize

public void setSize(java.lang.String size)

setDescription

public void setDescription(java.lang.String description)

setPicture

public void setPicture(java.lang.String picture)

getAll

public static java.util.List<BreweryModel> getAll()
                                           throws org.neo4j.graphdb.NotFoundException,
                                                  WrongNodeTypeException
Gets a list of all breweries as BreweryModels.

Returns:
The list of BreweryModels
Throws:
org.neo4j.graphdb.NotFoundException - Thrown if a node is not existant
WrongNodeTypeException - Thrown if a node is not of the desired type

getAll

public static java.util.List<BreweryModel> getAll(int items,
                                                  int skip)
                                           throws org.neo4j.graphdb.NotFoundException,
                                                  WrongNodeTypeException
Throws:
org.neo4j.graphdb.NotFoundException
WrongNodeTypeException

getAll

public static java.util.List<BreweryModel> getAll(java.lang.String brewerySize)
                                           throws org.neo4j.graphdb.NotFoundException,
                                                  WrongNodeTypeException
Gets a list of BeweryModels filtered by brewerySize.

Parameters:
brewerySize - The brewerySize
Returns:
The filtered list of BreweryModels
Throws:
org.neo4j.graphdb.NotFoundException - Thrown if a node is not existant
WrongNodeTypeException - Thrown if a node is not of the desired type

getAll

public static java.util.List<BreweryModel> getAll(java.lang.String brewerySize,
                                                  int items,
                                                  int skip)
                                           throws org.neo4j.graphdb.NotFoundException,
                                                  WrongNodeTypeException
Throws:
org.neo4j.graphdb.NotFoundException
WrongNodeTypeException

create

public static BreweryModel create(java.lang.String name,
                                  java.lang.String description,
                                  java.lang.String picture,
                                  java.lang.String size)
Creates a new Brewery and saves it persistent into the database.

Parameters:
name - name of the brewery.
description - text describing the brewery
picture - path to the picture
size - size of the brewery
Returns:
a BreweryModel representing the created brewery.

getUnknown

public static BreweryModel getUnknown()
                               throws org.neo4j.graphdb.NotFoundException,
                                      WrongNodeTypeException
Gets the BreweryModel for an unknown brewery.

Returns:
The mysterious unknown brewery
Throws:
org.neo4j.graphdb.NotFoundException - Thrown if a node is not existant
WrongNodeTypeException - Thrown if a node is not of the desired type