Class IncWorklistHandler<WJ extends WorklistItem,WI extends WorklistItem,I extends InitialIncWorklistData<WI>,N extends IncWorklistData<WI>>
- java.lang.Object
-
- de.aristaflow.ilm.model.common.collection.AbstractIteratorHandler<IncrementalWorklist<? extends WJ>,I,N>
-
- de.aristaflow.ilm.model.worklistmodel.IncWorklistHandler<WJ,WI,I,N>
-
- Type Parameters:
WJ
- The type ofWorklistItem
s of the Java model provided by the handled worklists.WI
- The type ofWorklistItem
s 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 aUUID
instead of a incremental worklist instance and thus simplifying interfaces not supporting Java objects, for instance web services.
All methods of this class (exceptinit(IncrementalWorklist, Integer)
require a UUID identifying the corresponding incremental worklist. If the ID does not refer to an incremental worklist, anIllegalArgumentException
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
isnull
), or - the incremental worklist contains no items at all.
null
will be returned instead ofIncWorklistData
if there are no items (for the current iteration). If the incremental worklist is closed on-the-fly, anIncWorklistData
will be returned even if there is no content.This class is thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description protected Function<WJ,WI>
transformation
The function transforming from the Java-model to ILM.-
Fields inherited from class de.aristaflow.ilm.model.common.collection.AbstractIteratorHandler
dataCreator, initDataCreator, iterators, iteratorTypeName, logger, removerService
-
-
Constructor Summary
Constructors Constructor Description IncWorklistHandler(Function<WJ,WI> transformation, Supplier<I> initDataCreator, Supplier<N> dataCreator, LogService logService)
Creates a new handler for incremental worklists.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close(@NotNull UUID iteratorId)
CallsServerSideProxy.close()
on the designated iterator and removes it from this handler.N
getNext(@NotNull UUID incWorklistId, @Positive Integer count, @PositiveOrZero Integer start)
CallsIncrementalWorklist.getNext(int)
on the designated incremental worklist.protected N
getNext(UUID incWorklistId, IncrementalWorklist<? extends WJ> iw, Integer count, Integer start)
CallsIncrementalWorklist.getNext(int)
on the designated incremental worklist.N
getPrevious(@NotNull UUID incWorklistId, @NotNull @Positive Integer count)
CallsIncrementalWorklist.getPrevious(int)
on the designated incremental worklist.I
init(IncrementalWorklist<? extends WJ> incWorklist, @Positive Integer count)
Adds the designated incremental worklist 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
closeOrDefer, closeOrDefer, getIterator, shutdown
-
-
-
-
Field Detail
-
transformation
protected final Function<WJ extends WorklistItem,WI extends WorklistItem> transformation
The function transforming from the Java-model to ILM.
-
-
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 callsgetNext(UUID, Integer, Integer)
with the designated parameters andstart
=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
ornull
. If this isnull
, 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 nocount
orInteger.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
- Ifcount
is non-positive (<= 0
), anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist has been closed implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist has been closed implicitly, aServiceConnectionException
will be thrown on client side.
-
getNext
@NotNull @Valid public N getNext(@NotNull @NotNull UUID incWorklistId, @Positive @Positive Integer count, @PositiveOrZero @PositiveOrZero Integer start)
CallsIncrementalWorklist.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
ornull
. If this isnull
, 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 isnull
, the nextcount
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
orInteger.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 anIncrementalWorklist
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 worklist items of the designated incremental worklist, anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist has been closed implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist has been closed implicitly, aServiceConnectionException
will be thrown on client side.
-
getNext
protected N getNext(UUID incWorklistId, IncrementalWorklist<? extends WJ> iw, Integer count, Integer start)
CallsIncrementalWorklist.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
isnull
), 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
ornull
. If this isnull
, 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 isnull
, the nextcount
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 anIncrementalWorklist
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 worklist items of the designated incremental worklist, anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist has been closed implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist has been closed implicitly, aServiceConnectionException
will be thrown on client side.
-
getPrevious
@NotNull @Valid public N getPrevious(@NotNull @NotNull UUID incWorklistId, @NotNull @Positive @NotNull @Positive Integer count)
CallsIncrementalWorklist.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 anIncrementalWorklist
known by this handler, anIllegalArgumentException
will be thrown.IllegalArgumentException
- If the designated incremental worklist does not have any previous worklist items or count is non-positive (<= 0), anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist has been closed implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist has been closed implicitly, aServiceConnectionException
will be thrown on client side.
-
close
public void close(@NotNull @NotNull UUID iteratorId)
CallsServerSideProxy.close()
on the designated iterator and removes it from this handler. This implementation callsIncrementalWorklist.close()
which does not throw anIOException
and handles legacy callingIncrementalWorklist.drop()
on proxies from old servers.- Overrides:
close
in classAbstractIteratorHandler<IncrementalWorklist<? extends WJ extends WorklistItem>,I extends InitialIncWorklistData<WI>,N extends IncWorklistData<WI>>
- Parameters:
iteratorId
- The ID of the iterator to close.
-
-