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:
String[] fieldNames = context.getFieldNames("Role");
if (fieldNames == null) {
return;
}
for (String field: fieldNames) {
context.writeCell(field);
}
context.newline();
List<PDIObject> objects = context.getDocument().getObjects("Role");
for (PDIObject object: objects) {
for (String field: fieldNames) {
context.writeCell(object.getFieldValue(field));
}
context.newline();
}
- 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.