Package step.core.accessors
Class InMemoryCRUDAccessor<T extends AbstractIdentifiableObject>
- java.lang.Object
-
- step.core.accessors.InMemoryCRUDAccessor<T>
-
- All Implemented Interfaces:
Accessor<T>
,CRUDAccessor<T>
- Direct Known Subclasses:
InMemoryControllerSettingAccessor
,InMemoryExecutionAccessor
,InMemoryExecutionTaskAccessor
,InMemoryFunctionAccessorImpl
,InMemoryPlanAccessor
,InMemoryReportNodeAccessor
,InMemoryResourceAccessor
,InMemoryResourceRevisionAccessor
,InMemoryUserAccessor
,InMemoryViewModelAccessor
public class InMemoryCRUDAccessor<T extends AbstractIdentifiableObject> extends Object implements CRUDAccessor<T>
-
-
Constructor Summary
Constructors Constructor Description InMemoryCRUDAccessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
findByAttributes(Map<String,String> attributes)
Find an object by default attributes.T
findByAttributes(Map<String,String> attributes, String attributesMapKey)
Find an object by attributes.Spliterator<T>
findManyByAttributes(Map<String,String> attributes)
Find objects by attributes.Spliterator<T>
findManyByAttributes(Map<String,String> attributes, String attributesMapKey)
Find objects by attributes.T
get(String id)
Get an object by idT
get(org.bson.types.ObjectId id)
Get an object by idIterator<T>
getAll()
List<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 orderprotected RuntimeException
notImplemented()
void
remove(org.bson.types.ObjectId id)
void
save(Collection<? extends T> entities)
Save a list of entities.T
save(T entity)
Save an entity.
-
-
-
Field Detail
-
map
protected Map<org.bson.types.ObjectId,T extends AbstractIdentifiableObject> map
-
-
Method Detail
-
get
public T get(org.bson.types.ObjectId id)
Description copied from interface:Accessor
Get an object by id- Specified by:
get
in interfaceAccessor<T extends AbstractIdentifiableObject>
- Parameters:
id
- the UID of the object- Returns:
- the object
-
get
public T get(String id)
Description copied from interface:Accessor
Get an object by id- Specified by:
get
in interfaceAccessor<T extends AbstractIdentifiableObject>
- Parameters:
id
- the UID of the object- Returns:
- the object
-
findByAttributes
public T findByAttributes(Map<String,String> attributes)
Description copied from interface:Accessor
Find an object by default attributes. If multiple objects match these attributes, the first one will be returned- Specified by:
findByAttributes
in interfaceAccessor<T extends 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:Accessor
Find objects by attributes.- Specified by:
findManyByAttributes
in interfaceAccessor<T extends AbstractIdentifiableObject>
- Parameters:
attributes
- the map of mandatory attributes of the object to be found- Returns:
- an
Iterator
for the objects found
-
getAll
public Iterator<T> getAll()
- Specified by:
getAll
in interfaceAccessor<T extends AbstractIdentifiableObject>
-
remove
public void remove(org.bson.types.ObjectId id)
- Specified by:
remove
in interfaceCRUDAccessor<T extends AbstractIdentifiableObject>
-
save
public T save(T entity)
Description copied from interface:CRUDAccessor
Save an entity. If an entity with the same id exists, it will be updated otherwise inserted.- Specified by:
save
in interfaceCRUDAccessor<T extends AbstractIdentifiableObject>
- Parameters:
entity
- the entity instance to be saved- Returns:
- the saved entity
-
save
public void save(Collection<? extends T> entities)
Description copied from interface:CRUDAccessor
Save a list of entities.- Specified by:
save
in interfaceCRUDAccessor<T extends AbstractIdentifiableObject>
- Parameters:
entities
- the list of entities to be saved
-
findByAttributes
public T findByAttributes(Map<String,String> attributes, String attributesMapKey)
Description copied from interface:Accessor
Find an object by attributes. If multiple objects match these attributes, the first one will be returned- Specified by:
findByAttributes
in interfaceAccessor<T extends 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:Accessor
Find objects by attributes.- Specified by:
findManyByAttributes
in interfaceAccessor<T extends 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
Iterator
for the objects found
-
getRange
public List<T> getRange(int skip, int limit)
Description copied from interface:Accessor
Get the range of objects specified by the skip/limit parameters browsing the collection sorted by ID in the descending order- Specified by:
getRange
in interfaceAccessor<T extends AbstractIdentifiableObject>
- Parameters:
skip
- the start index (inclusive) of the rangelimit
- the size of the range- Returns:
- a
List
containing the objects of the specified range
-
notImplemented
protected RuntimeException notImplemented()
-
-