Package step.client.accessors
Class AbstractRemoteCRUDAccessorImpl<T extends AbstractIdentifiableObject>
- java.lang.Object
-
- step.client.AbstractRemoteClient
-
- step.client.accessors.AbstractRemoteCRUDAccessorImpl<T>
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Accessor<T>
,CRUDAccessor<T>
- Direct Known Subclasses:
RemoteExecutionAccessor
,RemoteFunctionAccessor
,RemoteParameterAccessor
,RemotePlanAccessor
public class AbstractRemoteCRUDAccessorImpl<T extends AbstractIdentifiableObject> extends AbstractRemoteClient implements CRUDAccessor<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<T>
entityClass
protected javax.ws.rs.core.GenericType<List<T>>
genericEntity
protected ParameterizedType
parameterizedGenericType
protected String
path
-
Fields inherited from class step.client.AbstractRemoteClient
client, cookies, credentials
-
-
Constructor Summary
Constructors Constructor Description AbstractRemoteCRUDAccessorImpl(String path, Class<T> entityClass)
AbstractRemoteCRUDAccessorImpl(ControllerCredentials credentials, String path, Class<T> entityClass)
-
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 ordervoid
remove(org.bson.types.ObjectId id)
void
save(Collection<? extends T> entities)
Save a list of entities.T
save(T e)
Save an entity.-
Methods inherited from class step.client.AbstractRemoteClient
close, executeRequest, notImplemented, requestBuilder, requestBuilder
-
-
-
-
Field Detail
-
path
protected final String path
-
entityClass
protected final Class<T extends AbstractIdentifiableObject> entityClass
-
parameterizedGenericType
protected ParameterizedType parameterizedGenericType
-
genericEntity
protected javax.ws.rs.core.GenericType<List<T extends AbstractIdentifiableObject>> genericEntity
-
-
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>
-
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
-
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
-
remove
public void remove(org.bson.types.ObjectId id)
- Specified by:
remove
in interfaceCRUDAccessor<T extends AbstractIdentifiableObject>
-
save
public T save(T e)
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:
e
- 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
-
-