public interface Database
chronicle). A client gets one or more Database objects using
DatabaseFactory
.
Five interfaces play an important role in the data model underlying
CrNiCKL:
These interfaces provide read access to the objects.
When writing to the database, read/write versions of the interfaces
are required:
Read/write objects are obtained from the read only objects using the edit()
method.
Two methods are provided for transactions management: commit()
and rollback()
.
These methods are not used internally by CrNiCKL. Managing transactions and implementing
transaction boundaries is the client's responsibility.
Applications control a database using four methods: configure(ch.agent.crnickl.api.DatabaseConfiguration)
, open()
,
close()
, and clear()
. Depending on the implementation, only the first of these
methods is mandatory.
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the internal state of the database.
|
void |
close()
Close the database.
|
void |
commit()
Write all updates since the last commit or rollback to permanent storage.
|
void |
configure(DatabaseConfiguration configuration)
Configure the database.
|
<T> UpdatableProperty<T> |
createProperty(String name,
ValueType<T> valueType,
boolean indexed)
Create a property with the parameters specified.
|
UpdatableSchema |
createSchema(String name,
String nameOfBase)
Create a schema with the parameters specified.
|
<T> UpdatableValueType<T> |
createValueType(String name,
boolean restricted,
String scannerClassOrKeyword)
Create a value type with the parameters specified.
|
Chronicle |
getChronicle(String name,
boolean mustExist)
Return the chronicle with the given full name.
|
Chronicle |
getChronicle(Surrogate surrogate)
Return the chronicle identified by a surrogate.
|
MessageListener |
getMessageListener()
Return the message listener.
|
NamingPolicy |
getNamingPolicy()
Return the naming policy of the database.
|
Collection<Property<?>> |
getProperties(String pattern)
Return properties with names matching a pattern.
|
Property<?> |
getProperty(String name,
boolean mustExist)
Return the property with the given name.
|
Property<?> |
getProperty(Surrogate surrogate)
Return the property identified by a surrogate.
|
Schema |
getSchema(Surrogate surrogate)
Return the schema identified by a surrogate.
|
Collection<Schema> |
getSchemas(String pattern)
Return schemas with names matching a pattern.
|
<T> Series<T> |
getSeries(String name,
boolean mustExist)
Return the series with the given full name.
|
<T> Series<T> |
getSeries(Surrogate surrogate)
Return the series identified by a surrogate.
|
Property<?> |
getSparsityBuiltInProperty()
Return the built-in property for sparsity.
|
Property<?> |
getSymbolBuiltInProperty()
Return the built-in property for symbols.
|
Property<?> |
getTimeDomainBuiltInProperty()
Return the built-in property for time domains.
|
ch.agent.t2.time.TimeDomainCatalog |
getTimeDomainCatalog()
Return the time domain catalog.
|
Chronicle |
getTopChronicle()
Return the top chronicle.
|
Property<?> |
getTypeBuiltInProperty()
Return the built-in property for value types.
|
Collection<UpdatableSchema> |
getUpdatableSchemas(String pattern)
Return updatable schemas with names matching a pattern.
|
<T> UpdatableSeries<T> |
getUpdatableSeries(String name,
boolean mustExist)
Return an updatable series.
|
UpdateEventPublisher |
getUpdateEventPublisher()
Return the event publisher for this database.
|
<T> ValueType<T> |
getValueType(String name)
Return the value type with the given name.
|
<T> ValueType<T> |
getValueType(Surrogate surrogate)
Return the value type identified by a surrogate.
|
Collection<ValueType<?>> |
getValueTypes(String pattern)
Return value types with names matching a pattern.
|
Surrogate |
makeSurrogate(String string)
Return a
Surrogate corresponding to the input. |
void |
open()
Open the database.
|
void |
rollback()
Forget all updates since the last commit or rollback.
|
void |
setMessageListener(MessageListener listener)
Set the message listener used for logging messages.
|
void configure(DatabaseConfiguration configuration) throws T2DBException
configuration
- a database configurationT2DBException
void open() throws T2DBException
configure(ch.agent.crnickl.api.DatabaseConfiguration)
. What the method does depends on the implementation.
On some implementations it is not necessary to invoke the method before
using the database. Depending on the implementation it is possible to
continue using the database after a fatal error by invoking
close()
then open()
.T2DBException
void close() throws T2DBException
close()
then
open()
.T2DBException
void clear() throws T2DBException
T2DBException
void commit() throws T2DBException
T2DBException
void rollback() throws T2DBException
T2DBException
ch.agent.t2.time.TimeDomainCatalog getTimeDomainCatalog()
NamingPolicy getNamingPolicy()
UpdateEventPublisher getUpdateEventPublisher()
void setMessageListener(MessageListener listener)
listener
- a message listener or nullMessageListener getMessageListener()
Level.OFF
.Surrogate makeSurrogate(String string) throws T2DBException
Surrogate
corresponding to the input. The input is
typically a string returned by Surrogate.toString()
. An exception
is thrown if there is a syntax error or if the database of the surrogate
is unknown.string
- a string representation of a surrogateT2DBException
Chronicle getChronicle(Surrogate surrogate) throws T2DBException
surrogate
- a surrogateT2DBException
<T> Series<T> getSeries(Surrogate surrogate) throws T2DBException
surrogate
- a surrogateT2DBException
Schema getSchema(Surrogate surrogate) throws T2DBException
surrogate
- a surrogateT2DBException
Property<?> getProperty(Surrogate surrogate) throws T2DBException
surrogate
- a surrogateT2DBException
<T> ValueType<T> getValueType(Surrogate surrogate) throws T2DBException
surrogate
- a surrogateT2DBException
Chronicle getChronicle(String name, boolean mustExist) throws T2DBException
mustExist
parameter determines behavior when nothing is
found: exception or null result.name
- a full namemustExist
- if true throw an exception instead of returning nullT2DBException
<T> Series<T> getSeries(String name, boolean mustExist) throws T2DBException
mustExist
parameter.T
- the data type of the underlying time seriesname
- a full namemustExist
- if true throw an exception instead of returning nullT2DBException
<T> UpdatableSeries<T> getUpdatableSeries(String name, boolean mustExist) throws T2DBException
mustExist
parameter. If set, the series is created on the
fly, unless something is wrong, in which case an exception is thrown. If
not set the method returns null (unless something is wrong). Something is
wrong when the chronicle does not exist or is not accessible, or when the
series is not defined in the schema.
After a new series has been created, the client must execute
Updatable.applyUpdates()
on the series's chronicle or
on the series itself.
T
- the data type of the underlying time seriesname
- a full namemustExist
- if true throw an exception instead of returning nullT2DBException
Chronicle getTopChronicle()
Collection<Property<?>> getProperties(String pattern) throws T2DBException
pattern
- a name patternT2DBException
Property<?> getProperty(String name, boolean mustExist) throws T2DBException
mustExist
.name
- the name of the propertymustExist
- if true throw an exception instead of returning nullT2DBException
Property<?> getSymbolBuiltInProperty() throws T2DBException
T2DBException
Property<?> getTimeDomainBuiltInProperty() throws T2DBException
T2DBException
Property<?> getTypeBuiltInProperty() throws T2DBException
T2DBException
Property<?> getSparsityBuiltInProperty() throws T2DBException
T2DBException
<T> UpdatableProperty<T> createProperty(String name, ValueType<T> valueType, boolean indexed) throws T2DBException
Updatable.applyUpdates()
on the result.name
- the name of the propertyvalueType
- the value type of the attribute valuesindexed
- true if the property is suitable as a search criterionT2DBException
Collection<Schema> getSchemas(String pattern) throws T2DBException
pattern
- a name patternT2DBException
Collection<UpdatableSchema> getUpdatableSchemas(String pattern) throws T2DBException
pattern
- a name patternT2DBException
UpdatableSchema createSchema(String name, String nameOfBase) throws T2DBException
Updatable.applyUpdates()
on the result.name
- the name of the schemanameOfBase
- the name of the base schema or null if there is no base schemaT2DBException
<T> ValueType<T> getValueType(String name) throws T2DBException
name
- a value type nameT2DBException
Collection<ValueType<?>> getValueTypes(String pattern) throws T2DBException
pattern
- a name patternT2DBException
<T> UpdatableValueType<T> createValueType(String name, boolean restricted, String scannerClassOrKeyword) throws T2DBException
ValueType.StandardValueType
or the name of a class implementing
ValueScanner
. The client must execute
Updatable.applyUpdates()
on the result.name
- the name of the value typerestricted
- true if the value type has a list of allowed valuesscannerClassOrKeyword
- a keyword or the name of a scanner classT2DBException
Copyright © 2017. All rights reserved.