Package de.xima.fc.api.entity
Class GenericAPI
- java.lang.Object
-
- de.xima.fc.api.ASubAPI
-
- de.xima.fc.api.entity.GenericAPI
-
public class GenericAPI extends ASubAPI
Generic API class for manipulation of entities.
The class provides methods for the basic CRUD functions (Create, Read, Update, Delete).- Author:
- XIMA MEDIA GmbH
-
-
Constructor Summary
Constructors Constructor Description GenericAPI()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends ITransferableEntity>
Tcreate(Class<T> entityClass, UserContext uc, T entity)
Method for creating a entity of a defined class.<T extends ITransferableEntity>
T[]create(Class<T> entityClass, UserContext uc, T[] entities)
Method for creating multiple entities of a defined class.<T extends ITransferableEntity>
booleandelete(Class<T> entityClass, UserContext uc, T entity)
Method for deleting a entity of a defined class.<T extends ITransferableEntity>
booleandelete(Class<T> entityClass, UserContext uc, T[] entities)
Method for deleting multiple entities of a defined class.<T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding>
BooleandeleteAllBy(Class<T> entityClass, UserContext uc, C cm)
Method for deleting multiple entities of a defined class by ID.<T extends ITransferableEntity>
BooleandeleteAllBy(Class<T> entityClass, UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
Method for deleting multiple entities of a defined class by ID. * @paramthe type of the entity <T extends ITransferableEntity>
BooleandeleteById(Class<T> entityClass, UserContext uc, Integer id)
<T extends ITransferableEntity>
BooleandeleteById(Class<T> entityClass, UserContext uc, Long id)
Method for deleting a entity of a defined class by ID.<T extends ITransferableEntity>
List<T>getAll(Class<T> entityClass, UserContext uc)
Method for determining all entities.<T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding>
List<T>getAll(Class<T> entityClass, UserContext uc, C cm)
Method for determining all entities of a defined class using a criteria manager.<T extends ITransferableEntity>
List<T>getAll(Class<T> entityClass, UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
Method for determining all entities of a defined class using aQueryCriteriaManager
s.<T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager>
List<Map<String,Serializable>>getAttributes(Class<T> entityClass, UserContext uc, C cm)
<R,T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager>
List<R>getAttributes(Class<T> entityClass, UserContext uc, C cm, Class<R> resultClass)
<T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding>
TgetBy(Class<T> entityClass, UserContext uc, C cm)
Method for determining an entity using aQueryCriteriaManager
.<T extends ITransferableEntity>
TgetBy(Class<T> entityClass, UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
Method for determining an entity using aQueryCriteriaManager
.<T extends ITransferableEntity>
TgetById(UserContext uc, String entityClassName, String id)
Method for reading an entity by its class name and ID.<T extends ITransferableEntity>
TgetById(Class<T> entityClass, UserContext uc, Integer id)
<T extends ITransferableEntity>
TgetById(Class<T> entityClass, UserContext uc, Long id)
Method for reading a entity by class and ID.<T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager>
javax.persistence.TuplegetSingleAttributes(Class<T> entityClass, UserContext uc, C cm)
This method allows for the selection of certain attributes of an entity instead of reading the entire entity<R,T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager>
RgetSingleAttributes(Class<T> entityClass, UserContext uc, C cm, Class<R> resultClass)
This method allows for the selection of certain attributes of an entity instead of reading the entire entity<T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding>
intresultTotalCount(Class<T> entityClass, UserContext uc, C cm)
Method for determining the number of found entities based on their class.<T extends ITransferableEntity>
intresultTotalCount(Class<T> entityClass, UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
Method for determining the number of found entities based on their class.<T extends ITransferableEntity>
Tupdate(Class<T> entityClass, UserContext uc, T entity)
Method for updating a entity of a defined class.<T extends ITransferableEntity>
T[]update(Class<T> entityClass, UserContext uc, T[] entities)
Method for updating multiple entities of a defined class.-
Methods inherited from class de.xima.fc.api.ASubAPI
getHandlerProvider
-
-
-
-
Method Detail
-
getAll
public <T extends ITransferableEntity> List<T> getAll(Class<T> entityClass, UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
Method for determining all entities of a defined class using aQueryCriteriaManager
s.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.qcm
-QueryCriteriaManager
to be filtered by.- Returns:
List
fromITransferableEntity
which were found.- Since:
- 2.4.3
-
getAll
public <T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding> List<T> getAll(Class<T> entityClass, UserContext uc, C cm)
Method for determining all entities of a defined class using a criteria manager.- Type Parameters:
T
- the type of the entityC
- the type of the criteria manager- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.cm
- the criteria manager to be filtered by.- Returns:
List
fromITransferableEntity
which were found.- Since:
- 6.2.1
-
create
public <T extends ITransferableEntity> T create(Class<T> entityClass, UserContext uc, T entity)
Method for creating a entity of a defined class.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.entity
-ITransferableEntity
which should be created.- Returns:
ITransferableEntity
which is created.- Since:
- 2.4.3 @
-
create
public <T extends ITransferableEntity> T[] create(Class<T> entityClass, UserContext uc, T[] entities)
Method for creating multiple entities of a defined class.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.entities
-Array
the entities to create.- Returns:
Array
of the created entities.- Since:
- 2.4.3
-
delete
public <T extends ITransferableEntity> boolean delete(Class<T> entityClass, UserContext uc, T entity)
Method for deleting a entity of a defined class.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.entity
-ITransferableEntity
which should be deleted.- Returns:
Boolean
whether the deletion was successful or not.- Since:
- 2.4.3
-
delete
public <T extends ITransferableEntity> boolean delete(Class<T> entityClass, UserContext uc, T[] entities)
Method for deleting multiple entities of a defined class.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.entities
-Array
the entities to be deleted.- Returns:
Boolean
whether the deletion was successful or not.- Since:
- 2.4.3
-
getById
public <T extends ITransferableEntity> T getById(Class<T> entityClass, UserContext uc, Long id)
Method for reading a entity by class and ID.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.id
-Long
the ID of the searched entity.- Returns:
ITransferableEntity
the found entity.- Since:
- 2.4.3
-
getById
public <T extends ITransferableEntity> T getById(Class<T> entityClass, UserContext uc, Integer id)
-
getById
public <T extends ITransferableEntity> T getById(UserContext uc, String entityClassName, String id)
Method for reading an entity by its class name and ID.- Type Parameters:
T
- the type of the entity- Parameters:
uc
-UserContext
the user context in which the action is to be performed.entityClassName
-String
the class name of the searched entity.id
-Integer
the ID of the searched entity.- Returns:
ITransferableEntity
the found entity.- Since:
- 2.4.3
-
getAttributes
public <T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> List<Map<String,Serializable>> getAttributes(Class<T> entityClass, UserContext uc, C cm) throws NotSerializableException
- Throws:
NotSerializableException
-
getAttributes
public <R,T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> List<R> getAttributes(Class<T> entityClass, UserContext uc, C cm, Class<R> resultClass)
-
getSingleAttributes
public <T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> javax.persistence.Tuple getSingleAttributes(Class<T> entityClass, UserContext uc, C cm)
This method allows for the selection of certain attributes of an entity instead of reading the entire entity- Type Parameters:
T
- type of entityC
- type of the criteria manager- Parameters:
entityClass
-Class
the class of the searched entityuc
-UserContext
which will be usedcm
-GenericAPI
object, that contains lists for filtering, sorting and selecting. These lists, if available, are included in the SQL query. This value can benull
. The lists contained in theGenericAPI
can also benull
or empty.- Returns:
Tuple
that contains the values of the selected attributes- Since:
- 6.6.0
-
getSingleAttributes
public <R,T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> R getSingleAttributes(Class<T> entityClass, UserContext uc, C cm, Class<R> resultClass)
This method allows for the selection of certain attributes of an entity instead of reading the entire entity- Type Parameters:
R
- type of object, in which the result values will be placedT
- type of entityC
- type of the criteria manager- Parameters:
entityClass
-Class
the class of the searched entityuc
-UserContext
which will be usedcm
-GenericAPI
object, that contains lists for filtering, sorting and selecting. These lists, if available, are included in the SQL query. This value can benull
. The lists contained in theGenericAPI
can also benull
or empty.resultClass
-Class
of the object, in which the result value will be placed- Returns:
GenericAPI
that contains the values of the selected attributes- Since:
- 6.6.0
-
resultTotalCount
public <T extends ITransferableEntity> int resultTotalCount(Class<T> entityClass, UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
Method for determining the number of found entities based on their class.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.qcm
-QueryCriteriaManager
to be searched by.- Returns:
Integer
the found number of elementsQueryCriteriaManager
s.- Since:
- 2.4.3
-
resultTotalCount
public <T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding> int resultTotalCount(Class<T> entityClass, UserContext uc, C cm)
Method for determining the number of found entities based on their class.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.cm
- the criteria manager to be searched by.- Returns:
Integer
the found number of elements.- Since:
- 6.2.1
-
update
public <T extends ITransferableEntity> T[] update(Class<T> entityClass, UserContext uc, T[] entities)
Method for updating multiple entities of a defined class.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.entities
-Array
the entities to be updated.- Returns:
Array
the updated entities.- Since:
- 2.4.3
-
update
public <T extends ITransferableEntity> T update(Class<T> entityClass, UserContext uc, T entity)
Method for updating a entity of a defined class.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.entity
-ITransferableEntity
which should be updated.- Returns:
ITransferableEntity
the updated entity.- Since:
- 2.4.3
-
getBy
public <T extends ITransferableEntity> T getBy(Class<T> entityClass, UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
Method for determining an entity using aQueryCriteriaManager
.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.qcm
- theQueryCriteriaManager
to be searched by.- Returns:
- the found entity.
- Since:
- 2.4.3
-
getBy
public <T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding> T getBy(Class<T> entityClass, UserContext uc, C cm)
Method for determining an entity using aQueryCriteriaManager
.- Type Parameters:
T
- the type of the entityC
- the type of the criteria manager- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.cm
- the criteria manager to be searched by.- Returns:
- the found entity.
- Since:
- 6.2.1
-
deleteAllBy
public <T extends ITransferableEntity> Boolean deleteAllBy(Class<T> entityClass, UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
Method for deleting multiple entities of a defined class by ID. * @paramthe type of the entity - Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.qcm
-QueryCriteriaManager
to be searched by.- Returns:
Boolean
whether the deletion was successful or not.- Since:
- 2.4.3
-
deleteAllBy
public <T extends ITransferableEntity,C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding> Boolean deleteAllBy(Class<T> entityClass, UserContext uc, C cm)
Method for deleting multiple entities of a defined class by ID.- Type Parameters:
T
- the type of the entityC
- the type of the criteria manager- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.cm
- the criteria manager to be searched by.- Returns:
Boolean
whether the deletion was successful or not.- Since:
- 6.2.1
-
deleteById
public <T extends ITransferableEntity> Boolean deleteById(Class<T> entityClass, UserContext uc, Long id)
Method for deleting a entity of a defined class by ID.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.id
-Long
the ID of the searched entity.- Returns:
Boolean
whether the deletion was successful or not.- Since:
- 2.4.3
-
deleteById
public <T extends ITransferableEntity> Boolean deleteById(Class<T> entityClass, UserContext uc, Integer id)
-
getAll
public <T extends ITransferableEntity> List<T> getAll(Class<T> entityClass, UserContext uc)
Method for determining all entities.- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
-ITransferableEntity
class of the entity.uc
-UserContext
the user context in which the action is to be performed.- Returns:
List
of the found entities.- Since:
- 2.4.3
-
-