public class ChangeBundle
extends java.lang.Object
A bundle of changes to a triple store that are to be performed together.
The changes may not be able to be performed in a single transaction, as they may require changes to different items or to triples whose subjects are different items.
The class contains methods to add changes to the bundle and to perform the changes.
Constructor and Description |
---|
ChangeBundle(TripleStore store)
Create a change bundle
|
Modifier and Type | Method and Description |
---|---|
void |
ensureNoMatchingTriples(Item subject,
Item verb,
StoreSession session)
Add a change to ensure that there are no triples with a given
subject and verb.
|
void |
establishTripleSet(Item subject,
Item verb,
java.util.Set<Quantum> objects,
StoreSession session)
Add a change to establish a set of triples that have the same subjects
and verbs, which are given as items, and objects that may be given
by item handles or datum values.
|
Item |
getAddedItem(java.lang.String handle)
Get an item that has been added
|
java.util.Map<java.lang.String,Item> |
getNewItems() |
void |
makeChanges(StoreSession session)
Make the changes that have been added to the change bundle.
|
void |
rankNewItem(JoinConstraint[] constraints,
Item memberRankRelation,
java.lang.String rankUnknown,
java.lang.String newItemHandle)
Add a change to give a rank to an item specified to be added by
another change.
|
void |
setItemToAdd(java.lang.String handle,
java.lang.Long source,
AccessLevel onlyReadLevel,
AccessLevel readOrWriteLevel)
Add a change that will add an item to the store
|
void |
setItemToDelete(Item item)
Add a change that will delete an item from the store
|
void |
setItemToDelete(Item item,
DependentsSpec dependentsSpec)
Add a change that will delete an item from the store
|
void |
setItemToUpdate(Item item,
AccessLevel onlyReadLevel,
AccessLevel readOrWriteLevel)
Add a change that will update an item in the store
|
void |
setItemToUpdate(Item item,
AccessLevel onlyReadLevel,
AccessLevel readOrWriteLevel,
DependentsSpec dependentsSpec)
Add a change that will update an item in the store
|
void |
setTriplesToDelete(Item subject,
Item verb,
Datum object,
StoreSession session)
Add a change to delete triples with a given subject, verb,
and object.
|
void |
setTripleToDelete(Item subject,
Item verb,
Datum object,
StoreSession session)
Add a change to delete triples with a given subject, verb,
and object.
|
void |
setTripleToDelete(Triple triple,
StoreSession session)
Add a change to delete a triple.
|
void |
setTripleToPut(Quantum subject,
Quantum verb,
Quantum object,
StoreSession session)
Add a change that will put a triple to the store.
|
void |
setUniqueTripleObject(Item subject,
Item verb,
Datum object,
StoreSession session)
Add a change to ensure that there is exactly one triple
with a given subject and verb, and that it has a given object,
which is a non-item value or an existing item.
|
void |
setUniqueTripleObject(Item subject,
Item verb,
Quantum object,
StoreSession session)
Add a change to ensure that there is exactly one triple
with a given subject and verb, and that it has a given object,
which can be a new item to be created.
|
public ChangeBundle(TripleStore store)
store
- the triple store to which the changes are to be madepublic void setItemToAdd(java.lang.String handle, java.lang.Long source, AccessLevel onlyReadLevel, AccessLevel readOrWriteLevel)
handle
- a name used to refer to the item in other changes,
or after the changes have been made.source
- the source in which the item is to be createdonlyReadLevel
- the only-read access level that the item is to havereadOrWriteLevel
- the read-or-write access level that the item
is to havepublic Item getAddedItem(java.lang.String handle)
handle
- the handle of the item specified in the change to add itpublic void setItemToUpdate(Item item, AccessLevel onlyReadLevel, AccessLevel readOrWriteLevel) throws InputException
item
- the item to be updatedonlyReadLevel
- the only-read access level that the item is to have
after the changereadOrWriteLevel
- the read-or-write access level that the item is to
have after the changeInputException
public void setItemToUpdate(Item item, AccessLevel onlyReadLevel, AccessLevel readOrWriteLevel, DependentsSpec dependentsSpec) throws InputException
item
- the item to be updatedonlyReadLevel
- the only-read access level that the item is to have
after the changereadOrWriteLevel
- the read-or-write access level that the item is to
have after the changedependentsSpec
- the specification of dependent items, if any, that
must have the same access levels as the itemInputException
public void setItemToDelete(Item item) throws InputException, TripleStoreNonFatalException
item
- the item to be deletedInputException
TripleStoreNonFatalException
public void setItemToDelete(Item item, DependentsSpec dependentsSpec) throws InputException, TripleStoreNonFatalException
item
- the item to be deleteddependentsSpec
- the specification of dependent items, if any, that
must also be deletedTripleStoreNonFatalException
InputException
public void setTripleToPut(Quantum subject, Quantum verb, Quantum object, StoreSession session) throws InputException, TripleStoreNonFatalException
subject
- the subject of the triple. This is either
an item already in the store or the handle of an item to be
added.verb
- the verb of the triple. This is either
an item already in the store or the handle of an item to be
added.object
- the object of the triple. This is either a
datum or the handle of an item to be added. If it is a
datum then it can be an item already in the store.session
- the requesting store sessionInputException
TripleStoreNonFatalException
public void setTripleToDelete(Triple triple, StoreSession session) throws InputException, TripleStoreNonFatalException, TripleStoreFatalException, SourceConnectorException, NotInOperationException
triple
- the triple to be deletedsession
- the requesting store sessionInputException
TripleStoreNonFatalException
TripleStoreFatalException
SourceConnectorException
NotInOperationException
public void setTripleToDelete(Item subject, Item verb, Datum object, StoreSession session) throws InputException
subject
- the subject of the triple to be deleted.verb
- the verb of the triple to be deleted.object
- the object of the triple to be deleted.session
- the requesting store sessionInputException
public void setTriplesToDelete(Item subject, Item verb, Datum object, StoreSession session) throws InputException
subject
- the subject of the triple to be deleted or null,
in which case all subjects matchverb
- the verb of the triple to be deleted or null,
in which case all verbs matchobject
- the object of the triple to be deleted or null,
in which case all objects matchsession
- the requesting store sessionInputException
public void setUniqueTripleObject(Item subject, Item verb, Datum object, StoreSession session) throws InputException
subject
- the subject.verb
- the verb.object
- the object.session
- the requesting session.InputException
public void setUniqueTripleObject(Item subject, Item verb, Quantum object, StoreSession session) throws InputException
subject
- the subject.verb
- the verb.object
- the object.session
- the requesting session.InputException
public void ensureNoMatchingTriples(Item subject, Item verb, StoreSession session) throws InputException
subject
- the subject.verb
- the verb.session
- the requesting session.InputException
public void establishTripleSet(Item subject, Item verb, java.util.Set<Quantum> objects, StoreSession session) throws InputException
subject
- the subject.verb
- the verb.object
- the objects.session
- the requesting session.InputException
public void rankNewItem(JoinConstraint[] constraints, Item memberRankRelation, java.lang.String rankUnknown, java.lang.String newItemHandle) throws InputException
Add a change to give a rank to an item specified to be added by another change.
A set of items is ranked by making each of them the subject of a triple whose verb is a member rank relation and whose object is an integer that specifies its rank. The new item is to be ranked in the set of items that are the values of a particular unknown - the rank unknown - when a set of constraints is applied. It will be given a rank that is greater than the rank of any item currently in that set.
context
- the contextconstraints
- the constraints to be appliedmemberRankRelation
- the member rank relationrankUnknown
- the rank unknownnewItemHandle
- the handle specified in the change to add the
new item.InputException
public java.util.Map<java.lang.String,Item> getNewItems()
public void makeChanges(StoreSession session) throws java.lang.Exception
Make the changes that have been added to the change bundle.
If one of the changes cannot be made then the changes that have been made so far are reversed if possible.
session
- the requesting store sessionjava.lang.Exception