Class AbstractDaoRestServiceWithDTO<T,​D,​Q,​K extends Serializable,​I extends 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 Serializable,​I extends Serializable>
    extends Object
    Abstract class for easily implemented V2 endpoints.
    Author:
    Seth Leger, Alejandro Galue
    • Constructor Detail

      • AbstractDaoRestServiceWithDTO

        public AbstractDaoRestServiceWithDTO()
    • Method Detail

      • getDao

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

        protected abstract Class<T> getDaoClass()
      • getQueryBeanClass

        protected abstract Class<Q> getQueryBeanClass()
      • getCriteriaBuilder

        protected abstract CriteriaBuilder getCriteriaBuilder​(javax.ws.rs.core.UriInfo uriInfo)
      • 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 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

        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.
      • mapDTOToEntity

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