Adding a Role Generator: Example

Generators enable Gateway to write and format data into a csv file. The following generators are delivered in Gateway:

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

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

  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 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;

      }

      }

  5. Select Validate to ensure the syntax contains no errors.

    A success message displays: Syntax OK.

  6. 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.

Step me through...

Adding an File Deployment for CSV Files: Example

Creating a CSV File for Gateway: 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