Class IncWorklistUpdateHandler


  • public class IncWorklistUpdateHandler
    extends AbstractIteratorHandler<CachingIncWorklistUpdate,​InitialIncWorklistUpdateData,​IncWorklistUpdateData>
    This class handles incremental worklist updates by assigning IDs to them and mapping these IDs to the respective incremental worklist update. This allows to use a UUID instead of a incremental worklist update instance and thus simplifying interfaces not supporting Java objects, for instance web services.
    All methods of this class (except init(IncrementalWorklistUpdate, Integer) require a UUID identifying the corresponding incremental worklist update. If the ID does not refer to an incremental worklist update, an IllegalArgumentException will be thrown.
    All handler incremental worklist updates will be CachingIncWorklistUpdate. This allows for iterating back and specifying the first item update which to retrieve.

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

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

    This class is thread-safe.

    • Field Detail

      • initialAliveTime

        protected final long initialAliveTime
        The time in milliseconds a wrapping caching incremental worklist update is alive.
      • aliveTimeExtension

        protected final long aliveTimeExtension
        The time in milliseconds to extend the alive time when accessing the wrapping caching incremental worklist update.
    • Constructor Detail

      • IncWorklistUpdateHandler

        public IncWorklistUpdateHandler​(long initialAliveTime,
                                        long aliveTimeExtension,
                                        LogService logService)
        Creates a new handler for incremental worklist updates.
        Parameters:
        initialAliveTime - The time in milliseconds a wrapping caching incremental worklist update is alive.
        aliveTimeExtension - The time in milliseconds to extend the alive time when accessing the wrapping caching incremental worklist update.
        logService - The log service to retrieve the logger for log messages from.
    • Method Detail

      • init

        @NotNull
        @Valid
        public @NotNull @Valid InitialIncWorklistUpdateData init​(@NotNull @Valid
                                                                 @NotNull @Valid IncrementalWorklistUpdate incWorklistUpdate,
                                                                 @Positive
                                                                 @Positive Integer count)
        Adds the designated incremental worklist update 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 update will be removed from this handler when it is closed. If all data of the incremental worklist update is transferred now, the incremental worklist update will be closed immediately.
        Parameters:
        incWorklistUpdate - The incremental worklist update to add to this handler.
        count - The amount of item updates to retrieve in forward direction. This has to be > 0 or null. If this is null, all item updates of the designated incremental worklist update will be returned and the incremental worklist update will be closed.
        Returns:
        The initial meta data of the incremental worklist update and the next n item updates of the designated incremental worklist update, where n is the specified count. In case of an insufficient amount of next item updates remaining only the available item updates will be returned. If there are no item updates, null will be returned. If no count or Integer.MAX_VALUE is specified, all item updates of the designated incremental worklist update will be returned at once and the incremental worklist update will be closed.
        Throws:
        IllegalArgumentException - If count is non-positive (<= 0), an IllegalArgumentException will be thrown.
        IllegalStateException - If the designated incremental worklist update has been closed implicitly, an IllegalStateException will be thrown on server side.
        de.aristaflow.adept2.model.communication.ServiceConnectionException - If the designated incremental worklist update has been closed implicitly, a ServiceConnectionException will be thrown on client side.
      • getNext

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

        protected IncWorklistUpdateData getNext​(UUID incUpdateId,
                                                CachingIncWorklistUpdate incWorklistUpdate,
                                                Integer count,
                                                Integer start)
        Calls IncrementalWorklistUpdate.getNext(int) or IncrementalWorklistUpdate.getAll() on the designated incremental worklist update. The alive time of the incremental worklist update will be extended in case of implicit extension. If all item udpates are requested now or the incremental worklist update has no updates at all, it will be set to closed at once. The caller of this method has to close the incremental worklist update!
        Parameters:
        incUpdateId - The ID of the incremental worklist update to forward the call to.
        incWorklistUpdate - The incremental worklist update to forward the call to.
        count - The amount of item updates to retrieve in forward direction. This has to be > 0 or null. If this is null, all item updates of the designated incremental worklist update will be returned.
        start - The index of the item update from which to retrieve the next count item updates when requesting a limited amount of item updates (count > 0). 0 is the index of the first item update. This has to be >= 0 and it must not be bigger than the amounts of item updates in the designated incremental worklist update. If this is null, the next count item updates will be returned.
        Returns:
        Some meta data of the incremental worklist update and the next n item updates of the designated incremental worklist update, where n is the specified count. In case of an insufficient amount of next item updates remaining only the available item updates (or no item updates) will be returned.
        Throws:
        IllegalArgumentException - If the designated ID does not refer to an IncrementalWorklistUpdate 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 item updates of the designated incremental worklist update, an IllegalArgumentException will be thrown.
        IllegalStateException - If the designated incremental worklist update has been closed implicitly, an IllegalStateException will be thrown on server side.
        de.aristaflow.adept2.model.communication.ServiceConnectionException - If the designated incremental worklist update has been closed implicitly, a ServiceConnectionException will be thrown on client side.
      • getPrevious

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