matskn
matskn

Reputation: 1310

Merge multiple NotesViewEntryCollection and sort on date

I have some NotesViewEntryCollection that I want to merge into one collection, and then sort on date. All the collections are gathered from the same view, so there wont be a conversion problem.

Have tried to google this problem, but cant seem to find any good solutions, besides writing a bunch of for-loops.

Thnx in advance!

Upvotes: 1

Views: 1896

Answers (4)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15739

I found this out recently, that if you create a NotesViewEntry from one view, you can only add entries that exist in that view. So you can't combine entries from two different views.

A possible way round this would be to use a java.util.TreeMap, push the entries into the TreeMap with the date as the key. This may work, but you may need to convert the NotesViewEntry objects to your own non-Notes objects before adding them in. This will definitely be the case if you want to store them in a managed bean of session or application scope. No matter how you store them, if you use a TreeMap it will have a performance hit if you're dealing with a lot of entries.

Upvotes: 3

angryITguy
angryITguy

Reputation: 9561

Assuming that you're using LotusScript and a recent version of Notes (8+). You can use the merge method. The examples provided in the help, here, should help you get started. Be aware of some caveats when using NotesViewEntryCollections as reported by IBM.

The NotesViewEntryCollection gives you a sorted collection, and the merge method will also give you a unique sorted list of documents, unlike a regular NotesDocumentCollection which is just an unsorted bucket.

Upvotes: 4

Jasper Duizendstra
Jasper Duizendstra

Reputation: 2617

It does not answer your question, but it might be possible to move all the documents to a (temporary) folder. This folder can take care of the sorting and merging.

Upvotes: 1

Ken Pespisa
Ken Pespisa

Reputation: 22264

If you are using Notes 8.0 or greater, there is a Merge method you can call to merge two collections together. Otherwise, you are correct that you'd have to loop through each collection and call AddEntry to add each entry one at a time.

Upvotes: 1

Related Questions