Package org.projectbarbel.histo
Class BarbelHistoCore<T>
- java.lang.Object
-
- org.projectbarbel.histo.BarbelHistoCore<T>
-
- Type Parameters:
T- the business object type to manage
- All Implemented Interfaces:
BarbelHisto<T>
public final class BarbelHistoCore<T> extends Object implements BarbelHisto<T>
The core component ofBarbelHisto. SeeBarbelHistofor details.- Author:
- Niklas Schlimm
-
-
Field Summary
Fields Modifier and Type Field Description static ThreadLocal<BarbelHistoContext>CONSTRUCTION_CONTEXT
-
Constructor Summary
Constructors Modifier Constructor Description protectedBarbelHistoCore(BarbelHistoContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(Object documentId)Check ifBarbelHistocontains data for the given document ID.BarbelHistoContextgetContext()DocumentJournalgetDocumentJournal(Object id)voidload(Collection<Bitemporal> bitemporals)Method for clients that use a custom data store.voidloadQuiet(Collection<Bitemporal> bitemporals)StringprettyPrintJournal(Object id)Pretty print the journal for the given document ID.List<T>retrieve(com.googlecode.cqengine.query.Query<T> query)Retrieve data fromBarbelHistousing cqengine like queries.List<T>retrieve(com.googlecode.cqengine.query.Query<T> query, com.googlecode.cqengine.query.option.QueryOptions options)Retrieve data fromBarbelHistousing cqengine like queries.TretrieveOne(com.googlecode.cqengine.query.Query<T> query)Retrieve data fromBarbelHistousing cqengine like queries.TretrieveOne(com.googlecode.cqengine.query.Query<T> query, com.googlecode.cqengine.query.option.QueryOptions options)Retrieve data fromBarbelHistousing cqengine like queries.BitemporalUpdate<T>save(T newVersion, ZonedDateTime from, ZonedDateTime until)Save objects toBarbelHisto.intsize()DocumentJournaltimeshift(Object id, ZonedDateTime time)Turn back time to see how document journals looked like in the past.Collection<Bitemporal>unload(Object... documentIDs)Unloads the journal data of the given document IDs into a collection and return that to the client.Collection<Bitemporal>unloadAll()Unloads the complete backbone.Collection<Bitemporal>unloadQuiet(Object... documentIDs)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.projectbarbel.histo.BarbelHisto
save, save, save
-
-
-
-
Field Detail
-
CONSTRUCTION_CONTEXT
public static final ThreadLocal<BarbelHistoContext> CONSTRUCTION_CONTEXT
-
-
Constructor Detail
-
BarbelHistoCore
protected BarbelHistoCore(BarbelHistoContext context)
-
-
Method Detail
-
save
public BitemporalUpdate<T> save(T newVersion, ZonedDateTime from, ZonedDateTime until)
Description copied from interface:BarbelHistoSave objects toBarbelHisto. Creates snapshots of state. Clients can safely continue to work on passed instances. Thread safe, applies lock to journals of document IDs (not the complete backbone). This allows concurrent work on different document IDs. If clients try to update the same document Id, this method throwsConcurrentModificationException. The method returns a copy of the object saved including the version data. In inBarbelMode.POJOcast the returned object toBitemporalto read the version data.- Specified by:
savein interfaceBarbelHisto<T>- Parameters:
newVersion- the object state to savefrom- effective time of object stateuntil- effective until of the state- Returns:
- the
BitemporalUpdateperformed by this save operation
-
retrieve
public List<T> retrieve(com.googlecode.cqengine.query.Query<T> query)
Description copied from interface:BarbelHistoRetrieve data fromBarbelHistousing cqengine like queries. Clients want to useBarbelQueriesfor there convenience here.BarbelQueriescan be combined with additional queries fromQueryFactory.- Specified by:
retrievein interfaceBarbelHisto<T>- Parameters:
query- the client query fromBarbelQueriesand/orQueryFactory- Returns:
- the copies returned, maybe empty, never null
-
retrieve
public List<T> retrieve(com.googlecode.cqengine.query.Query<T> query, com.googlecode.cqengine.query.option.QueryOptions options)
Description copied from interface:BarbelHistoRetrieve data fromBarbelHistousing cqengine like queries. Clients want to useBarbelQueriesandBarbelQueryOptionsfor there convenience here.BarbelQueriescan be combined with additional queries fromQueryFactory.- Specified by:
retrievein interfaceBarbelHisto<T>- Parameters:
query- the client query fromBarbelQueriesand/orQueryFactoryoptions- the options fromBarbelQueryOptionsorQueryFactory- Returns:
- the copies returned, maybe empty, never null
-
prettyPrintJournal
public String prettyPrintJournal(Object id)
Description copied from interface:BarbelHistoPretty print the journal for the given document ID.- Specified by:
prettyPrintJournalin interfaceBarbelHisto<T>- Parameters:
id- the document ID- Returns:
- the journal as pretty print out
-
getContext
public BarbelHistoContext getContext()
-
getDocumentJournal
public DocumentJournal getDocumentJournal(Object id)
-
load
public void load(Collection<Bitemporal> bitemporals)
Description copied from interface:BarbelHistoMethod for clients that use a custom data store. Only add complete set of versions for one or more document IDs. Usually used in conjunction withBarbelHisto.unload(Object...).
InBarbelMode.POJO(default) clients have to pass a collection ofBitemporalVersion. InBarbelMode.BITEMPORALmode clients can add objects that implementBitemporal.
- Specified by:
loadin interfaceBarbelHisto<T>- Parameters:
bitemporals- consistent list ofBitemporalversions- See Also:
- https://github.com/npgall/cqengine
-
loadQuiet
public void loadQuiet(Collection<Bitemporal> bitemporals)
-
unload
public Collection<Bitemporal> unload(Object... documentIDs)
Description copied from interface:BarbelHistoUnloads the journal data of the given document IDs into a collection and return that to the client. The journal data of the given document IDs will be deleted from the backbone. This method is used when client uses custom data store. Clients may store the returned collection to the data store of their choice. Used in conjunction withBarbelHisto.load(Collection)to re-load that stored journals back intoBarbelHistoto continue bitemporal processing.
InBarbelMode.POJO(default) clients receive a collection ofBitemporalVersionobjects. InBarbelMode.BITEMPORALclients receive objects that implementBitemporal.
- Specified by:
unloadin interfaceBarbelHisto<T>- Parameters:
documentIDs- the document IDs to unload- Returns:
- the collection of
Bitemporalobjects to store into an arbitrary data store - See Also:
- https://github.com/npgall/cqengine
-
unloadQuiet
public Collection<Bitemporal> unloadQuiet(Object... documentIDs)
-
unloadAll
public Collection<Bitemporal> unloadAll()
Unloads the complete backbone.- Returns:
- the complete backbone versions.
-
timeshift
public DocumentJournal timeshift(Object id, ZonedDateTime time)
Description copied from interface:BarbelHistoTurn back time to see how document journals looked like in the past. If clients passLocalDateTime.now()the actual journal is returned. Time shift does not change the backbone collection of theBarbelHistoinstance, instead it returns an instance ofDocumentJournalwith copies of managedBitemporalobjects.- Specified by:
timeshiftin interfaceBarbelHisto<T>- Parameters:
id- the document Idtime- the time, must be in the past- Returns:
- the document journal at that given time
-
size
public int size()
-
retrieveOne
public T retrieveOne(com.googlecode.cqengine.query.Query<T> query)
Description copied from interface:BarbelHistoRetrieve data fromBarbelHistousing cqengine like queries. Clients want to useBarbelQueriesfor there convenience here.BarbelQueriescan be combined with additional queries fromQueryFactory. ThrowsIllegalStateExceptionwhen query returns more then one result,NoSuchElementExceptionif nothing was found.- Specified by:
retrieveOnein interfaceBarbelHisto<T>- Parameters:
query- the client query fromBarbelQueriesand/orQueryFactory- Returns:
- the returned copy
-
retrieveOne
public T retrieveOne(com.googlecode.cqengine.query.Query<T> query, com.googlecode.cqengine.query.option.QueryOptions options)
Description copied from interface:BarbelHistoRetrieve data fromBarbelHistousing cqengine like queries. Clients want to useBarbelQueriesandBarbelQueryOptionsfor there convenience here.BarbelQueriescan be combined with additional queries fromQueryFactory. ThrowsIllegalStateExceptionwhen query returns more then one result,NoSuchElementExceptionif nothing was found.- Specified by:
retrieveOnein interfaceBarbelHisto<T>- Parameters:
query- the client query fromBarbelQueriesand/orQueryFactoryoptions- the options fromBarbelQueryOptionsorQueryFactory- Returns:
- the returned copy
-
contains
public boolean contains(Object documentId)
Description copied from interface:BarbelHistoCheck ifBarbelHistocontains data for the given document ID.- Specified by:
containsin interfaceBarbelHisto<T>- Parameters:
documentId- the document id to check- Returns:
- true if
BarbelHistocontains data otherwise false
-
-