Package step.core.accessors
Class CachedAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
- java.lang.Object
-
- step.core.accessors.CachedAccessor<T>
-
-
Constructor Summary
Constructors Constructor Description CachedAccessor(Accessor<T> underlyingAccessor)CachedAccessor(Accessor<T> underlyingAccessor, boolean byPassCloning)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenableVersioning(Collection<EntityVersion> versionedCollection, Long newVersionThresholdMs)TfindByAttributes(Map<String,String> attributes)Find an object by default attributes.TfindByAttributes(Map<String,String> attributes, String attributesMapKey)Find an object by attributes.TfindByCriteria(Map<String,String> criteria)Find an object by criteria.Spliterator<T>findManyByAttributes(Map<String,String> attributes)Find objects by attributes.Spliterator<T>findManyByAttributes(Map<String,String> attributes, String attributesMapKey)Find objects by attributes.Stream<T>findManyByCriteria(Map<String,String> criteria)Find objects by criteria.Tget(String id)Get an object by idTget(org.bson.types.ObjectId id)Get an object by idIterator<T>getAll()Collection<T>getCollectionDriver()Stream<EntityVersion>getHistory(org.bson.types.ObjectId id, Integer skip, Integer limit)Get all object's versions by idList<T>getRange(int skip, int limit)Get the range of objects specified by the skip/limit parameters browsing the collection sorted by ID in the descending orderbooleanisVersioningEnabled()voidreloadCache()Reloads all the entities from the underlyingAccessorvoidremove(org.bson.types.ObjectId id)Remove an entity.TrestoreVersion(org.bson.types.ObjectId entityId, org.bson.types.ObjectId versionId)Restore a versionvoidsave(Iterable<T> entities)Save a list of entities.Tsave(T entity)Save an entity.Stream<T>stream()
-
-
-
Method Detail
-
reloadCache
public void reloadCache()
Reloads all the entities from the underlyingAccessor
-
getCollectionDriver
public Collection<T> getCollectionDriver()
- Specified by:
getCollectionDriverin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
-
get
public T get(org.bson.types.ObjectId id)
Description copied from interface:AccessorGet an object by id
-
findByCriteria
public T findByCriteria(Map<String,String> criteria)
Description copied from interface:AccessorFind an object by criteria. If multiple objects match these criteria, the first one will be returned- Specified by:
findByCriteriain interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
criteria- the map of mandatory criteria of the object to be found- Returns:
- the object
-
findManyByCriteria
public Stream<T> findManyByCriteria(Map<String,String> criteria)
Description copied from interface:AccessorFind objects by criteria.- Specified by:
findManyByCriteriain interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
criteria- the map of mandatory criteria of the object to be found- Returns:
- an
Iteratorfor the objects found
-
findByAttributes
public T findByAttributes(Map<String,String> attributes)
Description copied from interface:AccessorFind an object by default attributes. If multiple objects match these attributes, the first one will be returned- Specified by:
findByAttributesin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
attributes- the map of mandatory attributes of the object to be found- Returns:
- the object
-
findManyByAttributes
public Spliterator<T> findManyByAttributes(Map<String,String> attributes)
Description copied from interface:AccessorFind objects by attributes.- Specified by:
findManyByAttributesin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
attributes- the map of mandatory attributes of the object to be found- Returns:
- an
Iteratorfor the objects found
-
findByAttributes
public T findByAttributes(Map<String,String> attributes, String attributesMapKey)
Description copied from interface:AccessorFind an object by attributes. If multiple objects match these attributes, the first one will be returned- Specified by:
findByAttributesin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
attributes- the map of mandatory attributes of the object to be foundattributesMapKey- the string representing the name (or "key") of the attribute map- Returns:
- the object
-
findManyByAttributes
public Spliterator<T> findManyByAttributes(Map<String,String> attributes, String attributesMapKey)
Description copied from interface:AccessorFind objects by attributes.- Specified by:
findManyByAttributesin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
attributes- the map of mandatory attributes of the object to be foundattributesMapKey- the string representing the name (or "key") of the attribute map- Returns:
- an
Iteratorfor the objects found
-
remove
public void remove(org.bson.types.ObjectId id)
Description copied from interface:AccessorRemove an entity.
-
save
public T save(T entity)
Description copied from interface:AccessorSave an entity. If an entity with the same id exists, it will be updated otherwise inserted.
-
save
public void save(Iterable<T> entities)
Description copied from interface:AccessorSave a list of entities.
-
getHistory
public Stream<EntityVersion> getHistory(org.bson.types.ObjectId id, Integer skip, Integer limit)
Description copied from interface:AccessorGet all object's versions by id- Specified by:
getHistoryin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
id- the UID of the object- Returns:
- the list of versioned objects
-
restoreVersion
public T restoreVersion(org.bson.types.ObjectId entityId, org.bson.types.ObjectId versionId)
Description copied from interface:AccessorRestore a version- Specified by:
restoreVersionin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>- Parameters:
entityId- the UID of the object to be restored- Returns:
- the restored object
-
isVersioningEnabled
public boolean isVersioningEnabled()
- Specified by:
isVersioningEnabledin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
-
enableVersioning
public void enableVersioning(Collection<EntityVersion> versionedCollection, Long newVersionThresholdMs)
- Specified by:
enableVersioningin interfaceAccessor<T extends step.core.accessors.AbstractIdentifiableObject>
-
getRange
public List<T> getRange(int skip, int limit)
Description copied from interface:AccessorGet the range of objects specified by the skip/limit parameters browsing the collection sorted by ID in the descending order
-
-