Package org.opennms.web.rest.v2
Class AbstractDaoRestServiceWithDTO<T,D,Q,K extends Serializable,I extends Serializable>
- java.lang.Object
-
- org.opennms.web.rest.v2.AbstractDaoRestServiceWithDTO<T,D,Q,K,I>
-
- Type Parameters:
T
- Entity object (eg. OnmsEvent)D
- DTO object (eg. EventDTO). This is the type of object that will be transfered to and from the client. Mapping to and from the entity objects is delegated to the implementation.Q
- Query bean. This can be the same as the entity object if the object is a simple bean but for types with more than one level of bean properties, it makes sense to use a custom query bean or Apache CXF'sSearchBean
.K
- Type of the primary key of the entity in the database (eg. Integer).I
- Object Index (typically the same as the primary key, but can be different in some cases).
- Direct Known Subclasses:
AbstractDaoRestService
,AlarmRestService
,EventRestService
@Transactional public abstract class AbstractDaoRestServiceWithDTO<T,D,Q,K extends Serializable,I extends Serializable> extends Object
Abstract class for easily implemented V2 endpoints.- Author:
- Seth Leger, Alejandro Galue
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
DEFAULT_LIMIT
-
Constructor Summary
Constructors Constructor Description AbstractDaoRestServiceWithDTO()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static void
applyLimitOffsetOrderBy(javax.ws.rs.core.MultivaluedMap<String,String> p, CriteriaBuilder builder)
javax.ws.rs.core.Response
create(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, D object)
protected abstract JaxbListWrapper<D>
createListWrapper(Collection<D> list)
javax.ws.rs.core.Response
createSpecific()
javax.ws.rs.core.Response
delete(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, I id)
javax.ws.rs.core.Response
deleteMany(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)
protected javax.ws.rs.core.Response
doCreate(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, T object)
protected void
doDelete(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, T object)
protected abstract T
doGet(javax.ws.rs.core.UriInfo uriInfo, I id)
protected javax.ws.rs.core.Response
doUpdate(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, K key, T targetObject)
protected javax.ws.rs.core.Response
doUpdateProperties(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, T targetObject, MultivaluedMapImpl params)
javax.ws.rs.core.Response
get(javax.ws.rs.core.UriInfo uriInfo, I id)
javax.ws.rs.core.Response
get(javax.ws.rs.core.UriInfo uriInfo, org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)
javax.ws.rs.core.Response
getCount(javax.ws.rs.core.UriInfo uriInfo, org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)
protected Criteria
getCriteria(javax.ws.rs.core.UriInfo uriInfo, org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)
protected Map<String,CriteriaBehavior<?>>
getCriteriaBehaviors()
Map CXF query bean properties to Criteria property names, conversions, and actions.protected abstract CriteriaBuilder
getCriteriaBuilder(javax.ws.rs.core.UriInfo uriInfo)
protected abstract OnmsDao<T,K>
getDao()
protected abstract Class<T>
getDaoClass()
protected javax.ws.rs.WebApplicationException
getException(javax.ws.rs.core.Response.Status status, String msg, String... params)
javax.ws.rs.core.Response
getProperties(String query)
javax.ws.rs.core.Response
getPropertyValues(String propertyId, String query, Integer limit)
protected abstract Class<Q>
getQueryBeanClass()
protected Set<SearchProperty>
getQueryProperties()
Get a list of query properties that this endpoint supports for FIQL expressions andorderBy
expressions.protected Map<String,String>
getSearchBeanPropertyMap()
Map properties in the search expression to bean properties in the query capture bean.abstract T
mapDTOToEntity(D dto)
Map the given instance of the DTO to the corresponding entity.abstract D
mapEntityToDTO(T entity)
Map the given instance of the entity to the corresponding DTO.protected void
sendEvent(Event event)
javax.ws.rs.core.Response
update(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, K id, T object)
javax.ws.rs.core.Response
updateMany(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, org.apache.cxf.jaxrs.ext.search.SearchContext searchContext, MultivaluedMapImpl params)
javax.ws.rs.core.Response
updateProperties(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, I id, MultivaluedMapImpl params)
protected void
writeLock()
protected void
writeUnlock()
-
-
-
Field Detail
-
DEFAULT_LIMIT
protected static final int DEFAULT_LIMIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCriteriaBuilder
protected abstract CriteriaBuilder getCriteriaBuilder(javax.ws.rs.core.UriInfo uriInfo)
-
createListWrapper
protected abstract JaxbListWrapper<D> createListWrapper(Collection<D> list)
-
writeLock
protected final void writeLock()
-
writeUnlock
protected final void writeUnlock()
-
doCreate
protected javax.ws.rs.core.Response doCreate(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, T object)
-
doUpdate
protected javax.ws.rs.core.Response doUpdate(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, K key, T targetObject)
-
doUpdateProperties
protected javax.ws.rs.core.Response doUpdateProperties(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, T targetObject, MultivaluedMapImpl params)
-
doDelete
protected void doDelete(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, T object)
-
getQueryProperties
protected Set<SearchProperty> getQueryProperties()
Get a list of query properties that this endpoint supports for FIQL expressions and
orderBy
expressions.- Returns:
-
getSearchBeanPropertyMap
protected Map<String,String> getSearchBeanPropertyMap()
Map properties in the search expression to bean properties in the query capture bean. This is identical to using the
search.bean.property.map
context property but allows us to specify a different set of mappings for each service endpoint.- Key: Query property name
- Value: Bean property path
- Returns:
-
getCriteriaBehaviors
protected Map<String,CriteriaBehavior<?>> getCriteriaBehaviors()
Map CXF query bean properties to Criteria property names, conversions, and actions. In the absence of a mapping, the query bean property will be specified directly as a Criteria property with the same name.
- Key: CXF query property name
- Value:
CriteriaBehavior
to execute when this search term is specified
- Returns:
-
getCriteria
protected Criteria getCriteria(javax.ws.rs.core.UriInfo uriInfo, org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)
-
get
@GET @Produces({"application/json","application/xml","application/atom+xml"}) public javax.ws.rs.core.Response get(@Context javax.ws.rs.core.UriInfo uriInfo, @Context org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)
-
getCount
@GET @Path("count") @Produces("text/plain") public javax.ws.rs.core.Response getCount(@Context javax.ws.rs.core.UriInfo uriInfo, @Context org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)
-
getProperties
@GET @Path("properties") @Produces({"application/json","application/xml"}) public javax.ws.rs.core.Response getProperties(@QueryParam("q") String query)
-
getPropertyValues
@GET @Path("properties/{propertyId}") @Produces({"application/json","application/xml"}) public javax.ws.rs.core.Response getPropertyValues(@PathParam("propertyId") String propertyId, @QueryParam("q") String query, @QueryParam("limit") Integer limit)
-
get
@GET @Path("{id}") @Produces({"application/json","application/xml","application/atom+xml"}) public javax.ws.rs.core.Response get(@Context javax.ws.rs.core.UriInfo uriInfo, @PathParam("id") I id)
-
createSpecific
@POST @Path("{id}") public javax.ws.rs.core.Response createSpecific()
-
create
@POST @Consumes({"application/json","application/xml"}) public javax.ws.rs.core.Response create(@Context javax.ws.rs.core.SecurityContext securityContext, @Context javax.ws.rs.core.UriInfo uriInfo, D object)
-
updateMany
@PUT @Consumes("application/x-www-form-urlencoded") public javax.ws.rs.core.Response updateMany(@Context javax.ws.rs.core.SecurityContext securityContext, @Context javax.ws.rs.core.UriInfo uriInfo, @Context org.apache.cxf.jaxrs.ext.search.SearchContext searchContext, MultivaluedMapImpl params)
-
update
@PUT @Consumes({"application/json","application/xml"}) @Path("{id}") public javax.ws.rs.core.Response update(@Context javax.ws.rs.core.SecurityContext securityContext, @Context javax.ws.rs.core.UriInfo uriInfo, @PathParam("id") K id, T object)
-
updateProperties
@PUT @Consumes("application/x-www-form-urlencoded") @Path("{id}") public javax.ws.rs.core.Response updateProperties(@Context javax.ws.rs.core.SecurityContext securityContext, @Context javax.ws.rs.core.UriInfo uriInfo, @PathParam("id") I id, MultivaluedMapImpl params)
-
deleteMany
@DELETE public javax.ws.rs.core.Response deleteMany(@Context javax.ws.rs.core.SecurityContext securityContext, @Context javax.ws.rs.core.UriInfo uriInfo, @Context org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)
-
delete
@DELETE @Path("{id}") public javax.ws.rs.core.Response delete(@Context javax.ws.rs.core.SecurityContext securityContext, @Context javax.ws.rs.core.UriInfo uriInfo, @PathParam("id") I id)
-
applyLimitOffsetOrderBy
public static void applyLimitOffsetOrderBy(javax.ws.rs.core.MultivaluedMap<String,String> p, CriteriaBuilder builder)
-
sendEvent
protected void sendEvent(Event event)
-
getException
protected javax.ws.rs.WebApplicationException getException(javax.ws.rs.core.Response.Status status, String msg, String... params) throws javax.ws.rs.WebApplicationException
- Throws:
javax.ws.rs.WebApplicationException
-
mapEntityToDTO
public abstract D mapEntityToDTO(T entity)
Map the given instance of the entity to the corresponding DTO.
-
-