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 intDEFAULT_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 voidapplyLimitOffsetOrderBy(javax.ws.rs.core.MultivaluedMap<String,String> p, CriteriaBuilder builder)javax.ws.rs.core.Responsecreate(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.ResponsecreateSpecific()javax.ws.rs.core.Responsedelete(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, I id)javax.ws.rs.core.ResponsedeleteMany(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.ResponsedoCreate(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, T object)protected voiddoDelete(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, T object)protected abstract TdoGet(javax.ws.rs.core.UriInfo uriInfo, I id)protected javax.ws.rs.core.ResponsedoUpdate(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, K key, T targetObject)protected javax.ws.rs.core.ResponsedoUpdateProperties(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, T targetObject, MultivaluedMapImpl params)javax.ws.rs.core.Responseget(javax.ws.rs.core.UriInfo uriInfo, I id)javax.ws.rs.core.Responseget(javax.ws.rs.core.UriInfo uriInfo, org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)javax.ws.rs.core.ResponsegetCount(javax.ws.rs.core.UriInfo uriInfo, org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)protected CriteriagetCriteria(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 CriteriaBuildergetCriteriaBuilder(javax.ws.rs.core.UriInfo uriInfo)protected abstract OnmsDao<T,K>getDao()protected abstract Class<T>getDaoClass()protected javax.ws.rs.WebApplicationExceptiongetException(javax.ws.rs.core.Response.Status status, String msg, String... params)javax.ws.rs.core.ResponsegetProperties(String query)javax.ws.rs.core.ResponsegetPropertyValues(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 andorderByexpressions.protected Map<String,String>getSearchBeanPropertyMap()Map properties in the search expression to bean properties in the query capture bean.abstract TmapDTOToEntity(D dto)Map the given instance of the DTO to the corresponding entity.abstract DmapEntityToDTO(T entity)Map the given instance of the entity to the corresponding DTO.protected voidsendEvent(Event event)javax.ws.rs.core.Responseupdate(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, K id, T object)javax.ws.rs.core.ResponseupdateMany(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.ResponseupdateProperties(javax.ws.rs.core.SecurityContext securityContext, javax.ws.rs.core.UriInfo uriInfo, I id, MultivaluedMapImpl params)protected voidwriteLock()protected voidwriteUnlock()
-
-
-
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
orderByexpressions.- 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.mapcontext 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:
CriteriaBehaviorto 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
public javax.ws.rs.core.Response get(@Context javax.ws.rs.core.UriInfo uriInfo, @Context org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)
-
getCount
public javax.ws.rs.core.Response getCount(@Context javax.ws.rs.core.UriInfo uriInfo, @Context org.apache.cxf.jaxrs.ext.search.SearchContext searchContext)
-
getProperties
public javax.ws.rs.core.Response getProperties(String query)
-
getPropertyValues
public javax.ws.rs.core.Response getPropertyValues(String propertyId, String query, Integer limit)
-
get
public javax.ws.rs.core.Response get(@Context javax.ws.rs.core.UriInfo uriInfo, I id)
-
createSpecific
public javax.ws.rs.core.Response createSpecific()
-
create
public javax.ws.rs.core.Response create(@Context javax.ws.rs.core.SecurityContext securityContext, @Context javax.ws.rs.core.UriInfo uriInfo, D object)
-
updateMany
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
public javax.ws.rs.core.Response update(@Context javax.ws.rs.core.SecurityContext securityContext, @Context javax.ws.rs.core.UriInfo uriInfo, K id, T object)
-
updateProperties
public javax.ws.rs.core.Response updateProperties(@Context javax.ws.rs.core.SecurityContext securityContext, @Context javax.ws.rs.core.UriInfo uriInfo, I id, MultivaluedMapImpl params)
-
deleteMany
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
public javax.ws.rs.core.Response delete(@Context javax.ws.rs.core.SecurityContext securityContext, @Context javax.ws.rs.core.UriInfo uriInfo, 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.
-
-