Adding a Role Parser: Example

Parsers enable Gateway to read the contents of a csv or Excel (xls /xlsx) file. The following parsers have been delivered in Gateway:

To use a parser in a synchronization, you must set up:

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

  1. Sign in to Primavera Gateway as an administrator or developer.
  2. In the sidebar, select Configuration.
  3. Select the File Converters tab.
  4. 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);

      }

  5. Select Validate to ensure the Groovy syntax contains no errors.
  6. 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.

Step me through...

Setting Up Gateway to Support CSV Files: Example

Creating a CSV File for Gateway: Example

Setting Up Gateway to Support Excel Files: Example

Learn more about...

Adding Parsers and Generators

Setting Up Gateway to Support CSV Files



Legal Notices | Your Privacy Rights
Copyright © 2013, 2022

Last Published Thursday, October 6, 2022