Class AbstractDaoRestServiceWithDTO<T,​D,​Q,​K extends java.io.Serializable,​I extends java.io.Serializable>

  • 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's SearchBean.
    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 java.io.Serializable,​I extends java.io.Serializable>
    extends java.lang.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  
    • 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<java.lang.String,​java.lang.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​(java.util.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 java.util.Map<java.lang.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 java.lang.Class<T> getDaoClass()  
      protected javax.ws.rs.WebApplicationException getException​(javax.ws.rs.core.Response.Status status, java.lang.String msg, java.lang.String... params)  
      javax.ws.rs.core.Response getProperties​(java.lang.String query)  
      javax.ws.rs.core.Response getPropertyValues​(java.lang.String propertyId, java.lang.String query, java.lang.Integer limit)  
      protected abstract java.lang.Class<Q> getQueryBeanClass()  
      protected java.util.Set<SearchProperty> getQueryProperties()
      Get a list of query properties that this endpoint supports for FIQL expressions and orderBy expressions.
      protected java.util.Map<java.lang.String,​java.lang.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()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractDaoRestServiceWithDTO

        public AbstractDaoRestServiceWithDTO()
    • Method Detail

      • getDao

        protected abstract OnmsDao<T,​K> getDao()
      • getDaoClass

        protected abstract java.lang.Class<T> getDaoClass()
      • getQueryBeanClass

        protected abstract java.lang.Class<Q> getQueryBeanClass()
      • getCriteriaBuilder

        protected abstract CriteriaBuilder getCriteriaBuilder​(javax.ws.rs.core.UriInfo uriInfo)
      • createListWrapper

        protected abstract JaxbListWrapper<D> createListWrapper​(java.util.Collection<D> list)
      • doGet

        protected abstract T doGet​(javax.ws.rs.core.UriInfo uriInfo,
                                   I id)
      • 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 java.util.Set<SearchProperty> getQueryProperties()

        Get a list of query properties that this endpoint supports for FIQL expressions and orderBy expressions.

        Returns:
      • getSearchBeanPropertyMap

        protected java.util.Map<java.lang.String,​java.lang.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 java.util.Map<java.lang.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

        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​(java.lang.String query)
      • getPropertyValues

        public javax.ws.rs.core.Response getPropertyValues​(java.lang.String propertyId,
                                                           java.lang.String query,
                                                           java.lang.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<java.lang.String,​java.lang.String> p,
                                                   CriteriaBuilder builder)
      • sendEvent

        protected void sendEvent​(Event event)
      • getException

        protected javax.ws.rs.WebApplicationException getException​(javax.ws.rs.core.Response.Status status,
                                                                   java.lang.String msg,
                                                                   java.lang.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.
      • mapDTOToEntity

        public abstract T mapDTOToEntity​(D dto)
        Map the given instance of the DTO to the corresponding entity.