public final class Lookup extends Object
Modifier and Type | Field and Description |
---|---|
(package private) com.google.common.cache.Cache<String,Animal> |
animalsCache |
private Connection |
connection |
private org.jooq.DSLContext |
jooq |
(package private) com.google.common.cache.Cache<String,Location> |
locationsCache |
(package private) com.google.common.cache.Cache<String,Collection<Movement>> |
movementsCache |
(package private) com.google.common.cache.Cache<String,Test> |
testsCache |
Constructor and Description |
---|
Lookup(DatabaseImpl dbFacade)
Create the lookup object for accessing data in the internal databases.
|
Modifier and Type | Method and Description |
---|---|
private Animal |
createAnimal(org.jooq.Record animalRecord)
Create an animal object from the node object defining it in the graph database.
|
private Location |
createLocation(org.jooq.Record locationRecord)
Create a location object from the node object defining it in the graph database.
|
private Movement |
createMovement(org.jooq.Record movementRecord)
Create a movement object from the relationship object defining it in the graph database.
|
private Test |
createTest(org.jooq.Record testRecord)
Create a Test object from the node object defining it in the graph database.
|
Animal |
getAnimal(String animalId)
Get an animal from the list of animals in the system.
|
String |
getAnimalLocationIdAtDate(String animalId,
int date)
Get an animals location at a specified date.
|
Collection<Animal> |
getAnimals()
Get all the animals that have been read from the file(s) specified in the configuration file.
|
Collection<Animal> |
getAnimals(int date)
Get all the animals that have been read from the file(s) specified in the configuration file whose date of birth
is before or on a given date and whose date of death (it there is any) is on or after the same date.
|
Location |
getLocation(String locationId)
Get a location from the list of locations in the system.
|
Collection<Location> |
getLocations()
Get all the movements that have been read from the file(s) specified in the configuration file.
|
Collection<Movement> |
getMovements()
Get all the movements that have been read from the file(s) specified in the configuration file.
|
Collection<Movement> |
getMovements(int startDate,
int endDate)
Get all the movements that have been read from the file(s) specified in the configuration file filtered on a date
range.
|
Collection<Movement> |
getMovementsForAnimal(String animalId)
Get all the recorded movements for a given animal.
|
int |
getNumAnimals()
Get the number of animals stored in the internal database.
|
int |
getNumLocations()
Get the number of locations stored in the internal database.
|
int |
getNumMovements()
Get the number of movements stored in the internal database.
|
int |
getNumMovements(int startDate,
int endDate)
Get the number of movements stored in the internal database filtered on a date range.
|
int |
getNumTests()
Get the number of tests stored in the internal database.
|
Collection<Movement> |
getOffMovements(int startDate,
int endDate)
Get all the OFF movements that have been read from the file(s) specified in the configuration file filtered on a
date range.
|
Collection<Movement> |
getOnMovements(int startDate,
int endDate)
Get all the ON movements that have been read from the file(s) specified in the configuration file filtered on a
date range.
|
Collection<Test> |
getTests()
Get all the tests that have been read from the file(s) specified in the configuration file.
|
Collection<Test> |
getTests(int startDate,
int endDate)
Get all the tests that have been read from the file(s) specified in the configuration file.
|
org.jooq.Result<org.jooq.Record> |
runCustomQuery(String query)
Run a custom query against the database.
|
com.google.common.cache.Cache<String,Collection<Movement>> movementsCache
private org.jooq.DSLContext jooq
private Connection connection
public Lookup(DatabaseImpl dbFacade)
dbFacade
- the object that is responsible for accessing the internal databases.public int getNumTests()
public int getNumAnimals()
public int getNumLocations()
public int getNumMovements()
public int getNumMovements(int startDate, int endDate)
startDate
- the first date in the range with which we will filter the movementsendDate
- the final date in the range with which we will filter the movementspublic Collection<Movement> getMovements()
public Collection<Movement> getMovements(int startDate, int endDate)
startDate
- the first date in the range with which we will filter the movementsendDate
- the final date in the range with which we will filter the movementspublic Collection<Movement> getOffMovements(int startDate, int endDate)
startDate
- the first date in the range with which we will filter the movementsendDate
- the final date in the range with which we will filter the movementspublic Collection<Movement> getOnMovements(int startDate, int endDate)
startDate
- the first date in the range with which we will filter the movementsendDate
- the final date in the range with which we will filter the movementspublic Collection<Test> getTests()
public Collection<Test> getTests(int startDate, int endDate)
startDate
- the first date in the range with which we will filter the tests.endDate
- the final date in the range with which we will filter the tests.public Collection<Animal> getAnimals()
public Collection<Animal> getAnimals(int date)
date
- the date for which we reuqire the animals in the system.public Collection<Location> getLocations()
public Location getLocation(String locationId)
locationId
- the id of the location we are looking for.public Animal getAnimal(String animalId)
animalId
- the id of the animal we are looking for.public Collection<Movement> getMovementsForAnimal(String animalId)
animalId
- the id of the animal whose movements are to be returned.public String getAnimalLocationIdAtDate(String animalId, int date)
animalId
- the id of the animal.date
- the date for which we want the animals location.public org.jooq.Result<org.jooq.Record> runCustomQuery(String query)
query
- the SQL query to be run.private Location createLocation(org.jooq.Record locationRecord)
locationRecord
- the record object from the database defining the location.private Animal createAnimal(org.jooq.Record animalRecord)
animalRecord
- the record object from the database defining the animal.private Test createTest(org.jooq.Record testRecord)
testRecord
- the record object from the database defining the test.private Movement createMovement(org.jooq.Record movementRecord)
movementRecord
- the record object from the database defining the movement.Copyright © 2015 University of Glasgow. All rights reserved.