Class BaseRI
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends IBaseEntity>
voidDELETE: {entityName}/{key}<T extends IBaseEntity>
javax.ws.rs.core.ResponsePOST: {entityName}/{key}?data=[json]<T extends IBaseEntity>
javax.ws.rs.core.ResponsegetFromKey(String entityName, String key, String field) GET: {entityName}/{key}<T extends IBaseEntity>
javax.ws.rs.core.ResponsePOST: {entityName}?data=[json]<T extends IBaseEntity>
javax.ws.rs.core.Responsesearch(String entityName, String filterAsJson, String field, String param, boolean fulltext, int start, int end, String resultId) GET: {entityName}?filter|field|param&fulltext=true|false&start=0&end=30&resultId=[resultId]<T extends IBaseEntity>
javax.ws.rs.core.ResponseGET: {entityName}/{key}/usageMethods inherited from class mc.core.domain.base.AbstractAPI
getAll, getAll, getFromId, getFromInternalDescription, getReference, ref, ref
-
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 casekey- PathParam, mandatory. unique key to identify entityfield- 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 mappingIOException- 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]¶m=[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 casefilterAsJson- search filter as jsonfield- simple search field. used if filter is not set. optionalparam- simple search param. used if filter is not set. optionalfulltext- use fulltext search if available for entity. default is false. optionalstart- start index of result. default is 0 if not set. optionalend- end index of result. get first page if not set. optionalresultId- 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 mappingIOException- 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 mappingIOException- if error on response writingException- 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 casekey- 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 mappingIOException- 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 casekey- 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}/usagereturn using classes with constraint field and count of using instances (checked through model constraints).
- Parameters:
entityName- simple class name in lower casekey- unique key to identify entity- Throws:
ApplicationException- if key is not valid or not unique
-