-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration Formatters
Formatters are defined in YAMl files located in the config directory have been implemented to allow for end users manipulate the data that was returned by the FOLIO system. This is done by defining a series of reformat keys for both the charge and credit data.
formatters:
charge_formatters:
- ...
credit_formatters:
- ...vars:
run_env: "TEST"
trans_active: true
formatters:
charge_formatters:
- filter_field: patron.externalSystemId
type: LEFT_STRIP
search_for: "0"
replace_with: ""
new_field: patron.externalSystemId
credit_formatters:
- filter_field: patron.externalSystemId
type: LEFT_STRIP
search_for: "0"
replace_with: ""
new_field: patron.externalSystemIdFormatters are required to be in order, as they will be processed in the order listed.
If you do not wish to use a reformatter, you can just leave the formatters array empty.
The vars section allows you to set variables that can be used in the jobs section. This allows you to set a variable once and use it in multiple jobs.
- The field that holds record that should be reformated
- (options) LEFT_STRIP | RIGHT_STRIP | REPLACE
- RIGHT_STRIP - This will remove the characters from the right side of the string as defined by the search_for field.
- LEFT_STRIP - This will remove the characters from the left side of the string as defined by the search_for field.
- REPLACE - This will replace the search_for string with the replace_with string.
- What value should be searched for and/or what charter should be stripped from the left or right.
- Used with
REPLACEtype. What the value should be replaced with.
- The field name where the changes are to be saved to. This can be the same value as the
filter_field
At our institution our external ids are loaded with a leading 0. This is not needed by the bursar system and needs to be removed.
formatters:
charge_formatters:
- filter_field: patron.externalSystemId
type: LEFT_STRIP
search_for: "0"
replace_with: ""
new_field: patron.externalSystemIdThis will transform a value in patron.externalSystemId from 000123456 to 123456
If we wanted to remove leading and trailing 0's we could add another formatter:
formatters:
charge_formatters:
- filter_field: patron.externalSystemId
type: RIGHT_STRIP
search_for: "0"
replace_with: ""
new_field: patron.externalSystemIdThis would remove all leading and trailing 0's from the patron.externalSystemId field resulting in 123456 from 000123456000.
Titles can have ',' in them but when converted to a csv file this can lead to errors. We can remove these with the following reformatter:
formatters:
charge_formatters:
- filter_field: title
type: REPLACE
search_for: ","
replace_with: ""
new_field: titleThis will reformat the title "Apples and Oranges, How to tell the difference" to "Apples and Oranges How to tell the difference".