Class AbstractAPI

java.lang.Object
mc.core.system.base.BaseBean
mc.core.domain.base.AbstractAPI
Direct Known Subclasses:
AssetRI, BaseRI, CCRI, ChannelRI, GenericRI, I18nRI, SystemRI

public abstract class AbstractAPI extends mc.core.system.base.BaseBean
abstract base class for all APIs. uses services directly where possible for efficiency
  • 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 - mandatory
      entityId - mandatory
      Returns:
      entity
      Throws:
      EntityNotFoundException - if entity with given class and id does not exist in database
    • getReference

      public <T extends IBaseEntity> T getReference(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. 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 - mandatory
      entityId - mandatory
      Returns:
      instance of entityClass or hibernateProxy thereof.
    • ref

      public <T extends IBaseEntity> T ref(Class<T> entityClass, long entityId)
      shortcut to getReference(Class, long)) cause this will be heavily needed in new API
    • ref

      public <T extends IBaseEntity> List<T> ref(Class<T> entityClass, List<Long> entityIds)
      shortcut to getReference(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 - mandatory
      internalDescription - mandatory
      Returns:
      entity if found and unique
      Throws:
      EntityNotFoundException
      NotUniqueResultException
    • getAll

      public <T extends IBaseEntity> List<T> getAll(Class<T> entityClass)
      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 call BaseAPI#getSearchResult(String)
      Parameters:
      entityClass - mandatory
      filter - optional
      Returns:
      list of found entities or empty list if found none