Class BaseRI

java.lang.Object
mc.core.system.base.BaseBean
mc.core.domain.base.AbstractAPI
mc.core.domain.base.BaseRI

@Path("/") @Produces("application/json") public class BaseRI extends AbstractAPI
The base RI class exposes relevant methods of the base API as REST enabled endpoints.
  • Constructor Details

    • BaseRI

      public BaseRI()
  • Method Details

    • getFromKey

      @GET @Path("{entityName}/{key}") public <T extends IBaseEntity> javax.ws.rs.core.Response getFromKey(@PathParam("entityName") String entityName, @PathParam("key") String key, @QueryParam("field") String field) throws ApplicationException, IOException
      GET: {entityName}/{key}

      basic method to get data for an entity.

      Parameters:
      entityName - PathParam, mandatory. simple class name in lower case
      key - PathParam, mandatory. unique key to identify entity
      field - QueryParam, optional. key field for identifying entity. possible values are: id (IBaseEntity), internalDescription (IEntity), externalKey (ComplexEntity). else the usual getFromKey() rules apply
      Returns:
      data for entity
      Throws:
      ApplicationException - if key is not valid or not unique, or error in mapping
      IOException - if error on response writing
    • search

      @GET @Path("{entityName}") public <T extends IBaseEntity> javax.ws.rs.core.Response search(@PathParam("entityName") String entityName, @QueryParam("filter") String filterAsJson, @QueryParam("field") String field, @QueryParam("param") String param, @QueryParam("fulltext") boolean fulltext, @QueryParam("start") int start, @QueryParam("end") @DefaultValue("-1") int end, @QueryParam("resultId") String resultId) throws ApplicationException, IOException
      GET: {entityName}?filter|field|param&fulltext=true|false&start=0&end=30&resultId=[resultId]

      basic method to search for entities. use cases:

      search with a filter json definition:
      GET: {entityName}?filter=[filterAsJson]
      example: filter to search by referenced entity and its key-param. field can also be a property chain of target entity:
      GET: {entityName}?filter={ "criteria" : [{ "field":"[fieldname of referenced entity|propertyChain]", "param": "[key of referenced entity]" }]}
      If possible the id (without quotes) should be used because the key-param necessitates an additional database call.

      simple search with field and param. field can be a property chain of target entity:
      GET: {entityName}?field=[propertyChain]&param=[param]

      simple search with param. default filter for field is used:
      GET: {entityName}?param=[param]

      get all (result limited to start/end or first page if not set):
      GET: {entityName}?start=[startIdx]&end=[endIdx]

      Parameters:
      entityName - simple class name in lower case
      filterAsJson - search filter as json
      field - simple search field. used if filter is not set. optional
      param - simple search param. used if filter is not set. optional
      fulltext - use fulltext search if available for entity. default is false. optional
      start - start index of result. default is 0 if not set. optional
      end - end index of result. get first page if not set. optional
      resultId - resultId from previous search (only stateless session). must be valid if given. optional
      Returns:
      map with search result info and data for result entities
      Throws:
      ApplicationException - if error in filter or entity mapping
      IOException - if error on response writing
    • insert

      @POST @Path("{entityName}") public <T extends IBaseEntity> javax.ws.rs.core.Response insert(@PathParam("entityName") String entityName) throws ApplicationException, IOException, Exception
      POST: {entityName}?data=[json]

      EXPERT: basic insert method. used if no dedicated insert method for entity exists in RI.

      Parameters:
      entityName - simple class name in lower case
      Returns:
      data for inserted entity
      Throws:
      ApplicationException - if error on insert or entity mapping
      IOException - if error on response writing
      Exception - if entity class is abstract
    • edit

      @POST @Path("{entityName}/{key}") public <T extends IBaseEntity> javax.ws.rs.core.Response edit(@PathParam("entityName") String entityName, @PathParam("key") String key) throws ApplicationException, IOException
      POST: {entityName}/{key}?data=[json]

      EXPERT: basic edit method. used if no dedicated edit method for entity exists in RI.

      Parameters:
      entityName - simple class name in lower case
      key - unique key to identify entity
      Returns:
      data for entity
      Throws:
      ApplicationException - if key is not valid or not unique, or error on edit or entity mapping
      IOException - if error on response writing
    • delete

      @DELETE @Path("{entityName}/{key}") public <T extends IBaseEntity> void delete(@PathParam("entityName") String entityName, @PathParam("key") String key) throws ApplicationException
      DELETE: {entityName}/{key}

      EXPERT: basic delete method. used if no dedicated delete method for entity exists in RI.

      Parameters:
      entityName - simple class name in lower case
      key - unique key to identify entity
      Throws:
      ApplicationException - if key is not valid or not unique, or error on delete
    • usage

      @GET @Path("{entityName}/{key}/usage") public <T extends IBaseEntity> javax.ws.rs.core.Response usage(@PathParam("entityName") String entityName, @PathParam("key") String key) throws ApplicationException
      GET: {entityName}/{key}/usage

      return using classes with constraint field and count of using instances (checked through model constraints).

      Parameters:
      entityName - simple class name in lower case
      key - unique key to identify entity
      Throws:
      ApplicationException - if key is not valid or not unique