MDSLookupService¶
-
public interface
MDSLookupService
¶ This service allows executing lookups on entities given their classes or class names and lookup names as Strings. Allows generic access to any entity in MDS. This is just a facade and all data access goes through the underlying data service. EUDE can be identified either by their fully qualified class name (eg: “org.motechproject.mds.entity.Patient”) or by their entity name (eg: “Patient”)
Methods¶
count¶
-
long
count
(Class entityClass, String lookupName, Map<String, ?> lookupParams)¶ Retrieves a total number of instances, that match the specified lookup parameters, for the given lookup and entity. This will fail if specified lookup parameters do not match the lookup definition or if the lookup of given name is not specified for the given entity.
Parameters: - entityClass – entity class
- lookupName – name of the lookup from entity
- lookupParams – parameters to use, when executing the lookup
Returns: number of instances
count¶
-
long
count
(String entityClassName, String lookupName, Map<String, ?> lookupParams)¶ Retrieves a total number of instances, that match the specified lookup parameters, for the given lookup and entity class name. This will fail if specified lookup parameters do not match the lookup definition or if the lookup of given name is not specified for the given entity.
Parameters: - entityClassName – entity class name
- lookupName – name of the lookup from entity
- lookupParams – parameters to use, when executing the lookup
Returns: number of instances
countAll¶
countAll¶
findMany¶
-
<T> List<T>
findMany
(Class<T> entityClass, String lookupName, Map<String, ?> lookupParams)¶ Retrieves and executes multi-return lookup for the given entity class, lookup name and parameters. It will fail, if lookup parameters do not match the parameters specified in the lookup or if the lookup of given name does not exist for the retrieved entity.
Parameters: - entityClass – entity class
- lookupName – name of the lookup from entity
- lookupParams – parameters to use, when executing the lookup
- <T> – entity class
Returns: collection of instances, retrieved using given lookup criteria
findMany¶
-
<T> List<T>
findMany
(String entityClassName, String lookupName, Map<String, ?> lookupParams)¶ Retrieves and executes multi-return lookup for the given entity class name, lookup name and parameters. It will fail, if lookup parameters do not match the parameters specified in the lookup or if the lookup of given name does not exist for the retrieved entity.
Parameters: - entityClassName – entity class name
- lookupName – name of the lookup from entity
- lookupParams – parameters to use, when executing the lookup
- <T> – entity class
Returns: collection of instances, retrieved using given lookup criteria
findMany¶
-
<T> List<T>
findMany
(Class<T> entityClass, String lookupName, Map<String, ?> lookupParams, QueryParams queryParams)¶ Retrieves and executes multi-return lookup for the given entity class, lookup name and parameters. It will fail, if lookup parameters do not match the parameters specified in the lookup or if the lookup of given name does not exist for the retrieved entity. This version additionally allows to use query parameters, to adjust retrieved instances (eg. limit their number).
Parameters: - entityClass – entity class
- lookupName – name of the lookup from entity
- lookupParams – parameters to use, when executing the lookup
- queryParams – parameters to use, retrieving the instances
- <T> – entity class
Returns: collection of instances, retrieved using given lookup criteria
findMany¶
-
<T> List<T>
findMany
(String entityClassName, String lookupName, Map<String, ?> lookupParams, QueryParams queryParams)¶ Retrieves and executes multi-return lookup for the given entity class name, lookup name and parameters. It will fail, if lookup parameters do not match the parameters specified in the lookup or if the lookup of given name does not exist for the retrieved entity. This version additionally allows to use query parameters, to adjust retrieved instances (eg. limit their number).
Parameters: - entityClassName – entity class name
- lookupName – name of the lookup from entity
- lookupParams – parameters to use, when executing the lookup
- queryParams – parameters to use, retrieving the instances
- <T> – entity class
Returns: collection of instances, retrieved using given lookup criteria
findOne¶
-
<T> T
findOne
(Class<T> entityClass, String lookupName, Map<String, ?> lookupParams)¶ Retrieves and executes single-return lookup for the given entity class, lookup name and parameters. It will fail, if lookup parameters do not match the parameters specified in the lookup or if the lookup of given name does not exist for the retrieved entity. It will also throw
org.motechproject.mds.exception.lookup.SingleResultFromLookupExpectedException
in case lookup returns a collection of instances, rather than single instance.Parameters: - entityClass – entity class
- lookupName – name of the lookup from entity
- lookupParams – parameters to use, when executing the lookup
- <T> – entity class
Returns: Single instance, retrieved using given lookup criteria
findOne¶
-
<T> T
findOne
(String entityClassName, String lookupName, Map<String, ?> lookupParams)¶ Retrieves and executes single-return lookup for the given entity class name, lookup name and parameters. It will fail, if lookup parameters do not match the parameters specified in the lookup or if the lookup of given name does not exist for the retrieved entity. It will also throw
org.motechproject.mds.exception.lookup.SingleResultFromLookupExpectedException
in case lookup returns a collection of instances, rather than single instance.Parameters: - entityClassName – entity class name
- lookupName – name of the lookup from entity
- lookupParams – parameters to use, when executing the lookup
- <T> – entity class
Returns: Single instance, retrieved using given lookup criteria
retrieveAll¶
retrieveAll¶
retrieveAll¶
-
<T> List<T>
retrieveAll
(Class<T> entityClass, QueryParams queryParams)¶ Retrieves all instances for the given entity class name. This version additionally allows to use query parameters, to adjust retrieved instances (eg. limit their number).
Parameters: - entityClass – entity class
- <T> – entity class
Returns: a list of all instances for the given entity
retrieveAll¶
-
<T> List<T>
retrieveAll
(String entityClassName, QueryParams queryParams)¶ Retrieves all instances for the given entity class name. This version additionally allows to use query parameters, to adjust retrieved instances (eg. limit their number).
Parameters: - entityClassName – entity class name
- <T> – entity class
Returns: a list of all instances for the given entity