Parsers enable Gateway to read the contents of a csv or Excel (xls /xlsx) file. The following parsers have been delivered in Gateway:
- Default Parser
The Default Parser allows Gateway to read any object and field from a csv file.
- Resource Parser
A Resource Parser is a parser created specifically to read only a Resource object from a csv file. Additional parsers for reading specific objects and fields can be created.
To use a parser in a synchronization, you must set up:
- A File deployment supporting a CSV file format.
The File provider as the source application in a synchronization.
Note: This is an optional procedure you can use if you choose to create additional parsers to read specific provider objects.
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 Parser.
- Type: Select Parser
- Description: Enter, A parser to read the Role object.
- Script: Enter the following Groovy code for the Role object:
def currentName = getObjectName(context);
if (currentName == null) {
setObjectName(context,"Role");
}
def numberOfFields = getNumberOfFields(context);
if (numberOfFields == 0) {
setFieldNamesArray(context, 0);
} else {
createObject(context);
def index = 0;
while (index<numberOfFields) { setFieldValue(context, getFieldName(context, index), getCell(context, index)); index = index + 1;}
addObject(context);
}
- Select Validate to ensure the Groovy syntax contains no errors.
- Select Save.
The Role Parser is now displayed in the File Converters tab.
Tips
Use the Groovy source code of the Default Parser as a starting point to code for the Role object.