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 singleOutputJobMergeIteminto the list of corrrespondingSortableItem.static SortedJobsSorts the given job items.static SortedJobssort(Iterable<OutputJobMergeItem> jobs) Sorts the given list ofOutputJobMergeItems.static SortedJobssortItems(Iterable<SortableItem> items) Sorts the list of items.static SortableItemtoSortableItem(OutputJobItem jitem, int sorting) Converts aOutputJobItemwith the given sorting into aSortableItem.static List<SortableItem> toSortableItem(OutputJobMergeItem merge) Converts aOutputJobMergeIteminto a list ofSortableItems.
-
Method Details
-
sort
public static SortedJobs sort(Iterable<OutputJobItem> jobItems, Function<Integer, Integer> sortings) throws PersistExceptionSorts the given job items. Thesortingsis the user defined sorting function that returns the position for eachOutputJobItemin the list. The function is applied to the index of theOutputJobItemin question. The function may returnnullin which case a default sorting is used.RichIterableimplements theFunctioninterface 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);Functionsclass also provides convenient shortcuts, likeFunctions.constant(0)that returns a constant function, orFunctions.identitythat can be used to preserve the sorting in thejobItemslist.- Throws:
PersistException
-
sort
Sorts the given list ofOutputJobMergeItems. -
toSortableItem
Converts aOutputJobItemwith the given sorting into aSortableItem. TheSortableItemcontains theOutputJobItemas its element.- Throws:
PersistException
-
toSortableItem
Converts aOutputJobMergeIteminto a list ofSortableItems. 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
SortableItemcan contain the following elements:*
OutputCenterInputSupplier(for each additional document) *OutputJobItem*OutputJob(only unpersonalized)- Throws:
PersistException
-
mergeItemConverter
Returns a function that converts a singleOutputJobMergeIteminto the list of corrrespondingSortableItem. This is just callingtoSortableItem(OutputJobMergeItem)and may be useful when transforming collections. -
sortItems
Sorts the list of items. TheSortedJobsreturn value allows to access individual parts and allows to iterate over all items.
-