-
Notifications
You must be signed in to change notification settings - Fork 34
The Helpers package
The helpers package in the openntf.domino API is a set of classes to assist in common Domino programming patterns. In M1, there are two classes provided: DocumentSyncHelper and DocumentScanner.
DocumentSyncHelper is a utility to manage the common process of copying values from one document to a set of documents in another location. When you create a SyncHelper, you tell it a few things about your process. First, you set up the rules for discovery of target documents: which Database to target, which View in that Database to use for key matching, and the Object key from your source. Then you supply it with a Map<String, String> of source field names and target field names. Lastly, you provide a enum value to indicate the synchronization strategy.
Once you have initialized the SyncHelper with the proper controls, you can call .process(Document document) that will perform the sync process according to the controls using that document.
If you want to synchronize a collection of source documents, you can create one SyncHelper, and then iterator over your DocumentCollection calling SyncHelper.process(document) on each one.
The DocumentScanner is a stateful utility that builds Maps from the contents of each document that it processes. This is useful in finding every individual word contained in any item in any collection of Documents. Once the Scanner has processed a collection of documents, it has a getFieldTokenMap() method that returns a Map<String, Set> of all the unique words in each individual field. It also has a getTokenFreqMap() method that returns a Map<String, Integer> representing each unique word across all fields in all the documents, with a counter indicating the number of times that word was seen.
These helpers are intend both to be used and to provide concrete implementations of common patterns using the implementation provided in the openntf.domino API.
M2 adds two more helper classes: DocumentComparator and Formula. DocumentComparator has been provided courtesy of Michael Zischeck and is detailed here
Formula is a helper class for processing @Formulas. Provides syntax validation & auto-type conversion of results.