Class IncWorklistHandler<WJ extends WorklistItem,​WI extends WorklistItem,​I extends InitialIncWorklistData<WI>,​N extends IncWorklistData<WI>>

  • Type Parameters:
    WJ - The type of WorklistItems of the Java model provided by the handled worklists.
    WI - The type of WorklistItems of the ILM provided by the handled worklists.
    I - The type of the initial data provided when requesting the incremental worklist.
    N - The type of the incremental worklist data when iterating.

    public class IncWorklistHandler<WJ extends WorklistItem,​WI extends WorklistItem,​I extends InitialIncWorklistData<WI>,​N extends IncWorklistData<WI>>
    extends AbstractIteratorHandler<IncrementalWorklist<? extends WJ>,​I,​N>
    This class handles incremental worklists by assigning IDs to them and mapping these IDs to the respective incremental worklist. This allows to use a UUID instead of a incremental worklist instance and thus simplifying interfaces not supporting Java objects, for instance web services.
    All methods of this class (except init(IncrementalWorklist, Integer) require a UUID identifying the corresponding incremental worklist. If the ID does not refer to an incremental worklist, an IllegalArgumentException will be thrown.

    This handler tries to minimise closing effort for incremental worklists. It will close them implicitly if

    • all items are transferred initially,
    • all items are requested at once (count is null), or
    • the incremental worklist contains no items at all.
    Usually null will be returned instead of IncWorklistData if there are no items (for the current iteration). If the incremental worklist is closed on-the-fly, an IncWorklistData will be returned even if there is no content.

    This class is thread-safe.

    • Constructor Detail

      • IncWorklistHandler

        public IncWorklistHandler​(Function<WJ,​WI> transformation,
                                  Supplier<I> initDataCreator,
                                  Supplier<N> dataCreator,
                                  LogService logService)
        Creates a new handler for incremental worklists.
        Parameters:
        transformation - The function transforming from the Java-model to ILM.
        initDataCreator - The creator for the data provided initially when requesting the incremental worklist.
        dataCreator - The creator for the data provided when iterating.
        logService - The log service to retrieve the logger for log messages from.
    • Method Detail

      • init

        @NotNull
        @Valid
        public I init​(IncrementalWorklist<? extends WJ> incWorklist,
                      @Positive
                      @Positive Integer count)
        Adds the designated incremental worklist to this handler, creates an ID for it and calls getNext(UUID, Integer, Integer) with the designated parameters and start = null. The added incremental worklist will be removed from this handler when it is closed. If all data of the incremental worklist is transferred now, the incremental worklist will be closed immediately.
        Parameters:
        incWorklist - The incremental worklist to add to this handler.
        count - The amount of worklist items to retrieve in forward direction. This has to be > 0 or null. If this is null, all worklist items of the designated incremental worklist will be returned.
        Returns:
        The initial meta data of the incremental worklist and the next n worklist items of the designated incremental worklist, where n is the specified count. In case of an insufficient amount of next worklist items remaining only the available worklist items will be returned. If there are no worklist items, null will be returned. If no count or Integer.MAX_VALUE is specified, all worklist items of the designated incremental worklist will be returned at once and the incremental worklist will be closed.
        Throws:
        IllegalArgumentException - If count is non-positive (<= 0), an IllegalArgumentException will be thrown.
        IllegalStateException - If the designated incremental worklist has been closed implicitly, an IllegalStateException will be thrown on server side.
        de.aristaflow.adept2.model.communication.ServiceConnectionException - If the designated incremental worklist has been closed implicitly, a ServiceConnectionException will be thrown on client side.
      • getNext

        @NotNull
        @Valid
        public N getNext​(@NotNull
                         @NotNull UUID incWorklistId,
                         @Positive
                         @Positive Integer count,
                         @PositiveOrZero
                         @PositiveOrZero Integer start)
        Calls IncrementalWorklist.getNext(int) on the designated incremental worklist. The alive time of the incremental worklist will be extended in case of implicit extension.
        Parameters:
        incWorklistId - The ID of the incremental worklist to forward the call to.
        count - The amount of worklist items to retrieve in forward direction. This has to be > 0 or null. If this is null, all worklist items of the designated incremental worklist will be returned (Integer.MAX_VALUE) and the incremental worklist will be closed.
        start - The index of the worklist item from which to retrieve the next count worklist items when requesting a limited amount of worklist items (count > 0). 0 is the index of the first worklist item. This has to be >= 0 and it must not be bigger than the amounts of worklist items in the designated incremental worklist. If this is null, the next count worklist items will be returned.
        Returns:
        Some meta data of the incremental worklist and the next n worklist items of the designated incremental worklist, where n is the specified count. In case of an insufficient amount of next worklist items remaining only the available worklist items (or no worklist items) will be returned. If no count or Integer.MAX_VALUE is specified, all remaining worklist items of the designated incremental worklist will be returned at once.
        Throws:
        IllegalArgumentException - If the designated ID does not refer to an IncrementalWorklist known by this handler, an IllegalArgumentException will be thrown.
        IllegalArgumentException - If count is non-positive (<= 0) or start is negative (< 0) or start refers to an index that is bigger than the amount of worklist items of the designated incremental worklist, an IllegalArgumentException will be thrown.
        IllegalStateException - If the designated incremental worklist has been closed implicitly, an IllegalStateException will be thrown on server side.
        de.aristaflow.adept2.model.communication.ServiceConnectionException - If the designated incremental worklist has been closed implicitly, a ServiceConnectionException will be thrown on client side.
      • getNext

        protected N getNext​(UUID incWorklistId,
                            IncrementalWorklist<? extends WJ> iw,
                            Integer count,
                            Integer start)
        Calls IncrementalWorklist.getNext(int) on the designated incremental worklist. The alive time of the incremental worklist will be extended in case of implicit extension. If all items of the worklist are requested (count is null), it will be set to closed at once. The caller of this method has to close the incremental worklist!
        Parameters:
        incWorklistId - The ID of the incremental worklist to forward the call to.
        iw - The incremental worklist to forward the call to.
        count - The amount of worklist items to retrieve in forward direction. This has to be > 0 or null. If this is null, all worklist items of the designated incremental worklist will be returned (Integer.MAX_VALUE) and the incremental worklist will be closed.
        start - The index of the worklist item from which to retrieve the next count worklist items when requesting a limited amount of worklist items (count > 0). 0 is the index of the first worklist item. This has to be >= 0 and it must not be bigger than the amounts of worklist items in the designated incremental worklist. If this is null, the next count worklist items will be returned.
        Returns:
        Some meta data of the incremental worklist and the next n worklist items of the designated incremental worklist, where n is the specified count. In case of an insufficient amount of next worklist items remaining only the available worklist items (or no worklist items) will be returned.
        Throws:
        IllegalArgumentException - If the designated ID does not refer to an IncrementalWorklist known by this handler, an IllegalArgumentException will be thrown.
        IllegalArgumentException - If count is non-positive (<= 0) or start is negative (< 0) or start refers to an index that is bigger than the amount of worklist items of the designated incremental worklist, an IllegalArgumentException will be thrown.
        IllegalStateException - If the designated incremental worklist has been closed implicitly, an IllegalStateException will be thrown on server side.
        de.aristaflow.adept2.model.communication.ServiceConnectionException - If the designated incremental worklist has been closed implicitly, a ServiceConnectionException will be thrown on client side.
      • getPrevious

        @NotNull
        @Valid
        public N getPrevious​(@NotNull
                             @NotNull UUID incWorklistId,
                             @NotNull @Positive
                             @NotNull @Positive Integer count)
        Calls IncrementalWorklist.getPrevious(int) on the designated incremental worklist.
        Parameters:
        incWorklistId - The ID of the incremental worklist to forward the call to.
        count - The amount of worklist items to retrieve in backward direction. This has to be > 0.
        Returns:
        The ID of the incremental worklist and the previous n worklist items, where n is the specified count. The order corresponds to the one in the underlying data structure, that is previous worklist items in the returned list are also previous worklist items in the data structure. In case of an insufficient amount of previous worklist items remaining only the available worklist items will be returned. If there are no more previous worklist items, null will be returned as flat items.
        Throws:
        IllegalArgumentException - If the designated ID does not refer to an IncrementalWorklist known by this handler, an IllegalArgumentException will be thrown.
        IllegalArgumentException - If the designated incremental worklist does not have any previous worklist items or count is non-positive (<= 0), an IllegalArgumentException will be thrown.
        IllegalStateException - If the designated incremental worklist has been closed implicitly, an IllegalStateException will be thrown on server side.
        de.aristaflow.adept2.model.communication.ServiceConnectionException - If the designated incremental worklist has been closed implicitly, a ServiceConnectionException will be thrown on client side.