public abstract class SourceConnector
extends java.lang.Object
implements java.io.Serializable
A connector to a source of items and triples.
Each source is identified by a unique long integer.
Positive integers are used for private sources, negative integers are used for shared sources, and zero is used for the virtual source containing special items.
There is a maximum and a minimum value set for source numbers. All integers outside this range are reserved to be allocated uses at a future time.
Within a source, each item is identified by a unique reference that is a long integer, and each triple is identified by a unique reference that is a long integer. These are the numeric identifiers of the items and triples within their sources. (The identifier spaces are separate. An item and a triple can have the same numeric identifier.)
Modifier and Type | Class and Description |
---|---|
class |
SourceConnector.IdAndTrans
Numeric item identifier and transaction returned when an item is added
|
Modifier and Type | Field and Description |
---|---|
static long |
adminLevelItemNr
The numeric identifier of the item that represents
the administration access level of the source.
|
static long |
adminLevelTripleNr
The numeric identifier of the triple that defines
the administration access level of the source.
|
static long |
sourceItemNr
The numeric identifier of the source item.
|
Modifier and Type | Method and Description |
---|---|
abstract SourceConnector.IdAndTrans |
addItem(Id onlyReadLevelId,
Id readOrWriteLevelId)
Add an item
|
SourceConnector.IdAndTrans |
addSourceItem(Id onlyReadLevelId,
Id readOrWriteLevelId)
Add an item if the source connector is operational.
|
abstract void |
close()
Close the source connector
|
abstract void |
create()
Create the source.
|
StoredTriple |
createSourceTriple(Item subject,
Item verb,
Datum object,
Transaction trans)
Create a triple if the source connector is operational.
|
abstract StoredTriple |
createTriple(Item subject,
Item verb,
Datum object,
Transaction trans)
Create a triple
|
void |
endSourceTransaction(Transaction trans)
End a transaction if the source connector is operational.
|
abstract void |
endTransaction(Transaction trans)
End a transaction.
|
abstract Datum |
getBinaryTripleObject(long tripleNr)
Get a stored triple's binary object
|
SourceConnectorClient |
getClient() |
java.io.File |
getLocalDir() |
Datum |
getSourceBinaryTripleObject(long tripleNr)
Get a stored triple's binary object if the source connector is operational.
|
long |
getSourceNr() |
Datum |
getSourceTextTripleObject(long tripleNr)
Get a stored triple's text object if the source connector is operational.
|
java.io.File |
getSpecFile() |
java.lang.String |
getSpecFilePath() |
abstract java.lang.Exception |
getTerminator()
Return an exception that caused connector operation to abort.
|
abstract Datum |
getTextTripleObject(long tripleNr)
Get a stored triple's text object
|
static boolean |
isDomainSourceNr(long nr)
Determine whether a source number is that of a
domain source
|
static boolean |
isInstallationSourceNr(long nr)
Determine whether a source number is that of an
installation-specific source
|
boolean |
isOperational() |
boolean |
isOwner() |
static boolean |
isRegisteredSourceNr(long nr)
Determine whether a source number is that of a
registered source
|
abstract void |
load()
Load items and triples into a triple store from the connector,
but without adding the items to the triple store's index.
|
void |
log(java.lang.String message)
Create a log entry
|
void |
makeOperational()
Make the connector operational
|
abstract void |
removeItem(long itemNr,
Transaction trans)
Remove an item from the source
|
void |
removeSourceItem(long itemNr,
Transaction trans)
Remove an item from the source if the source connector is operational.
|
void |
removeSourceTriple(long tripleNr,
Transaction trans)
Note that a triple is removed from the source if the source
connector is operational.
|
abstract void |
removeTriple(long tripleNr,
Transaction trans)
Note that a triple is removed from the source.
|
StoredTriple |
replaceSourceTriple(Triple triple,
Datum newObject,
Transaction trans)
Replace a triple in the source by a new triple with the
same subject and verb, but with a new object and a new
numeric identifier, if the source connector is operational.
|
abstract StoredTriple |
replaceTriple(Triple triple,
Datum newObject,
Transaction trans)
Replace a triple in the source by a new triple with the
same subject and verb, but with a new object and a new
numeric identifier
|
abstract void |
simulateIoError()
Simulate an I/O error for testing purposes
|
abstract boolean |
sourceExists()
Determine whether the source exists or must be created.
|
Transaction |
startSourceTransaction()
Start a new transaction if the source connector is operational.
|
abstract Transaction |
startTransaction()
Start a new transaction.
|
void |
stopOperation()
Stop operation of the source connector
|
abstract void |
updateItem(long itemNr,
Id onlyReadLevelId,
Id readOrWriteLevelId,
Transaction trans)
Update an item in the source
|
void |
updateSourceItem(long itemNr,
Id onlyReadLevelId,
Id readOrWriteLevelId,
Transaction trans)
Update an item in the source if the source connector is operational.
|
public static final long sourceItemNr
public static final long adminLevelItemNr
public static final long adminLevelTripleNr
public static boolean isInstallationSourceNr(long nr)
nr
- a source numberpublic static boolean isDomainSourceNr(long nr)
nr
- a source numberpublic static boolean isRegisteredSourceNr(long nr)
nr
- a source numberjava.io.IOException
public SourceConnectorClient getClient()
public long getSourceNr()
public boolean isOwner()
public java.io.File getLocalDir()
public java.io.File getSpecFile()
public java.lang.String getSpecFilePath() throws java.io.IOException
java.io.IOException
public boolean isOperational()
public void makeOperational()
public abstract boolean sourceExists() throws SourceConnectorException
SourceConnectorException
public abstract void create() throws SourceConnectorException, TripleStoreNonFatalException
Create the source.
A new source is created.
A source must be created, or loaded, but not both, before it can be used.
A source is created with a source item and a source administration access level. The only-read level of the source item is the lowest access level, and its read-or-write level is the highest access level.The only-read level of the source administration access level is the lowest access level, and it is its own read-or-write level.
public abstract void load() throws SourceConnectorException, TripleStoreNonFatalException
Load items and triples into a triple store from the connector, but without adding the items to the triple store's index.
Invoked by the loadFromSource() method to apply a set of deltas that add items and triples in the source to the invoking triple store. This part of the load process is specific to the source. The subsequent part, in which the loaded items are indexed, is handled by the loadFromSource() method.
Note that the deltas may contain deletions as well as additions, and must be applied in order. This implies that the connector must apply deltas adding the items referenced by a triple before applying the delta that adds the triple. However, triples setting access level superiority permissions can be loaded before the triples defining the access levels concerned.
A source must be created, or loaded, but not both, before it can be used.
public Transaction startSourceTransaction() throws SourceConnectorException
Start a new transaction if the source connector is operational.
Every write operation is associated with a transaction. It is not guaranteed that all writes for a transaction will be performed, or none. What is guaranteed is that, if there is a system failure, only records resulting from completed transactions will be re-loaded when the system re-starts.
A transaction is associated with an item, which must be from the source that this connector connects to, and must have been locked before the transaction is started. The only write operations associated with the transaction are write operations on the item, or on triples of which it is the subject.
SourceConnectorException
public abstract Transaction startTransaction() throws SourceConnectorException
Start a new transaction.
Every write operation is associated with a transaction. It is not guaranteed that all writes for a transaction will be performed, or none. What is guaranteed is that, if there is a system failure, only records resulting from completed transactions will be re-loaded when the system re-starts.
A transaction is associated with an item, which must be from the source that this connector connects to, and must have been locked before the transaction is started. The only write operations associated with the transaction are write operations on the item, or on triples of which it is the subject.
SourceConnectorException
public void endSourceTransaction(Transaction trans) throws SourceConnectorException
trans
- a transaction to be endedSourceConnectorException
public abstract void endTransaction(Transaction trans) throws SourceConnectorException
trans
- a transaction to be endedSourceConnectorException
public SourceConnector.IdAndTrans addSourceItem(Id onlyReadLevelId, Id readOrWriteLevelId) throws SourceConnectorException
onlyReadLevelId
- the identifier of the item representing
the only-read access level that the item is to havereadOrWriteLevelId
- the identifier of the item representing
the read-or-write access level that the item is to haveSourceConnectorException
TripleStoreNonFatalException
public abstract SourceConnector.IdAndTrans addItem(Id onlyReadLevelId, Id readOrWriteLevelId) throws SourceConnectorException
onlyReadLevelId
- the identifier of the item representing
the only-read access level that the item is to havereadOrWriteLevelId
- the identifier of the item representing
the read-or-write access level that the item is to haveSourceConnectorException
TripleStoreNonFatalException
public void updateSourceItem(long itemNr, Id onlyReadLevelId, Id readOrWriteLevelId, Transaction trans) throws SourceConnectorException, TripleStoreNonFatalException
itemNr
- the numeric identifier of the item in the sourceonlyReadLevelId
- the identifier of the item representing
the only-read access level that the item is to havereadOrWriteLevelId
- the identifier of the item representing
the read-or-write access level that the item is to havetrans
- the transaction of which this operation is a partSourceConnectorException
TripleStoreNonFatalException
public abstract void updateItem(long itemNr, Id onlyReadLevelId, Id readOrWriteLevelId, Transaction trans) throws SourceConnectorException, TripleStoreNonFatalException
itemNr
- the numeric identifier of the item in the sourceonlyReadLevelId
- the identifier of the item representing
the only-read access level that the item is to havereadOrWriteLevelId
- the identifier of the item representing
the read-or-write access level that the item is to havetrans
- the transaction of which this operation is a partSourceConnectorException
TripleStoreNonFatalException
public void removeSourceItem(long itemNr, Transaction trans) throws SourceConnectorException, TripleStoreNonFatalException
itemNr
- the numeric identifier of the item in the sourcetrans
- the transaction of which this operation is a partSourceConnectorException
TripleStoreNonFatalException
public abstract void removeItem(long itemNr, Transaction trans) throws SourceConnectorException, TripleStoreNonFatalException
itemNr
- the numeric identifier of the item in the sourcetrans
- the transaction of which this operation is a partSourceConnectorException
TripleStoreNonFatalException
public StoredTriple createSourceTriple(Item subject, Item verb, Datum object, Transaction trans) throws SourceConnectorException, TripleStoreNonFatalException
subject
- the triple's subjectverb
- the triple's verbobject
- the triple's objecttrans
- the transaction of which this operation is a partSourceConnectorException
TripleStoreNonFatalException
public abstract StoredTriple createTriple(Item subject, Item verb, Datum object, Transaction trans) throws SourceConnectorException, TripleStoreNonFatalException
subject
- the triple's subjectverb
- the triple's verbobject
- the triple's objecttrans
- the transaction of which this operation is a partSourceConnectorException
TripleStoreNonFatalException
public StoredTriple replaceSourceTriple(Triple triple, Datum newObject, Transaction trans) throws SourceConnectorException, TripleStoreNonFatalException
triple
- the triple to be replacednewObject
- the triple's new objecttrans
- the transaction of which this operation is a partSourceConnectorException
TripleStoreNonFatalException
public abstract StoredTriple replaceTriple(Triple triple, Datum newObject, Transaction trans) throws SourceConnectorException, TripleStoreNonFatalException
triple
- the triple to be replacednewObject
- the triple's new objecttrans
- the transaction of which this operation is a partSourceConnectorException
TripleStoreNonFatalException
public Datum getSourceTextTripleObject(long tripleNr) throws SourceConnectorException, TripleStoreNonFatalException
tripleNr
- the numeric identifier in its source of a stored
tripleSourceConnectorException
TripleStoreNonFatalException
public abstract Datum getTextTripleObject(long tripleNr) throws SourceConnectorException, TripleStoreNonFatalException
tripleNr
- the numeric identifier in its source of a stored
tripleSourceConnectorException
TripleStoreNonFatalException
public Datum getSourceBinaryTripleObject(long tripleNr) throws SourceConnectorException, TripleStoreNonFatalException
tripleNr
- the numeric identifier in its source of a stored
tripleSourceConnectorException
TripleStoreNonFatalException
public abstract Datum getBinaryTripleObject(long tripleNr) throws SourceConnectorException, TripleStoreNonFatalException
tripleNr
- the numeric identifier in its source of a stored
tripleSourceConnectorException
TripleStoreNonFatalException
public void removeSourceTriple(long tripleNr, Transaction trans) throws SourceConnectorException
tripleNr
- the numeric identifier within the source of the
triple to be removedtrans
- the transaction of which this operation is a partSourceConnectorException
public abstract void removeTriple(long tripleNr, Transaction trans) throws SourceConnectorException
tripleNr
- the numeric identifier within the source of the
triple to be removedtrans
- the transaction of which this operation is a partSourceConnectorException
public void stopOperation() throws SourceConnectorException
SourceConnectorException
public abstract void close()
public abstract java.lang.Exception getTerminator()
Return an exception that caused connector operation to abort.
If an exception is thrown in the course of background processing then operation of the connector is aborted and the exception is stored.
public abstract void simulateIoError()
public void log(java.lang.String message)
message
- a message to be logged