Package mc.core.domain.base
Class AbstractAPI
java.lang.Object
mc.core.system.base.BaseBean
mc.core.domain.base.AbstractAPI
public abstract class AbstractAPI
extends mc.core.system.base.BaseBean
abstract base class for all APIs. uses services directly where possible for efficiency
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends IBaseEntity>
List<T>searches all persistent entities of given class.<T extends IBaseEntity>
List<T>searches for all persistent entities of given class according to criteria in search filter if given, otherwise for all.<T extends IBaseEntity>
Treturns a persistent entity for given class with given id.<T extends IEntity>
TgetFromInternalDescription(Class<T> entityClass, String internalDescription) get entity through it's internal description.<T extends IBaseEntity>
TgetReference(Class<T> entityClass, long entityId) returns an instance of given entityClass if the entity is already in cache of the persistence provider, or a proxy object thereof.<T extends IBaseEntity>
Tshortcut togetReference(Class, long)) cause this will be heavily needed in new API<T extends IBaseEntity>
List<T>shortcut togetReference(Class, long)) cause this will be heavily needed in new API
-
Constructor Details
-
AbstractAPI
public AbstractAPI()
-
-
Method Details
-
getFromId
public <T extends IBaseEntity> T getFromId(Class<T> entityClass, long entityId) throws EntityNotFoundException returns a persistent entity for given class with given id. Loads from database if the entity is already in cache of the persistence provider. Use this method if you have to read data from the entity.- Parameters:
entityClass- mandatoryentityId- mandatory- Returns:
- entity
- Throws:
EntityNotFoundException- if entity with given class and id does not exist in database
-
getReference
returns an instance of given entityClass if the entity is already in cache of the persistence provider, or a proxy object thereof. In either case entity is not loaded from database but can be used as if, any fields accessed will be loaded lazily from database. Use this method if you only need the Id or the reference to an entity for saving as property of another entity. Avoids unnecessary database access.- Parameters:
entityClass- mandatoryentityId- mandatory- Returns:
- instance of entityClass or hibernateProxy thereof.
-
ref
shortcut togetReference(Class, long)) cause this will be heavily needed in new API -
ref
shortcut togetReference(Class, long)) cause this will be heavily needed in new API -
getFromInternalDescription
public <T extends IEntity> T getFromInternalDescription(Class<T> entityClass, String internalDescription) throws EntityNotFoundException, NotUniqueResultException get entity through it's internal description.- Parameters:
entityClass- mandatoryinternalDescription- mandatory- Returns:
- entity if found and unique
- Throws:
EntityNotFoundExceptionNotUniqueResultException
-
getAll
searches all persistent entities of given class. same as getAll( entitiyClass, null). handle with care! do not use for entities where potentially a huge number exists. the system returns all loaded entities without paging.- Parameters:
entityClass- mandatory- Returns:
- List of found entities or empty list if found none
-
getAll
public <T extends IBaseEntity> List<T> getAll(Class<T> entityClass, mc.core.system.search.SearchFilter filter) searches for all persistent entities of given class according to criteria in search filter if given, otherwise for all. If usePaging set to true in searchFilter initiates display of results in pages by first getting the count of all results for the query and then performing the query and storing it in the sessionData. Only the first page of results according to pageSize in searchFilter is returned. Subsequent calls to getPage() or getResults() return the corresponding part of the result. To obtain full information about the search result callBaseAPI#getSearchResult(String)- Parameters:
entityClass- mandatoryfilter- optional- Returns:
- list of found entities or empty list if found none
-