ch.agent.crnickl.jdbc
Class ReadMethodsForChroniclesAndSeries

java.lang.Object
  extended by ch.agent.crnickl.impl.DatabaseMethodsImpl
      extended by ch.agent.crnickl.jdbc.JDBCDatabaseMethods
          extended by ch.agent.crnickl.jdbc.ReadMethodsForChroniclesAndSeries
All Implemented Interfaces:
ch.agent.crnickl.impl.DatabaseMethods, ch.agent.crnickl.impl.PermissionChecker
Direct Known Subclasses:
WriteMethodsForChroniclesAndSeries

public class ReadMethodsForChroniclesAndSeries
extends JDBCDatabaseMethods

A stateless object with methods providing read access to chronicles and series.

Author:
Jean-Paul Vetterli

Constructor Summary
ReadMethodsForChroniclesAndSeries()
           
 
Method Summary
 boolean getAttributeValue(List<ch.agent.crnickl.api.Chronicle> chronicles, ch.agent.crnickl.api.Attribute<?> attribute)
          The method completes the attribute with the value found for one of the entities in the list and returns true.
 ch.agent.crnickl.api.Chronicle getChronicle(ch.agent.crnickl.api.Surrogate surrogate)
          Find a chronicle corresponding to a surrogate.
 ch.agent.crnickl.api.Chronicle getChronicleOrNull(ch.agent.crnickl.api.Chronicle parent, String name)
          Find a chronicle with a given parent and name.
<T> List<ch.agent.crnickl.api.Chronicle>
getChroniclesByAttributeValue(ch.agent.crnickl.api.Property<T> property, T value, int maxSize)
          Return a list of chronicles with a given value for a given property.
 Collection<ch.agent.crnickl.api.Chronicle> getChroniclesByParent(ch.agent.crnickl.api.Chronicle parent)
          Return the collection of chronicles with a given direct parent.
<T> ch.agent.crnickl.api.Series<T>[]
getSeries(ch.agent.crnickl.api.Chronicle chronicle, String[] names, int[] numbers)
          Return array of series in the positions corresponding to the requested numbers.
<T> ch.agent.crnickl.api.Series<T>
getSeries(ch.agent.crnickl.api.Surrogate surrogate)
          Find a series corresponding to a surrogate.
 
Methods inherited from class ch.agent.crnickl.jdbc.JDBCDatabaseMethods
close, executeAndGetNewId, getId, getId, getIdOrZero, makeSurrogate, open, open, open
 
Methods inherited from class ch.agent.crnickl.impl.DatabaseMethodsImpl
check, check, check, check, checkIntegrity, makeSurrogate, makeSurrogate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadMethodsForChroniclesAndSeries

public ReadMethodsForChroniclesAndSeries()
Method Detail

getChronicle

public ch.agent.crnickl.api.Chronicle getChronicle(ch.agent.crnickl.api.Surrogate surrogate)
                                            throws ch.agent.crnickl.T2DBException
Find a chronicle corresponding to a surrogate. An exception is thrown if there is no such chronicle.

Parameters:
surrogate - a surrogate
Returns:
a chronicle, never null
Throws:
ch.agent.crnickl.T2DBException

getChronicleOrNull

public ch.agent.crnickl.api.Chronicle getChronicleOrNull(ch.agent.crnickl.api.Chronicle parent,
                                                         String name)
                                                  throws ch.agent.crnickl.T2DBException
Find a chronicle with a given parent and name.

Parameters:
parent - a chronicle
name - a string
Returns:
a chronicle or null
Throws:
ch.agent.crnickl.T2DBException

getChroniclesByParent

public Collection<ch.agent.crnickl.api.Chronicle> getChroniclesByParent(ch.agent.crnickl.api.Chronicle parent)
                                                                 throws ch.agent.crnickl.T2DBException
Return the collection of chronicles with a given direct parent.

Parameters:
parent - a chronicle
Returns:
a collection of chronicles, possibly empty, never null
Throws:
ch.agent.crnickl.T2DBException

getAttributeValue

public boolean getAttributeValue(List<ch.agent.crnickl.api.Chronicle> chronicles,
                                 ch.agent.crnickl.api.Attribute<?> attribute)
                          throws ch.agent.crnickl.T2DBException
The method completes the attribute with the value found for one of the entities in the list and returns true. If no value was found, the method return false. If more than value was found, the one selected corresponds to the first entity encountered in the list.

Parameters:
chronicles - a list of chronicles
attribute - an attribute
Returns:
true if any value found
Throws:
ch.agent.crnickl.T2DBException

getChroniclesByAttributeValue

public <T> List<ch.agent.crnickl.api.Chronicle> getChroniclesByAttributeValue(ch.agent.crnickl.api.Property<T> property,
                                                                              T value,
                                                                              int maxSize)
                                                                   throws ch.agent.crnickl.T2DBException
Return a list of chronicles with a given value for a given property.

Parameters:
property - a property
value - a value
maxSize - the maximum size of the result or 0 for no limit
Returns:
a list of chronicles, possibly empty, never null
Throws:
ch.agent.crnickl.T2DBException

getSeries

public <T> ch.agent.crnickl.api.Series<T> getSeries(ch.agent.crnickl.api.Surrogate surrogate)
                                         throws ch.agent.crnickl.T2DBException
Find a series corresponding to a surrogate.

Parameters:
surrogate - a surrogate
Returns:
a series or null
Throws:
ch.agent.crnickl.T2DBException

getSeries

public <T> ch.agent.crnickl.api.Series<T>[] getSeries(ch.agent.crnickl.api.Chronicle chronicle,
                                                      String[] names,
                                                      int[] numbers)
                                           throws ch.agent.crnickl.T2DBException
Return array of series in the positions corresponding to the requested numbers. These numbers are series numbers within the schema, not the series keys in the database. When a requested number in the array is non-positive, the corresponding series will be null in the result. A series can also be null when the requested number is positive but the series has no data and has not been set up in the database (and therefore has no series database key).

Parameters:
chronicle - a chronicle
names - an array of simple names to plug into the series
numbers - an array of numbers
Returns:
an array of series
Throws:
ch.agent.crnickl.T2DBException


Copyright © 2013. All Rights Reserved.