Class JobItemSorter
java.lang.Object
ch.tocco.nice2.outputcenter.api.sorting.JobItemSorter
-
Method Summary
Modifier and TypeMethodDescriptionstatic Function
<OutputJobMergeItem, List<SortableItem>> Returns a function that converts a singleOutputJobMergeItem
into the list of corrrespondingSortableItem
.static SortedJobs
Sorts the given job items.static SortedJobs
sort
(Iterable<OutputJobMergeItem> jobs) Sorts the given list ofOutputJobMergeItem
s.static SortedJobs
sortItems
(Iterable<SortableItem> items) Sorts the list of items.static SortableItem
toSortableItem
(OutputJobItem jitem, int sorting) Converts aOutputJobItem
with the given sorting into aSortableItem
.static List
<SortableItem> toSortableItem
(OutputJobMergeItem merge) Converts aOutputJobMergeItem
into a list ofSortableItem
s.
-
Method Details
-
sort
public static SortedJobs sort(Iterable<OutputJobItem> jobItems, Function<Integer, Integer> sortings) throws PersistExceptionSorts the given job items. Thesortings
is the user defined sorting function that returns the position for eachOutputJobItem
in the list. The function is applied to the index of theOutputJobItem
in question. The function may returnnull
in which case a default sorting is used.RichIterable
implements theFunction
interface by using the function argument to lookup the element in the list. Therefore it can be used to create permutations more conveniently:
Guava'sRichIterable<Integer> f = RichIterable.list(1, 4, 2, 3); //maps 0->1, 1->4, etc SortedJobs sorted = sort(items, f);
Functions
class also provides convenient shortcuts, likeFunctions.constant(0)
that returns a constant function, orFunctions.identity
that can be used to preserve the sorting in thejobItems
list.- Throws:
PersistException
-
sort
Sorts the given list ofOutputJobMergeItem
s. -
toSortableItem
Converts aOutputJobItem
with the given sorting into aSortableItem
. TheSortableItem
contains theOutputJobItem
as its element.- Throws:
PersistException
-
toSortableItem
Converts aOutputJobMergeItem
into a list ofSortableItem
s. If the associated job item is a personalized job all its job items are added and the optional additional docuement. If the job is unpersonalized, the jobs document is added as well as the additional document if present.If the merge item is only linked to a dms document, then this is converted into a
SortableItem
.The
SortableItem
can contain the following elements:*
OutputCenterInputSupplier
(for each additional document) *OutputJobItem
*OutputJob
(only unpersonalized)- Throws:
PersistException
-
mergeItemConverter
Returns a function that converts a singleOutputJobMergeItem
into the list of corrrespondingSortableItem
. This is just callingtoSortableItem(OutputJobMergeItem)
and may be useful when transforming collections. -
sortItems
Sorts the list of items. TheSortedJobs
return value allows to access individual parts and allows to iterate over all items.
-