Generators enable Gateway to write and format data into a csv file. The following generators are delivered in Gateway:
- Default Generator
The Default Generator allows Gateway to write any object and any field into a csv file.
- Resource Generator
The Resource Generator is a generator created specifically to write only a Resource object from a csv file. Additional generators to write specific objects and fields into a csv file can be created.
To use a generator in a synchronization, you must set up:
- A File deployment supporting a CSV file format.
The File provider as the destination application in a synchronization.
Note: This is an optional procedure you can use if you choose to create additional generators to write specific provider objects to a csv file.
Prerequisite
Add a File deployment connection selecting CSV format.
Procedure
- Sign in to Primavera Gateway as an administrator or developer.
- In the sidebar, select Configuration.
- Select the File Converters tab.
- Select Add... and enter the following information in the File Converter wizard:
- Name: Enter Role Generator.
- Type: Select Generator.
- Description: Enter, A file generator to write a Role object to a csv file.
- Script: Enter the following Groovy code for the Role object:
setCurrentObjectName(context, "Role");def fieldNameCount = getFieldNameCount(context);if (fieldNameCount > 0) {def fieldNameIndex = 0;while (fieldNameIndex < fieldNameCount) {def fieldName = getFieldNameByIndex(context, fieldNameIndex);writeCell(context, fieldName);fieldNameIndex = fieldNameIndex + 1;}newline(context);def objectCount = getObjectCount(context);def objectIndex = 0;while (objectIndex < objectCount) {setCurrentObject(context, objectIndex);fieldNameIndex = 0;while (fieldNameIndex < fieldNameCount) {def fieldName = getFieldNameByIndex(context, fieldNameIndex);def value = getFieldValue(context, fieldName);writeCell(context, value);fieldNameIndex = fieldNameIndex +1;}newline(context);objectIndex = objectIndex + 1;}}
- Select Validate to ensure the syntax contains no errors.
A success message displays: Syntax OK.
- Select Save.
The Role Generator displays in the File Converters tab.
Tip:
Use the Groovy source code of the Default Generator as a starting point to code for the Role object.