Class IncWorklistUpdateHandler
- java.lang.Object
-
- de.aristaflow.ilm.model.common.collection.AbstractIteratorHandler<IteratorWrapper<CachingIncWorklistUpdate>,InitialIncWorklistUpdateData,IncWorklistUpdateData>
-
- de.aristaflow.ilm.model.worklistmodel.IncWorklistUpdateHandler
-
public class IncWorklistUpdateHandler extends AbstractIteratorHandler<IteratorWrapper<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 aUUID
instead of a incremental worklist update instance and thus simplifying interfaces not supporting Java objects, for instance web services.
All methods of this class (exceptinit(IncrementalWorklistUpdate, Integer)
require a UUID identifying the corresponding incremental worklist update. If the ID does not refer to an incremental worklist update, anIllegalArgumentException
will be thrown.
All handler incremental worklist updates will beCachingIncWorklistUpdate
. This allows for iterating back and specifying the first item update which to retrieve.All handled incremental worklist updates have an implicit alive time. This is extended each time an incremental worklist is accessed (except for
drop(UUID)
). Nonetheless. it can be explicitly dropped any time.This handler tries to minimise dropping effort for incremental worklist updates. It will drop them implicitly if
- all updates are transferred initially,
- all updates are retrieved at once (
count
isnull
), - the incremental worklist update contains no data at all.
null
will be returned instead ofIncWorklistUpdateData
if there are no updates (for the current iteration). If the incremental worklist update is dropped on-the-fly, anIncWorklistUpdateData
will be returned even if there is no content.This class is thread-safe.
-
-
Field Summary
-
Fields inherited from class de.aristaflow.ilm.model.common.collection.AbstractIteratorHandler
aliveTimeExtension, dataCreator, initDataCreator, iterators, removerService
-
-
Constructor Summary
Constructors Constructor Description IncWorklistUpdateHandler(long aliveTimeExtension, LogService logService)
Creates a new handler for incremental worklist updates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
drop(@NotNull UUID incUpdateId)
CallsIncrementalWorklistUpdate.drop()
on the designated incremental worklist update and removes it from this handler.@NotNull @Valid IncWorklistUpdateData
getNext(@NotNull UUID incUpdateId, @Positive Integer count, @PositiveOrZero Integer start)
CallsIncrementalWorklistUpdate.getNext(int)
on the designated incremental worklist update.protected IncWorklistUpdateData
getNext(UUID incUpdateId, IteratorWrapper<CachingIncWorklistUpdate> ir, Integer count, Integer start)
CallsIncrementalWorklistUpdate.getNext(int)
orIncrementalWorklistUpdate.getAll()
on the designated incremental worklist update.@NotNull @Valid IncWorklistUpdateData
getPrevious(@NotNull UUID incUpdateId, @NotNull @Positive Integer count)
CallsCachingIncWorklistUpdate.getPrevious(int)
on the designated incremental worklist update.@NotNull @Valid InitialIncWorklistUpdateData
init(@NotNull @Valid IncrementalWorklistUpdate incWorklistUpdate, @Positive Integer count)
Adds the designated incremental worklist update to this handler, creates an ID for it and callsgetNext(UUID, Integer, Integer)
with the designated parameters andstart
=null
.-
Methods inherited from class de.aristaflow.ilm.model.common.collection.AbstractIteratorHandler
getIterator, shutdown
-
-
-
-
Constructor Detail
-
IncWorklistUpdateHandler
public IncWorklistUpdateHandler(long aliveTimeExtension, LogService logService)
Creates a new handler for incremental worklist updates.- Parameters:
aliveTimeExtension
- The time in milliseconds to extend the alive time of the incremental worklist update implicitly.logService
- The log service to retrieve the logger for the executor 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 callsgetNext(UUID, Integer, Integer)
with the designated parameters andstart
=null
. The added incremental worklist update will be removed from this handler when it is dropped. If all data of the incremental worklist update is transferred now, the incremental worklist update will be dropped 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
ornull
. If this isnull
, all item updates of the designated incremental worklist update will be returned and the incremental worklist update will be dropped.- 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 nocount
orInteger.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 dropped. - Throws:
IllegalArgumentException
- Ifcount
is non-positive (<= 0
), anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist update has been dropped implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist update has been dropped implicitly, aServiceConnectionException
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)
CallsIncrementalWorklistUpdate.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
ornull
. If this isnull
, all item updates of the designated incremental worklist update will be returned and the incremental worklist update will be dropped.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 isnull
, the nextcount
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
orInteger.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 anIncrementalWorklistUpdate
known by this handler, anIllegalArgumentException
will be thrown.IllegalArgumentException
- Ifcount
is non-positive (<= 0
) orstart
is negative (< 0
) orstart
refers to an index that is bigger than the amount of item updates of the designated incremental worklist update, anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist update has been dropped implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist update has been dropped implicitly, aServiceConnectionException
will be thrown on client side.
-
getNext
protected IncWorklistUpdateData getNext(UUID incUpdateId, IteratorWrapper<CachingIncWorklistUpdate> ir, Integer count, Integer start)
CallsIncrementalWorklistUpdate.getNext(int)
orIncrementalWorklistUpdate.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 dropped at once. The caller of this method has to drop the incremental worklist update!- Parameters:
incUpdateId
- The ID of the incremental worklist update to forward the call to.ir
- 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
ornull
. If this isnull
, 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 isnull
, the nextcount
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 anIncrementalWorklistUpdate
known by this handler, anIllegalArgumentException
will be thrown.IllegalArgumentException
- Ifcount
is non-positive (<= 0
) orstart
is negative (< 0
) orstart
refers to an index that is bigger than the amount of item updates of the designated incremental worklist update, anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist update has been dropped implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist update has been dropped implicitly, aServiceConnectionException
will be thrown on client side.
-
getPrevious
@NotNull @Valid public @NotNull @Valid IncWorklistUpdateData getPrevious(@NotNull @NotNull UUID incUpdateId, @NotNull @Positive @NotNull @Positive Integer count)
CallsCachingIncWorklistUpdate.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 anIncrementalWorklistUpdate
known by this handler, anIllegalArgumentException
will be thrown.IllegalArgumentException
- If the designated incremental worklist update does not have any previous item updates or count is non-positive (<= 0), anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist update has been dropped implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist update has been dropped implicitly, aServiceConnectionException
will be thrown on client side.
-
drop
public void drop(@NotNull @NotNull UUID incUpdateId)
CallsIncrementalWorklistUpdate.drop()
on the designated incremental worklist update and removes it from this handler.- Parameters:
incUpdateId
- The ID of the incremental worklist update to forward the call to.- Throws:
IllegalArgumentException
- If the designated ID does not refer to anIncrementalWorklistUpdate
known by this handler, anIllegalArgumentException
will be thrown.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist has been dropped implicitly, aServiceConnectionException
will be thrown on client side.
-
-