Managing System Interfaces with the EPT

Table of Contents

Introduction

This document explains how to set up integrations for enterprise networks. The context of this guide is a network owner sharing information with various customer enterprises. The document explains integration transformations, custom inbound integrations, custom outbound integrations, message queues, and custom data formats.

What is the Enterprise Process Template (EPT)?

The Enterprise Process Template (EPT) allows adding functionality to a network. EPT functionality is specific to only one enterprise within the Network.

Like the Standard Process Template (SPT) and Modules, the EPT serves as a store of information and functionality. However, not all users in the network have access to the same EPT. Many users within the same network may actually interact with different EPT's, depending on their role in the Network. Each EPT has its own Enterprise specific functionality.

images/download/attachments/144836879/image2021-10-5_8-44-19-version-1-modificationdate-1670861791000-api-v2.png

What are Interfaces?

Interfaces are the mechanism through which data is the Network and other systems exchange data. Inbound interfaces allow other systems to send data to the Network. Outbound interfaces allow the Network to send data out to other systems (or users).

Interfaces support a variety of formats. Formats supported without custom programming include:

  • XML (Extensible Markup Language).

  • JSON (JavaScript Object Notation).

  • CSV (Comma-Separated Values).

  • EDI (Electronic Data interchange).

Interfaces can also use custom Java programming code to handle non-standard data formats.

Existing Interfaces vs. New Interfaces vs. Custom Interfaces.

The ONE Platform supports numerous standard interfaces. Pre-built Modules or Enterprise Process Templates (EPT's) may also have interfaces available for use. These interfaces allow external systems to interact with applications running on the platform. Additionally, developers can create new interfaces using the SDK to interact with data inside the platform through structured pre-set integration formats. Finally, developers can write custom Java based interfaces to interact with data inside the platform.

Message Transforms

Message Transforms are layers which modify the format of data during receipt from or transmission to an external system. For example, a Message Transforms may convert XML formatted data to CSV format before that data is received in by an inbound interface. Or a Message Transform may convert CSV formatted data to JSON format before that data is sent out by an outbound interface. You can use Message Transforms to adapt messages to existing interfaces.

Next Steps

In this document we will learn how to create a new Dataset and EPT. Next, we will learn how to create an Inbound Interface, for data coming into the ONE Platform. After that we discuss how to create an Outbound Interface, for data going out of the ONE Platform. Finally, we will go over how to create custom Interfaces (both Inbound and Outbound) for handling non-standard data types.

Before continuing on, you should familiarize yourself with the basics of ONE's Platform and SDK. A good starting point is the ONE Network Software Development Kit Training Guide, found at the following URL: https://docs.onenetwork.com/devnet/latest/sdk-training-guide

Create and upload an EPT for a Customer Enterprise

The Enterprise Process Template (EPT) provides enterprise-specific customization within a multi-party community. It lets you customize the behavior of the application for a single enterprise. In this guide we will use the Enterprise Process Template (EPT) to create custom integrations for specific enterprises in the network.

Install the Platform SDK

  1. Start with the Platform SDK.

  1. If you do not have the Platform SDK installed, then create an account and follow the instructions here to install the SDK: https://www.onenetwork.com/dev-net/developer-resource-center/

  2. NOTE: If you are using ONE's Real Time Value Network modules, do not download the SDK from that link. Work with your contacts at ONE Network to get an "instance builder" which allows you to get the binaries for the relevant modules.

Create a Dataset

  1. Each EPT needs a Dataset. If you do not already have a Dataset, you can create a new Dataset with the following steps:

  2. Select File -> New -> Dataset Project.

  3. Set the Value Chain ID. In this example we will use 2050.

  4. Set the Dataset Name. We will use "BusinessNet".
    images/download/attachments/144836879/image2021-10-5_8-44-45-version-1-modificationdate-1670861791000-api-v2.png

  5. Click Finish.

  6. Our new Dataset will now be visible in the Package Explorer on the left of the Platform SDK:
    images/download/attachments/144836879/image2021-10-5_8-45-2-version-1-modificationdate-1670861791000-api-v2.png

Create an EPT

  1. Create a new EPT project by going to File -> New -> EPT Project.
    images/download/attachments/144836879/image2021-10-5_8-45-16-version-1-modificationdate-1670861791000-api-v2.png

  2. Fill in values for Value Chain ID, Enterprise Name, EPT Name, and EPT Source Package. For example:

    1. Value Chain ID: 2050

    2. Enterprise Name: AcmeIndustries

    3. EPT Name: AcmeIndustries

    4. EPT Source Package: com.acmeindustries.myept

  3. Your EPT project will now be visible in the Package Explorer in the upper left of the Platform SDK.

    1. images/download/attachments/144836879/image2021-10-5_8-45-32-version-1-modificationdate-1670861791000-api-v2.png

  4. Next, we need to add the build files:

    1. Click on the Ant tab in the upper right of the Platform SDK.

    2. Click on the Add Buildfiles button inside the Ant view (leftmost button).

    3. images/download/attachments/144836879/image2021-10-5_8-45-46-version-1-modificationdate-1670861791000-api-v2.png

  5. Expand both the EPT and the dataset.

  6. Select both buildfiles by holding Ctrl and clicking on each.

  7. Then click OK to add the buildfiles.

    1. images/download/attachments/144836879/image2021-10-5_8-45-59-version-1-modificationdate-1670861791000-api-v2.png

  8. The buildfiles will now appear inside the Ant view in the upper right of the SDK.

  9. Expand the buildfiles in the Ant view by clicking on the arrows next to the buildfile names.

    1. images/download/attachments/144836879/image2021-10-5_8-46-17-version-1-modificationdate-1670861791000-api-v2.png

  10. Double click on the "build" file to run the build process.

    1. images/download/attachments/144836879/image2021-10-5_8-46-32-version-1-modificationdate-1670861791000-api-v2.png

  11. The Console window will show the message "BUILD SUCCESSFUL" when the build process is complete.

    1. images/download/attachments/144836879/image2021-10-5_8-46-46-version-1-modificationdate-1670861791000-api-v2.png

  12. Start the server.

    1. To start the server first open Windows File Explorer by typing "file explorer" in the search box and selecting the application.

    2. Navigate to the directory: "C:\OneSDK_21.0\default-instance\platform\bin"

    3. Double click on the file "run.bat". This will open a new Command Prompt window with the server running in it. Note that it may take a couple of minutes for the server to start.

      1. Note: You can alternatively, double click on "run-jdwp.bat". "run-jdwp.bat" starts the server in "Debug" mode, which displays additional notifications in the Command Prompt.

    4. Wait for the server to start. You can tell that it has started when the text in the Command Prompt stops scrolling. You can also confirm that the server has started by navigating to the URL "http://localhost" in a web browser. If the server is running then the application sign in page with display.

      1. images/download/attachments/144836879/image2021-10-5_8-46-58-version-1-modificationdate-1670861791000-api-v2.png

  13. In the Ant tab in the upper right of the Platform SDK, double click on the "load-data" file to load the dataset.

    1. If using SDK version 21.0, then use the following work around for a problem in this step:

      1. If the error message "The specified JRE installation does not exist." appears, then do the following:

        1. Run->External Tools->External Tools Configurations->JRE:

        2. Click on the Separate JRE radio button.

        3. Click on Apply.

        4. Click Run.

      2. If the build process fails, then do the following:

        1. Double click the "local.properties" file under the dataset in the Package Explorer section of the Platform SDK.

        2. Find the line with the following text: "web.server.parent.dir=webserverparentdir"

        3. Change that text to: "web.server.root.dir=${install.root.dir}/tomcat"

        4. Save the changes.

        5. Double click on "load-data" in the Ant tab again to re-run the process.

    2. If using SDK version 22.0, then use the following work around for a problem in this step:

      1. If the build process fails, then do the following:

        1. Double click the "local.properties" file under the dataset in the Package Explorer section of the Platform SDK.

        2. Add the following text to the bottom of the file: "web.server.root.dir=${install.root.dir}/tomcat"

        3. Save the changes.

        4. Double click on "load-data" in the Ant tab again to re-run the process.
          images/download/attachments/144836879/image2021-10-5_8-47-18-version-1-modificationdate-1670861791000-api-v2.png

          images/download/attachments/144836879/image2021-10-5_8-47-33-version-1-modificationdate-1670861791000-api-v2.png

Submitting Changes to the Server

During the development process, you must upload changes you make to the server. There are two ways to do this:

Option A - Submit through Studio

One method of uploading the EPT is doing so using the Platform SDK's "Submit to Server" button. It will publish all changes made in the EPT Project to a running server. You can either use the ValueChainAdmin context or EnterpriseAdmin context to load the EPT. For example, I used "BusinessNetAdmin", because this is a default username with ValueChainAdmin permission.

This is the "Submit to Server" button. It can be found in the upper left of the Platform SDK. images/download/attachments/144836879/image2021-10-5_8-50-59-version-1-modificationdate-1670861791000-api-v2.png

Option B - Using the load-data file

You can also use load-data to publish changes made in the EPT Project by adding an EnterpriseProcessTypeFolder entry to the LoadData.xml of your dataset.

<LoadData xmlns="http://www.onenetwork.com/Platform">
<ValueChain>data/ValueChain.xml</ValueChain>
<StandardProcessType>Standard Process Template.spt</StandardProcessType>
<UiMetaModel>data/UiMetaModel.xml</UiMetaModel>
<EnterpriseProcessTypeFolder>AcmeIndustries</EnterpriseProcessTypeFolder>
</LoadData>

More info about EPTs

For more information about the Enterprise Process Template (EPT), see: https://devnet.onenetwork.com/oms/apps/DeveloperNetwork/www/docs/guides/SdkUsersGuide/help/content/modeling-ept.html

Create an Enterprise Admin User

By default, our new Dataset has an example user with Value Chain Admin permission. However, since we are working with Enterprise level data, let's create a new user account with the appropriate level of permissions. We want to create an Enterprise Admin user, which is a user with administrator privileges at the Enterprise level. Since this is the first time we've set this up, we will need to create: an Enterprise, a Role, a User, and a User Association.

Add an Enterprise

  1. In the Package Explorer section of the Platform SDK, expand the Dataset.

  2. Expand the folder "data".

  3. Right click on "Enterprises.csv".

  4. Choose Open With → Text Editor.

  5. You should see two lines of data. The top row contains the column headers. The second row is an example enterprise. Add a third row with the following data:

    AcmeIndustries,Acme Industries,1,US~TX~Dallas~~~~455 Valley View~~~75056~~~,US~TX~Dallas~~~~455 Valley View~~~75056~~~,,,,MONDAY,America/Chicago
  6. Click the Save button.

  7. Click the Submit To Server button. The Submit dialog will open:

    1. Set the URL to: http://localhost.

    2. Set Username to: BusinessNetAdmin (This is a default Value Chain Admin account which gets created with the Dataset.)

    3. Set Password to: password

    4. Set Interface Name to: PLT.Enterprise_IB

    5. Set Interface Version to: 1.0

    6. Click Submit.
      images/download/attachments/144836879/image2021-10-5_8-51-15-version-1-modificationdate-1670861791000-api-v2.png

  8. The toast in the bottom right of the Platform SDK should display "Successfully uploaded". An Enterprise named "Acme Industries" has now been created.

Add a Role

  1. Right click on "Roles.csv.

  2. Choose Open With → Text Editor.

  3. You should see three lines of data. The top row shows the column headers. The second row is an example Value Chain Admin role. The third row is an example user role. Add a fourth row with the following data:

    AcmeIndustriesAdminRole,ENTERPRISE_ADMIN,AcmeIndustries,,,1
  4. Click the Save button.

  5. Click the Submit To Server button. The Submit dialog will open:

    1. Set the URL to: http://localhost.

    2. Set Username to: BusinessNetAdmin

    3. Set Password to: password

    4. Set Interface Name to: PLT.Role_IB

    5. Set Interface Version to: 1.0

    6. Click Submit.
      images/download/attachments/144836879/image2021-10-5_8-51-34-version-1-modificationdate-1670861791000-api-v2.png

    7. The toast in the bottom right of the Platform SDK should display "Successfully uploaded". A Role called "AcmeIndustriesAdminRole" has now been created.

Add a User

  1. Right click on "Users.csv".

  2. Choose Open With → Text Editor.

  3. You should see three lines of data. The top row shows the column headers. The next two rows are example users. Add a fourth row with the following data:

    AcmeIndustriesEntAdmin,AcmeIndustries,All,example@email.com,Jane,,Doe,1,US,en
  4. Click the Save button.

  5. Click the Submit To Server button. The Submit dialog will open:

    1. Set the URL to: http://localhost.

    2. Set Username to: BusinessNetAdmin

    3. Set Password to: password

    4. Set Interface Name to: PLT.User_IB

    5. Set Interface Version to: 1.0

    6. Click Submit.
      images/download/attachments/144836879/image2021-10-5_8-51-48-version-1-modificationdate-1670861791000-api-v2.png

    7. The toast in the bottom right of the Platform SDK should display "Successfully uploaded". A User called "AcmeEnterpriseEntAdmin" has now been created.

Add a User Association

  1. Right click on "UserAssociations.csv".

  2. Choose Open With → Text Editor.

  3. You should see three lines of data. The top row shows the column headers. The next two rows are example user associations. Add a fourth row with the following data:

    AcmeIndustriesEntAdmin,2050,AcmeIndustries,AcmeIndustriesAdminRole,2050,AcmeIndustries,,,1
  4. Click the Save button.

  5. Click the Submit To Server button. The Submit dialog will open:

    1. Set the URL to: http://localhost.

    2. Set Username to: BusinessNetAdmin

    3. Set Password to: password

    4. Set Interface Name to: PLT.UserAssociation_IB

    5. Set Interface Version to: 1.0

    6. Click Submit.
      images/download/attachments/144836879/image2021-10-5_8-52-7-version-1-modificationdate-1670861791000-api-v2.png

    7. The toast in the bottom right of the Platform SDK should display "Successfully uploaded". The user "AcmeIndustriesEntAdmin" is now associated with the "AcmeIndustriesAdminRole", which has the "ENTERPRISE_ADMIN" Role Type.

Enable UI Permissions

Make the ENTERPRISE_ADMIN Role Type available for UI permissions:

  1. Double click on "Enterprise Process Template.ept" in the Package Explorer section of the Platform SDK.

  2. Click on the Overview tab in the center of the Platform SDK.

  3. In the Role Types section, check the checkbox next to "ENTERPRISE_ADMIN". This will allow us to use the ENTERPRISE_ADMIN Role Type when setting permissions for the User Interface in a later section.

    1. Note: You may need to resize the windows in order to see the Role Types section's content.

  4. Save changes by clicking the Save button.

  5. Click the Submit to Server button.

    1. The Submit dialog will appear.

    2. Set the URL to: http://localhost

    3. Set the User Name to: BusinessNetAdmin

    4. Set the Password to: password

    5. Click Submit. The dialog will disappear and it may take a moment for the server to process the changes to the EPT.
      images/download/attachments/144836879/image2021-10-5_8-52-22-version-1-modificationdate-1670861791000-api-v2.png

We now have a user with Enterprise Admin privileges. We will use this user account when configuring our interfaces in later sections.

Create a new Inbound Interface for a Customer Enterprise (CSV)

The ONE Network platform can accept inbound information in a variety of formats, including custom formats. This section will provide an example of how to set up an inbound interface with Comma Separated Value (CSV) format.

  1. Inside the Package Explorer on the left of the Platform SDK, expand the EPT.

  2. Double click on "Enterprise Process Template.ept". This will open up a tab for the Enterprise Process Template.

    images/download/attachments/144836879/image2021-10-5_8-52-40-version-1-modificationdate-1670861791000-api-v2.png

Submitting Changes to the Server

  1. Click on the "Outline" tab in the upper right of the Platform SDK.

  2. Expand the "Integration Interfaces" item in the Outline view.
    images/download/attachments/144836879/image2021-10-5_8-52-53-version-1-modificationdate-1670861791000-api-v2.png

  3. Right click on "Inbound". Then select "Add Inbound Interface". This will start a new custom interface for the EPT.

  4. Populate the form with information about the new interface:

    1. Change the Name to a descriptive name, such as EPT.AcmeIndustries.Item_IB

    2. Add a description.

    3. Set the Format Type drop-down to "CSV".
      images/download/attachments/144836879/image2021-10-5_8-53-10-version-1-modificationdate-1670861791000-api-v2.png

  5. Click on the "Format" tab at the bottom. This will open up the "Format" sub tab.

  6. The data fields in Comma Separated Value (CSV) file imports can map directly to ONE "models". We will now select which fields to add an in which order. Add fields to the Inbound Interface:

    1. Click the Add Fields button.

    2. Set the Model Type. In this example, we are using the Model Type "Item".

    3. Set the Model Level if applicable.

      1. Note: This will be grayed out in this example.

    4. Set the Action Name. In this example, let's select PLT.Create. This means that new records will be created based on information from our Inbound Interface.

    5. Click on the fields to interact with. (Hold shift and click to select multiple fields.) For this example, let's set the following fields:

      1. EnterpriseName

      2. Name

      3. PriceAmount

      4. ValueChainID

    6. Click the Add Fields button.
      images/download/attachments/144836879/image2021-10-5_8-53-31-version-1-modificationdate-1670861791000-api-v2.png

    7. Click Close to close the dialog.

    8. If any of the fields are required, then set the Required value for those fields. This will default to "Y" for fields which are Keys in the database.
      images/download/attachments/144836879/image2021-10-5_8-53-47-version-1-modificationdate-1670861791000-api-v2.png

    9. Note: We are leaving the field "Allow Name-Based Mapping" unchecked in this example. This means that the system will import fields from the data file in the order that is displayed in the Format tab. If the "Allow Name-Based Mapping" box was checked, then the system would attempt to match fields based on their name in a header row.

  7. Click on the "Processor" tab at the bottom of the Platform SDK. This is where we will set information about the type of processor to use.

  8. We are setting up an interface to process a CSV file, so set the Processor drop-down field to "Default Model CSV Processor".

  9. Set the Default Custom Model Name to "Standard Item".

  10. Set the Default Action Name to "PLT.InsertOrUpdate".
    images/download/attachments/144836879/image2021-10-5_8-54-2-version-1-modificationdate-1670861791000-api-v2.png

  11. The Processor tab has other options for configuring how the file will be processed. Leave these as their default settings for now.

  12. Save the Inbound Processor by clicking on the Save button.

  13. Submit the EPT:

    1. Click on the Submit to Server button. The Submit dialog will appear.

    2. Set the URL to: http://localhost

    3. Set the User Name to: BusinessNetAdmin

    4. Set the Password to: password

    5. Click Submit.

  14. At this point, we now have a CSV "data format" which external systems can use when sending data.

Create message queues for processing, Customer Upload via HTTPS

Create an Inbound MessageQueue

In order to receive messages, we must set up a queue where these messages will be temporarily stored. ONE typically processes inbound messages asynchronously; that is, we receive the message to a queue, and then process in FIFO order from the queue as computing resources allow.

We will give our MessageQueue the following properties:

  • We will name it "inbox/Widget". (A good practice is to prefix inbound queues with "inbox" and outbound with "outbox".)

  • We will indicate its Classification as "Inbox", meaning it processes inbound messages.

  1. In the Package Explorer view on the left of the Platform SDK, expand the Dataset.

  2. Expand the "data" folder.
    images/download/attachments/144836879/image2021-10-5_8-54-18-version-1-modificationdate-1670861791000-api-v2.png

  3. If there is not already a "PLT.MessageQueue_IB.csv" file present, then add one:

    1. Right click on the "data" folder.

    2. Select New->File.

    3. Name the new file "PLT.MessageQueue_IB.csv".

    4. Click Finish.

  4. Depending on your preference settings, the Platform SDK may try to open the file in Microsoft Excel. However, we want to open this file in a text editor:

    1. Close Excel.

    2. Right click on "PLT.MessageQueue_IB.csv".

    3. Select Open With→Text Editor.

    4. The file should now be open in the middle of the Platform SDK.

  5. Add the following content to the new file:

    #* Name,Enterprise Name,Classification,"Exclusive Consumer (0 or 1 (0=false, 1=true))","Paused (0 or 1 (0=false, 1=true))"
    inbox/Widget,AcmeIndustries,Inbox,1,0
  6. Save the file by clicking on the Save button.

  7. Click the Submit to Server button.

  8. The Submit dialog will appear.

    1. Leave URL set to: http://localhost

    2. For Username enter: BusinessNetAdmin

    3. For Password type: password

    4. For Interface Name type: PLT.MessageQueue_IB

    5. For Interface Version type: 1.0

    6. Click Submit.

  9. Once this is loaded, we can log in and verify that this MessageQueue was created successfully:

    1. Open a web browser.

    2. Navigate to the URL: http://localhost

    3. Sign in with the username "InstanceAdminUser" and the password "password".

    4. Click on Integration→Message Queue Summary in the upper left menu of the web page. You should see "inbox/Widget" listed as one of the Queue Names.

Set up MsgProcessingContext

To upload data through EPT interfaces, you will need to load MsgProcessingContext. This is because by default message processing is handled using a "Value Chain Admin" context. However, a "Value Chain Admin" context does not have awareness of EPT processes. We need to associate your queue with the Enterprise Admin to be used to process it.

  1. In the Package Explorer view on the left of the Platform SDK, expand the Dataset.

  2. Expand the "data" folder.

  3. If there is not already a "PLT.MsgProcessingContext_IB.csv" file present, then add one:

    1. Right click on the "data" folder.

    2. Select New->File.

    3. Name the new file "PLT.MsgProcessingContext_IB.csv".

  4. Depending on the preference settings, the Platform SDK may try to open the file in Microsoft Excel. However, we want to open this file in a text editor:

    1. Close Excel.

    2. Right click on "PLT.MsgProcessingContext_IB.csv".

    3. Select Open With→Text Editor.

    4. The file should now be open in the middle of the Platform SDK.

  5. Add the following content to the new file:

    #OwningQueueEnterpriseName,OwningQueueName,InboundInterfaceName,InboundInterfaceVersion,ProcessingContextRoleValueChainId,ProcessingContextRoleEnterpriseName,ProcessingContextRoleOrganizationName,ProcessingContextRoleSiteName,ProcessingContextRoleName,ProcessingContextUserValueChainId,ProcessingContextUserEnterpriseName,ProcessingContextUserName,OutboundQueueEnterpriseName,OutboundQueueName,OutboundQueueVcId,Sender,ResolverClass
    AcmeIndustries,inbox/Widget,,,2050,AcmeIndustries,,,AcmeIndustriesAdminRole,2050,AcmeIndustries,AcmeIndustriesEntAdmin,,,,,
  6. Save the changes.

  7. Click the Submit to Server button.

  8. The Submit dialog will appear.

    1. Leave URL set to: http://localhost

    2. For Username enter: BusinessNetAdmin (or an appropriate user with Value Chain Admin permission)

    3. For Password type: password

    4. For Interface Name type: PLT.MsgProcessingContext_IB

    5. For Interface Version type: 1.0

    6. Click Submit.

Test Our Inbound Interface

We want to test that our HTTPS interface is working. Let's do this using an application called Postman.

  1. Download and install Postman following the instructions found here: https://www.getpostman.com/downloads/

  2. Set up a new Collection.

    1. In Postman, select: File->New→Create New→Collection

    2. Name the Collection "ONE Network Tests".

    3. Click Save.

  3. Create a new Request:

    1. In Postman, select: File->New→Create New→Request

    2. Name the request "ONE Inbound Test".

    3. Select the Collection "ONE Network Tests".

    4. Click Save.

  4. Expand the "ONE Network Tests" collection.

  5. Select the "ONE Inbound Test" request.

  6. Change the method from GET to POST.

  7. Set the URL to http://localhost/oms/rest/queue/enqueue

  8. Add the following Keys and Values to the Params section of the Request.

    Key

    Value

    QueueName

    inbox/Widget

    Sender

    myExternalApp

    InboundInterface

    EPT.AcmeIndustries.Item_IB

    InboundInterfaceVersion

    1.0

    InboundQueueEnterpriseName

    AcmeIndustries

  9. To connect to the server, we need to authenticate that we are allowed to do so. There are two methods of authentication: Basic and OAuth. In this example, we will connect with the Basic method:

    1. In Postman, click on the Headers sub tab of our Request.

    2. Add a new Key Value pair with "Authorization" as the Key and "Basic QnVzaW5lc3NOZXRBZG1pbjpwYXNzd29yZA==" as the Value.

      1. Note: The Value for Basic authentication is "Basic username:password", where "username:password" is encoded with Base64 encoding. In this example, we are using the username "BusinessNetAdmin" and the password "password". The Base64 encoded value of the string "BusinessNetAdmin:password" is "QnVzaW5lc3NOZXRBZG1pbjpwYXNzd29yZA==". Therefore, the Value to use in the Authorization Header is "Basic QnVzaW5lc3NOZXRBZG1pbjpwYXNzd29yZA==".

  10. We also need to add a Message Body, with the information that we want to send:

    1. In Postman, click on the Body sub-tab.

    2. Choose "raw" as the body type.

    3. Select Text from the drop down.

    4. Add the following text to the Body section:

      AcmeIndustries,NewWidget,123.54,2050
    5. Click Save.

    6. Click Send.

  11. Postman should show a Status: 200, indicating a successful transmission of the message.

    1. Note: This doesn't mean that it was processed successfully; it just means that the message has been enqueued by ONE. images/download/attachments/144836879/image2021-10-5_8-54-38-version-1-modificationdate-1670861791000-api-v2.png

  12. We can confirm that the message was processed successfully by viewing the message status through the user interface:

    1. Open a web browser.

    2. Navigate to the URL: http://localhost

    3. Sign in with the username "InstanceAdminUser" and the password "password".

    4. Click on Integration→Message Queue Summary in the upper left menu of the web page. You should see "inbox/Widget" listed as one of the Queue Names.

    5. Click on inbox/Widget. This will open up the Messages tab.

    6. Our transmission will be listed in the table. The State column will display "Processed" if the message was processed.

    7. Go back to the Message Queue Summary view. There will be another Queue named "outbox/Widget/Success". Our transmission will also appear in this Queue as "Processed" if the record was successfully added to the database.

      1. Note: We could also verify that a database record was created by running the command "SELECT * FROM Item" in a SQL editor.

For information about additional Parameters or OAuth authentication, see: Integration Capability Summary#MessageQueuesandMessages

Create a Transform for an Existing Inbound Interface

Introduction to Message Transforms

Message Transforms are features which allow data to be formatted (or transformed) when exchanging that data with an external computer system. Message Transforms can be used to transform an inbound message before processing by the ONE Platform. Or Message Transforms can be used to format an outbound message before delivery to an external system or user.

Message Transforms can be used with either pre-built Interfaces or with Interfaces built through the Platform SDK. In this example, we will look at using a Message Transform with an Inbound Interface. You can use the following steps to see a list of Interfaces:

  1. In the Package Explorer section in the left of the Platform SDK, expand the Enterprise Process Template.

  2. Double click on Enterprise Process Template.ept.

  3. Click on the Outline tab in the upper right of the Platform SDK.

  4. Expand Integration Interfaces. You should see both Inbound and Outbound listed here.

  5. Expand Inbound. You should now see a list of any EPT specific Inbound Interfaces. You should also see PLT, which if expanded will show a list of Inbound Interfaces common to all applications built on the Platform SDK.

In this section, we will set up a Message Transform for an Inbound Interface, EPT.AcmeIndustries.User_IB.

Create an Inbound Interface

Let's create an Inbound Interface to work with. (Note that if EPT.AcmeIndustries.User_IB already existed, then we could skip this step.)

  1. Create a new Inbound Interface like we did in the "Create a new Inbound Interface for a Customer Enterprise (CSV)" section above.

  2. Call the interface: EPT.AcmeIndustries.User_IB

  3. Set the Format Type to: CSV

  4. Instead of Item fields, add the following User fields:

    • Name

    • EnterpriseName

    • Email

    • FirstName

    • MiddleInitial

    • LastName

    • Active

    • LocaleCountry

    • LocaleLanguage

  5. Arrange the fields in the order shown above. You can do this from the Format tab by clicking field names and then using the "Up" and "Down" buttons.

    1. Note: If you do not rearrange the fields to your desired order, then they will automatically populate in alphabetical order.

  6. Set Processor to: Default Model CSV Processor

  7. Set Default Custom Model Name to: Standard User

  8. Set Default Action Name to: PLT.InsertOrUpdate

  9. Save the changes.

  10. Submit the changes to the server.

Create an Inbound MessageQueue

Create an Inbound MessageQueue like we did in the section "Create an Inbound MessageQueue" above. Except, create this MessageQueue to be used with the Inbound Interface "EPT.AcmeIndustries.User_IB".

  1. We will name it "inbox/User". (A good practice is to prefix inbound queues with "inbox" and outbound with "outbox".)

  2. We will indicate its Classification as "Inbox", meaning it processes inbound messages.

  3. We will add a line to the file "PLT.MessageQueue_IB.csv".

  4. The line to add to the file is:

    inbox/User,AcmeIndustries,Inbox,1,0
  5. Save the changes.

  6. Submit the changes to the server.

Set up a MsgProcessingContext

Set up a MsgProcessingContext like we did in the section "Set up MsgProcessingContext" above. Create this MsgPRocessingContext for the new MessageQueue created in the previous step.

  1. We will add a line to the file "PLT.MsgProcessingContext_IB.csv".

  2. The line to add to the file is:

    AcmeIndustries,inbox/User,,,2050,AcmeIndustries,,,AcmeIndustriesAdminRole,2050,AcmeIndustries,AcmeIndustriesEntAdmin,,,,,


  3. Save the changes.

  4. Submit the changes to the server.

Add a Transform

As an example, we are going to create a Transform which will convert XML formatted data to CSV formatted data before the data gets processed. These are the steps to create the Transform:

  1. Navigate to the Package Explorer view in the left of the Platform SDK.

  2. Right click on "src".

  3. Select New → Other → Java → Class.

  4. Name the Package "com.acmeindustries.myept.xforms".

  5. Name the Class "UserIBTransformer".

  6. Click Finish. The new Java Class will be added to the Src tree.

  7. Click on the Class in the Package Explorer view to open up the code editor.

    1. This is sample data to show what we want to send in from an outside system as XML formatted data.

      <users>
      <user>
      <name>jcorbin</name>
      <email>jcorbin@acmeindustries.com</email>
      <first>Jeremy</first>
      <middle>L</middle>
      <last>Corbin</last>
      </user>
      <user>
      <name>slewis</name>
      <email>slewis@acmeindustries.com</email>
      <first>Stacy</first>
      <middle>M</middle>
      <last>Lewis</last>
      </user>
      <user>
      <name>djones</name>
      <email>djones@acmeindustries.com</email>
      <first>David</first>
      <middle>H</middle>
      <last>Jones</last>
      </user>
      </users>
    2. This is sample data to show how we want the data to look after being converted by the Transform

      jcorbin,AcmeIndustries,All,user1@acmeindustries.com,Jeremy,L,Corbin,1,US,en slewis,AcmeIndustries,All,user2@acmeindustries.com,Stacy,M,Lewis,1,US,en djones,AcmeIndustries,All,user3@acmeindustries.com,David,H,Jones,1,US,en

      Note: In this example we want our Transform to assume the Enterprise Name, the Active Status, the Country, and the Language to be the same for all incoming data.

  8. Replace the Java code with the following example:

    package com.acmeindustries.myept.xforms;
    import com.onenetwork.platform.integ.msg.MessageTransform;
    import com.onenetwork.platform.integ.msg.MessageTransformContext;
    import com.onenetwork.platform.tools.io.Streams;
    import java.io.*; //For converting a String to an InputStream
    import java.nio.charset.StandardCharsets; //For converting a String to an InputStream
    import javax.xml.parsers.*; //For parsing XML
    import org.w3c.dom.*; //For parsing XML
    public class UserIBTransformer extends MessageTransform {
    @Override
    public void transform(InputStream in, OutputStream out,MessageTransformContext ctx) throws Exception
    {
    String input = Streams.readFully(new InputStreamReader(in));
    String output = input;
    output = convertXMLtoCSV(input);
    out.write(output.getBytes("UTF-8"));
    }
    public static String convertXMLtoCSV(String XMLInputString)
    {
    String CSVOutput = ""; //To store the output.
    //Convert the String parameter to an InputStream for use by the Document lib
    InputStream stream = new ByteArrayInputStream(XMLInputString.getBytes(StandardCharsets.UTF_8));
    //Parse the XML to a Java Object Array
    try
    {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(stream);
    //Create an array of CSV strings to output
    NodeList nodeList = document.getElementsByTagName("user");
    for (int i = 0; i < nodeList.getLength(); i++)
    {
    //Initialize empty variables to hold the values we read
    String newUserName = "";
    String newUserEmail = "";
    String newUserFirst = "";
    String newUserMiddle = "";
    String newUserLast = "";
    NodeList childList = nodeList.item(i).getChildNodes();
    for (int j = 0; j < childList.getLength(); j++)
    {
    Node childNode = childList.item(j);
    switch (childNode.getNodeName())
    {
    case "name":
    newUserName = childNode.getTextContent();
    break;
    case "email":
    newUserEmail = childNode.getTextContent();
    break;
    case "first":
    newUserFirst = childNode.getTextContent();
    break;
    case "middle":
    newUserMiddle = childNode.getTextContent();
    break;
    case "last":
    newUserLast = childNode.getTextContent();
    break;
    }
    }
    CSVOutput = CSVOutput + newUserName + ",AcmeIndustries," + newUserEmail + "," + newUserFirst + "," + newUserMiddle + "," + newUserLast + ",1,US,en" + "\n";
    }
    } catch (Exception ex)
    {
    ex.printStackTrace();
    }
    return CSVOutput;
    }
    }


    Note: We modified the class to extend MessageTransform.

Create a Message Transform Setting

The last step in setting up our Message Transform is to tell the Platform SDK to use our Transform Class:

  1. In the Package Explorer view on the left of the Platform SDK, expand the Dataset.

  2. Expand the "data" folder.

  3. If there is not already a "PLT.MessageTransform_IB.csv" file present, then add one:

    1. Right click on the "data" folder.

    2. Select New->File.

    3. Name the new file "PLT.MessageTransform_IB.csv".

    4. Depending on your preference settings, the Platform SDK may try to open the file in Microsoft Excel. However, we want to open this file in a text editor:

    5. Close Excel.

    6. Right click on "PLT.MessageTransform_IB.csv".

    7. Select Open With→Text Editor.

    8. The file should now be open in the middle of the Platform SDK.

  4. Add the following new text to the bottom of the file:

    # TransformOn,InboundQueueName,InboundQueueEnterpriseName,InboundInterface,InboundInterfaceVersion,OutboundQueueName,OutboundQueueEnterpriseName,OutboundInterface,OutboundInterfaceVersion,TransformClass,Precedence,Config
    Dequeue,inbox/User,AcmeIndustries,EPT.AcmeIndustries.User_IB,1.0,,,,,com.acmeindustries.myept.xforms.UserIBTransformer,,{}
  5. Save the file by clicking on the Save button.

  6. Click the Submit to Server button.

  7. The Submit dialog will appear.

    1. Leave URL set to: http://localhost

    2. For Username enter: BusinessNetAdmin (or an appropriate user with Value Chain Admin permission)

    3. For Password type: password

    4. For Interface Name type: PLT.MessageTransform_IB

    5. For Interface Version type: 1.0

    6. Click Submit.

Test Our Interface

Test the interface like we did in the "Test Our Inbound Interface" section above.

  1. Change the QueueName in the POST Parameters to "inbox/User" (to match the name of the MessageQueue created in this section).

  2. Change the InboundInterface in the POST Parameters to EPT.AcmeIndustries.User_IB. Also change the message body to be XML formatted.

  3. Change the Body to the XML example:

    <users>
    <user>
    <name>jcorbin</name>
    <email>jcorbin@acmeindustries.com</email>
    <first>Jeremy</first>
    <middle>L</middle>
    <last>Corbin</last>
    </user>
    <user>
    <name>slewis</name>
    <email>slewis@acmeindustries.com</email>
    <first>Stacy</first>
    <middle>M</middle>
    <last>Lewis</last>
    </user>
    <user>
    <name>djones</name>
    <email>djones@acmeindustries.com</email>
    <first>David</first>
    <middle>H</middle>
    <last>Jones</last>
    </user>
    </users>
  4. Send the request and then verify that the new User requests were processed successfully.

Create an Outbound Interface for a Customer Enterprise (CSV)

To send data from the ONE Network platform to a client's system, we will need to set up an Outbound Interface. Each Outbound Interface has a Generator. The Generator produces data in the given format so it can be put into an outbound queue. These are the steps to create an Outbound Interface Generator:

  1. Double click on the "Enterprise Process Template.ept" file in the Package Explorer view in the left of the Platform SDK.

  2. Click on the "Outline" tab on the right of the Platform SDK.

  3. Expand the EPT in the Outline view.

  4. Expand the Integration Interfaces section in the Outline view.
    images/download/attachments/144836879/image2021-10-5_8-55-8-version-1-modificationdate-1670861791000-api-v2.png

  5. Right click on Outbound.

  6. Click on Add Outbound Interface.

  7. A new Outbound Interface will be created. Populate the Overview sub-tab in the center of the Platform SDK.

    1. Set the Name of the new Outbound Interface to something descriptive. In this example let's use "EPT.AcmeIndustries.Item_OB"

    2. Set Format Type to "CSV".

    3. Add an appropriate Description.
      images/download/attachments/144836879/image2021-10-5_8-55-22-version-1-modificationdate-1670861791000-api-v2.png

  8. Click on the Format sub-tab in the center of the Platform SDK.

  9. Add Fields to the Outbound Interface:

    1. Click the "Add Fields" button.

    2. Select the Model Type. Set this to Item for this example.

    3. Select the Model Level. This will be grayed out in this example.

    4. Highlight the Fields that you want to send by holding Shift and click on the field names. Select:

      1. EnterpriseName

      2. Name

      3. ValueChainId
        images/download/attachments/144836879/image2021-10-5_8-55-33-version-1-modificationdate-1670861791000-api-v2.png

  10. Click "Add Fields".

  11. Click "Close".

    images/download/attachments/144836879/image2021-10-5_8-55-50-version-1-modificationdate-1670861791000-api-v2.png

  12. Click on the Generator sub-tab in the center of the Platform SDK.

  13. Under Model Type, select the data model that we want to send through the interface.
    images/download/attachments/144836879/image2021-10-5_8-56-1-version-1-modificationdate-1670861791000-api-v2.png

  14. Click on the Configuration sub-tab in the center of the Platform SDK. This is where we would could configure options regarding sending data such as max attempts, max processing time, or a custom data transformation layer.
    images/download/attachments/144836879/image2021-10-5_8-56-16-version-1-modificationdate-1670861791000-api-v2.png

  15. Click on the Subscription sub-tab in the center of the Platform SDK. This is where we can enable Schedules, add Event Based Subscriptions, or modify Permissions for the Outbound Interface Generator.

  16. Check the "Support Schedules" check box in the Subscription sub-tab. This will be important later when we set up a message destination.

    1. Note: We will add Subscriptions and Permissions in a later section.

  17. Save your changes.

  18. Submit the changes to the server.

Create Outbound message queues for processing

Just like with Inbound Interfaces, Outbound Interfaces also need MessagesQueues.

Create a MessageQueue for an Outbound Interface

Creating a MessageQueue for an Outbound Interface is very similar to creating a MessageQueue for an Inbound Interface.

We will give our MessageQueue the following properties:

  • We will name it "outbox/CustomWidget".

  • We will indicate its Classification as "Outbox", meaning it processes outbound messages.

  1. In the Package Explorer view on the left of the Platform SDK, expand the Dataset.

  2. Expand the "data" folder.
    images/download/attachments/144836879/image2021-10-5_8-56-32-version-1-modificationdate-1670861791000-api-v2.png

  3. If there is not already a "PLT.MessageQueue_IB.csv" file present, then add one. (There should be one present from when we set up an Inbound Interface earlier in this guide.)

  4. Open this file in a text editor.

  5. Add the following content to the new file:

    outbox/Widget,AcmeIndustries,Outbox,1,0
  6. Save the file by clicking on the Save button.

  7. Click the Submit to Server button.

  8. The Submit dialog will appear.

    1. Leave URL set to: http://localhost

    2. For Username enter: BusinessNetAdmin

    3. For Password type: password

    4. For Interface Name type: PLT.MessageQueue_IB

    5. For Interface Version type: 1.0

    6. Click Submit.

  9. Once this is loaded, we can log in and verify that this MessageQueue was created successfully:

    1. Open a web browser.

    2. Navigate to the URL: http://localhost

    3. Sign in with the username "InstanceAdminUser" and the password "password".

    4. Click on Integration→Message Queue Summary in the upper left menu of the web page. You should see "outbox/CustomWidget" listed as one of the Queue Names.

Subscribing to Generate Outbound

Integration Subscriptions allow users to define when they want to receive Outbound messages. Message delivery can happen in response to model actions or on a scheduled basis. Enabling the Integration Subscription flow is a two-step process: the first step is creating meta-data to describe the subscription options, and the second step is for users/enterprises to choose their subscription options.

Create the Subscription Options

  1. If the Outbound Interface is not already pulled up in the view, then open it in the Platform SDK:

    1. Double click on "enterprise process template.ept" in the Package Explorer on the left side of the Platform SDK.

    2. Click on the Outline on the upper right of the Platform SDK.

    3. Expand the EPT.

    4. Expand Integration Interfaces.

    5. Expand Outbound.

    6. Expand the Interface.

    7. Double click on the version number (This is probably 1.0).

  2. The Outbound Interface generator should now be in view. Click on the Subscription sub-tab in the center of the Platform SDK.

  3. Determine if this Outbound Interface should be Schedule-based or Event-based:

    1. Note: At this point we can choose to make our Outbound Interface either Schedule Based or Event Based. In this example, we are going to make it Event Based.

    2. Set up an Event Based outbound process:

      1. Check the "Support Schedules" checkbox if it is not checked.

      2. Click the "Add" button in the "Event Based Subscriptions" section. This will open the "Add Actions" dialog for adding event-based subscriptions.

        1. Select a Model Type. Set this to "Item" for this example.

        2. Select a Model Level if available (if the select box is not grayed out).

        3. Select the name(s) of the action(s) to add. Note that the Description column will tell when a given action will run. Let's choose all actions available to us by holding Shift and clicking on each item.

        4. Click "Add Actions".

        5. Click "OK" to close the dialog. The selected actions should now be visible in the Event Based Subscriptions section.

      3. Add Permissions:

        1. Click "Add" in the Permissions section. This will open the Select Role Types dialog.

        2. Check the checkbox next to the role "ENTERPRISE_ADMIN".

        3. Click OK to close the dialog. "ENTERPRISE_ADMIN" should now show up in the box in the Permissions section. images/download/attachments/144836879/image2021-10-5_8-56-52-version-1-modificationdate-1670861791000-api-v2.png

      4. Add the subscription to an Interface Group:

        1. Double click on "Enterprise Process Template.ept" in the Package Explorer view on the left of the Platform SDK.

        2. Click on the "Outline" tab in the upper right of the Platform SDK.

        3. Expand the EPT.

        4. Expand Integration Interfaces.
          images/download/attachments/144836879/image2021-10-5_8-57-6-version-1-modificationdate-1670861791000-api-v2.png

        5. Right Click on Groups.

        6. Select Add Group.

        7. A new group will now be visible in the Outline. Click on the new group to view the details.

        8. The Interface Group details will be visible in the center of the Platform SDK. Set the details:

          1. Set Name to a descriptive name. In this example, let's use the name "EPT.AcmeIndustries.ItemChanges".

          2. Set Description to a short description of the Interface Group. In this example, set it to "This group tracks changes to Items."

          3. In the Interfaces sub-tab, click the Outbound tab.

          4. Click Add.

          5. Select the Outbound Interface that we created in earlier. (We named this "EPT.AcmeIndustries.Item_OB".)

          6. Click Add.

          7. Check "Is subscription category?". This is found in the Overview section.

        9. Save the changes.

        10. Submit the changes to the server.

    At this point we enabled a subscription option. However, we still need to login to the user interface and create a subscription. We will create the subscription in the following section.

Set Up a Subscription

Introduction to Subscriptions

Subscriptions allow users to subscribe to Outbound Interfaces in order to receive messages. Message delivery can happen in response to model actions or on a scheduled basis. Enabling the Integration Subscription flow is a two-step process: the first step is creating meta-data to describe the subscription options, and the second step is for users/enterprises to choose their subscription options.

Add the Subscription UI

  1. Note: We checked "Support Schedules" in the Outbound Interface when we created the Outbound Interface. This is needed to allow users to add Subscriptions through the User Interface.

  2. Note We checked "Is Subscription Category" when we created the Interface Group. This is also needed to allow users to add Subscriptions through the User Interface.

  3. Add a Web Action to create an Integration Subscription UI with the following steps:

    1. In the Package Explorer section on the left of the Platform SDK, select "Enterprise Process Template.ept".

    2. Click on the Outline tab in the upper right of the Platform SDK.

    3. Click on the name of the EPT ("Acme Industries EPT") in the Outline tab.

    4. In the center view of the Platform SDK, click on the UiMetaModel sub-tab.

    5. Copy the following code and paste it into the UiMetaModel XML, replacing any content that is already there.

      <ModuleUiMetaModel xmlns="http://www.onenetwork.com/Platform">
      <WebInfo>
      <WebAction name="IntegrationSubscriptions">
      <PanelOptions>
      <PanelClass>One.Report</PanelClass>
      <PanelConfig>{reportName: "PLT.IntegrationSubscriptionsReport", filters: {}, autoExecute: true}
      </PanelConfig>
      </PanelOptions>
      </WebAction>
      <WebAction name="NewIntegrationSubscription">
      <PanelOptions>
      <PanelClass>One.IntegrationSubscriptionDetailPanel</PanelClass>
      <PanelConfig>{}
      </PanelConfig>
      </PanelOptions>
      </WebAction>
      <WebActionGroup name="Subscriptions">
      <WebActionRef name="IntegrationSubscriptions"/>
      <WebActionRef name="NewIntegrationSubscription"/>
      </WebActionGroup>
      <RoleTypeUiConfig menuType="tree">
      <RoleTypeRef>
      <IntrinsicRoleType>ENTERPRISE_ADMIN</IntrinsicRoleType>
      </RoleTypeRef>
      <WebActionGroupRef name="Subscriptions"/>
      </RoleTypeUiConfig>
      </WebInfo>
      </ModuleUiMetaModel>


    6. Click the Save button to save the changes.

    7. Click the Submit to Server button. The Submit dialog will open.

    8. Set the URL to: http://localhost

    9. Set the Username to: BusinessNetAdmin

    10. Set the Password to: password

    11. Click Submit.

Create the Subscription From the UI

At this point we have options in the User Interface which will allow us to set up and configuration subscriptions to our Outbound Interface. In this section we will go through the steps to set up one of these subscriptions.

  1. Log into the UI:

    1. Open a web browser, such as Google Chrome.

    2. Navigate to: http://localhost

    3. Log in as:

      1. Username: AcmeIndustriesEntAdmin

      2. Password: password

  2. In the upper left of the web page there will be a menu option labelled "Subscriptions". Click on this button.
    images/download/attachments/144836879/image2021-10-5_8-57-22-version-1-modificationdate-1670861791000-api-v2.png

  3. You will see two options. "Integration Subscriptions" and "New Integration Subscription". Click on "New Integration Subscription". A tab will open with options for creating a new subscription.

  4. Set Category to: EPT.AcmeIndustries.ItemChanges

  5. Set Outbound Interface to: EPT.AcmeIndustries.Item_OB

  6. Set Version to: 1.0

  7. Leave Active checked.

  8. Create a Destination:

    1. Under Destination click New Destination.

    2. Set a Name for the Destination. In this example, I set this to "ItemChangedEmail".

    Set the Destination Type to Email.

    1. Note: An alternative delivery option is SFTP.

    2. Note: Emails will not generate from the server, unless you add your email server's SMTP options in the following file: C:\OneSDK_21.0\default-instance\platform\setup\dvce-app-config.xml

    3. Set Email to your email address.

    4. Set the Subject. In this example, let's use the subject "Item Changed".

    5. Set the Message. In this example, set it to "An item was changed."
      images/download/attachments/144836879/image2021-10-5_8-57-37-version-1-modificationdate-1670861791000-api-v2.png

    6. Click "Create".

    7. Close the dialog by clicking on the X icon in the upper right of the dialog.

  9. Check the checkbox next to the new destination.

  10. Leave ExecuteAs set to the default setting (the logged in user).

  11. Leave Ignore Changes Made By blank.

    1. This would be used if you wanted to only changes by some, but not all, users.

  12. Check the boxes next to Events. In this example, these boxes are labelled "Item: On All Creates" and "Item: On All Updates". This will send us a message for each new Item or change to an existing Item.

  13. Leave the Schedule section blank.

    1. This would be used if you want the notifications to come at predetermined dates or times.

  14. Leave Active Date Range blank.

    1. This would be used if you want to limit the notifications to a certain date range.

  15. Click "Create" to finish setting up the Subscription.

  16. Test the Outbound Interface by sending a new Item to the application. One way to create a new item is to send item information to the Inbound Interface we created earlier. You can follow the example in the section "Test Our Inbound Interface". If an email server is configured then you should receive an email with a message when a new item is created or an item is changed.

    1. Note: configuring an email server is not included in this guide.

Create a Transform for an Outbound Interface.

Introduction to Outbound Message Transforms

Just like with Inbound Interfaces, we can also create Message Transforms for Outbound Interfaces. This gives us the ability to add custom code to alter the contents of an outbound message before the messages are sent. Message Transforms can be used with either pre-built Interfaces or with Interfaces built through the Platform SDK. In this example, we will look at using a Message Transform with an Outbound Interface. You can use the following steps to see a list of Interfaces:

  1. In the Package Explorer section in the left of the Platform SDK, expand the Enterprise Process Template.

  2. Double click on Enterprise Process Template.ept.

  3. Click on the Outline tab in the upper right of the Platform SDK.

  4. Expand Integration Interfaces. You should see both Inbound and Outbound listed here.

  5. Expand Outbound. You should now see a list of any EPT specific Outbound Interfaces. You should also see PLT, which if expanded will show a list of Outbound Interfaces common to all applications built on the Platform SDK.

In this section we will add a Message Transform to the Outbound Interface, EPT.AcmeIndustries.Item_OB. Since this interface already exists, we do not need to create a new Outbound interface. To illustrate the Message Transform process, we will add a Message Transform which replaces the comma delimiter with a custom character.

Add a Transform

  1. Navigate to the Package Explorer view in the left of the Platform SDK.

  2. Right click on "src".

  3. Select New → Other → Java → Class.

  4. Click Next.

  5. Name the Package "com.acmeindustries.myept.xforms".

  6. Name the Class "ItemOBTransformer".

  7. Click Finish. The new Java Class will be added to the Src tree.

  8. Click on the Class in the Package Explorer view to open up the code editor.

  9. Replace the Java code with the following example:

    package com.acmeindustries.myept.xforms;
     
    import com.onenetwork.platform.integ.msg.MessageTransform;
    import com.onenetwork.platform.integ.msg.MessageTransformContext;
    import com.onenetwork.platform.tools.io.Streams;
    import java.io.*; //For converting a String to an InputStream
    import java.nio.charset.StandardCharsets; //For converting a String to an InputStream
    import javax.xml.parsers.*; //For parsing XML
    import org.w3c.dom.*; //For parsing XML
    import com.onenetwork.platform.tools.log.PlatformLogger;
    public class ItemOBTransformer extends MessageTransform {
    private static PlatformLogger LOG = PlatformLogger.get(ItemOBTransformer.class);
    @Override
    public void transform(InputStream in, OutputStream out,MessageTransformContext ctx) throws Exception
    {
    LOG.info("Transforming outbound content...");
    String input = Streams.readFully(new InputStreamReader(in));
    String output = "";
    // Add code here to transform the content.
    output = replaceCommas(input);
    out.write(output.getBytes("UTF-8"));
    }
    /*****************************************************************************************************
    * Name: replaceCommas
    * Description:
    * This function accepts a string as a parameter.
    * It then returns the same string with commas replaced by pipes.
    ******************************************************************************************************/
    public static String replaceCommas(String inputString)
    {
    String outputString = "";
    int stringLength = inputString.length();
    for (int i = 0; i < stringLength; i++) {
    if(inputString.charAt(i) == ',') {
    outputString = outputString + '|';
    }
    else {
    outputString = outputString + inputString.charAt(i);
    }
    }
    return outputString;
    }
    }

Create a Message Transform Setting

The last step is to tell the Platform SDK to use our Transform Class for Outbound messages:

  1. In the Package Explorer view on the left of the Platform SDK, expand the Dataset.

  2. Expand the "data" folder.

  3. If there is not already a "PLT.MessageTransform_IB.csv" file present, then add one:

  4. Right click on the "data" folder.

  5. Select New→File.

  6. Name the new file "PLT.MessageTransform_IB.csv".

  7. Depending on your preference settings, the Platform SDK may try to open the file in Microsoft Excel. However, we want to open this file in a text editor:

    1. Close Excel.

    2. Right click on "PLT.MessageTransform_IB.csv".

    3. Select Open With→Text Editor.

  8. The file should now be open in the middle of the Platform SDK.

  9. Add the following new text to the bottom of the file:

    # TransformOn,InboundQueueName,InboundQueueEnterpriseName,InboundInterface,InboundInterfaceVersion,OutboundQueueName,OutboundQueueEnterpriseName,OutboundInterface,OutboundInterfaceVersion,TransformClass,Precedence,Config
    Enqueue,,,,,ISQ_ItemChangedEmail,AcmeIndustries,EPT.AcmeIndustries.Item_OB,1.0,com.acmeindustries.myept.xforms.ItemOBTransformer,,{}
  10. Save the file by clicking on the Save button.

  11. Click the Submit to Server button.

  12. The Submit dialog will appear.

    1. Leave URL set to: http://localhost

    2. For Username enter: BusinessNetAdmin (or an appropriate user with Value Chain Admin permission)

    3. For Password type: password

    4. For Interface Name type: PLT.MessageTransform_IB

    5. For Interface Version type: 1.0

    6. Click Submit.

Custom interfaces (XML, JSON, etc.)

There might be times where neither an out of the box model is suitable for processing a certain type of message. In this case, you can create a Custom processor to handle the data.

Custom Inbound Interface

Let's say that we want to create an Inbound Interface that does something in a custom way. In the following example we will create a customer Inbound Interface. It will accept a HTTP POST with JSON formatted data. That data will then be parsed and inserted into the database as a new Item.

These are the steps to create the new custom inbound interface:

  1. Let's define what the incoming data will look like. In this example, we are going to receive new item information in a JSON format like the following. We want this data to be inserted into the database as a new Item.

    {
    "enterprise": "AcmeIndustries",
    "itemName": "NewWidget2",
    "price": 123.54,
    "valueChainID": 2050
    }
    1. First create a new Inbound Interface with the type set to Custom:

      1. Expand the EPT in the Package Explore view on the left of the Platform SDK.

      2. Double click on "Enterprise Process Template.ept".

      3. In the upper right of the Platform SDK, click on the "Outline" tab. Expand the EPT and Integration Interfaces in the Outline tab on the right of the Platform SDK.

      4. images/download/attachments/144836879/image2021-10-5_8-57-58-version-1-modificationdate-1670861791000-api-v2.png

      5. Right click on "Inbound".

      6. Select "Add Inbound Interface".

      7. Set the Name. In this example, we will use: "EPT.AcmeIndustries.CustomItem_IB"'

      8. Set the Description. Let's describe it as: "This is a custom inbound interface for items."

      9. Choose "Custom" in the Format Type drop down.

      10. Click the Save button to save the new Inbound Interface.

      11. Click the Submit to Server button to submit the new interface to the server.

    2. We now need to create a java class which extends AbstractInboundProcessor (or directly implements com.onenetwork.platform.integ.msg.InboundProcessor):

      1. In the Package Explorer view on the left side of the Platform SDK, right click on the EPT folder name.

      2. Select New→Class. The "New Java Class" dialog will open up.

      3. Leave Source Folder as the default.

      4. Click Browse next to Package. This will open the "Package Selection" dialog.

      5. Select your EPT's Package name. In this example: "com.acmeindustries.myept"

      6. Click OK to close the Package Selection dialog.

      7. Enter a name for your class in the Name field. For example "CustomItem_IB".

      8. Leave the other values at their defaults.

      9. Click Finish. A new Java file will be created in your EPT's "src" sub-directory. The new Java file will also automatically open in the Platform SDK. images/download/attachments/144836879/image2021-10-5_8-58-11-version-1-modificationdate-1670861791000-api-v2.png

      10. Now we need to add code to handle the custom data format:

        package com.acmeindustries.myept;
        import java.io.*;
        import java.util.ArrayList;
        import java.util.List;
        import org.json.*;
        import com.onenetwork.platform.common.Item;
        import com.onenetwork.platform.data.model.ModelList;
        import com.onenetwork.platform.common.usercontext.PlatformUserContext;
        import com.onenetwork.platform.data.model.ModelDataService;
        import com.onenetwork.platform.env.servicelocator.Services;
        import com.onenetwork.platform.grid.GridTaskContext;
        import com.onenetwork.platform.integ.msg.AbstractInboundProcessor;
        import com.onenetwork.platform.integ.msg.Message;
        import com.onenetwork.platform.tools.io.Streams;
        import com.onenetwork.platform.tools.log.PlatformLogger;
        public class CustomItem_IB extends AbstractInboundProcessor {
        private static PlatformLogger LOG = PlatformLogger.get(CustomItem_IB.class);
        @Override public void processMessage(Message msg, GridTaskContext gridCtx, File fileForErrors, PlatformUserContext ctx) throws Exception {
        InputStream in = null;
        OutputStream out = null;
        try {
        in = msg.readPayload();
        LOG.info("Will process message " + msg.getId());
        String contents = Streams.readFully(new InputStreamReader(in));
        LOG.info("The message contents are: " + contents);
        //Read values from the POST body.
        JSONObject obj = new JSONObject(contents); //convert the JSON string into an object
        String enterprise = obj.getString("enterprise");
        String itemName = obj.getString("itemName");
        Float price = (float) obj.getDouble("price");
        Integer valueChainID = obj.getInt("valueChainID");
        //Initialize a ModelList
        ModelList<Item> modelList = new ModelList<Item>();
        modelList.setActionName("PLT.InsertOrUpdate");
        modelList.setValueChainId(valueChainID);
        //Initialize an Item using data from the POST body.
        Item newItem = new Item();
        newItem.setName(itemName);
        newItem.setValueChainId(valueChainID);
        newItem.setPriceAmount(price);
        newItem.setEnterpriseName(enterprise);
        List<Item> items = new ArrayList<Item>();
        items.add(newItem);
        //Add the Item to the ModelList
        modelList.getModels().addAll(items);
        //Write the ModelList to the database
        ModelDataService mds = Services.get(ModelDataService.class);
        ModelList returnedList = mds.write(modelList, ctx);
        if (returnedList.getListError() != null || returnedList.getErrors().size() > 0) {
        throw new Exception("Unable to insert or update record : " + returnedList.getListError().getValue());
        }
        }
        finally {
        Streams.close(in, out);
        }
        }
        }
      11. Save the file.

      12. Double click on "Enterprise Process Template.ept" in the Package Explorer.

      13. Click the Submit to Server button.

    3. Add the Java Class to the Inbound Interface.

      1. Double click on "Enterprise Process Template.ept" in the Package Explorer view on the left of the Platform SDK.

      2. Click on the Outline tab in the upper right of the Platform SDK.

      3. Expand: AcmeIndustries EPT → Integration Interfaces → Inbound → EPT.AcmeIndustries.CustomItem_IB

      4. Click on 1.0 under "EPT.AcmeIndustries.CustomItem_IB" in the Outline view.

      5. Select the Processor sub-tab in the middle of the Platform SDK.

      6. In the Processor Details section, under "Provide the fully-qualified name of a class...", enter: com.acmeindustries.myept.CustomItem_IB

      7. Click the Save button.

      8. Submit the change to the server.

    4. Create a Message Queue for the custom interface as described in the "Create an Inbound MessageQueue" section above.

    5. Set up a MsgProcessingContext for the custom interface as described in the "Set up MsgProcessingContext" section above.

    6. Test the interface like we did in earlier sections.

      1. Be sure to change the Value for the "InboundInterface" Key to "E PT.AcmeIndustries.CustomItem_IB".

      2. Set the POST body type to "raw" and "text", with the following content:

        {
        "enterprise": "AcmeIndustries",
        "itemName": "NewWidget2",
        "price": 123.54,
        "valueChainID": 2050
        }

Custom Outbound Interface

We can also create custom Outbound Interfaces to perform actions. In this example, we will create an Outbound Interface which will generate JSON formatted data when a record in the "User" Data Model is created or changed.

These are the steps to create the new custom outbound interface:

  1. Create an Outbound Interface:

    1. Expand the EPT in the Package Explore view on the left of the Platform SDK.

      1. Double click on "Enterprise Process Template.ept".

      2. In the upper right of the Platform SDK, click on the "Outline" tab. Expand the EPT and Integration Interfaces in the Outline tab on the right of the Platform SDK.

      3. Right click on Outbound.

      4. Select Add Outbound Interface.

      5. Name the new Outbound Interface "EPT.AcmeIndustries.CustomUser_OB".

      6. Set Format Type to "Custom".

      7. Select the Subscription sub-tab.

      8. Check Support Schedules.

      9. Save the changes.

      10. Submit the changes to the server.

    2. Create a Java Class with the Listener:

      1. In the Package Explorer view on the left side of the Platform SDK, right click on the EPT folder name.

      2. Select New→Class. The "New Java Class" dialog will open up.

      3. Leave Source Folder as the default.

      4. Enter a package name. In this example let's use: "com.acmeindustries.integ"

      5. Enter a name for your class in the Name field. For example, "UserCustomOutboundGenerator".

      6. Leave the other values at their defaults.

      7. Click Finish. A new Java file will be created in your EPT's "src" sub-directory.

      8. Add code to for your Generator:

        package com.acmeindustries.integ;
         
        import java.io.IOException;
        import org.json.JSONArray;
        import com.onenetwork.platform.common.User;
        import com.onenetwork.platform.common.usercontext.PlatformUserContext;
        import com.onenetwork.platform.data.model.ModelDataService;
        import com.onenetwork.platform.env.servicelocator.Services;
        import com.onenetwork.platform.integ.msg.SysIdOutboundGenerator;
        import com.onenetwork.platform.integ.msg.SysIdOutboundProcessingContext;
        import com.onenetwork.platform.tools.log.PlatformLogger;
         
        public class UserCustomOutboundGenerator implements SysIdOutboundGenerator {
        private static PlatformLogger LOG = PlatformLogger.get(UserCustomOutboundGenerator.class);
        @Override public void generate(SysIdOutboundProcessingContext outboundProcessingContext){
        LOG.info("Generating outbound content...");
        JSONArray outputMessage = new JSONArray(); // Initializing a new JSONArray to store output.
        // Iterate through each record inserted or updated.
        for (Long sysID : outboundProcessingContext.getSysIds()) {
        // Get the record data from the system.
        PlatformUserContext userContext = outboundProcessingContext.getPlatformUserContext();
        ModelDataService modelDataService = Services.get(ModelDataService.class);
        User currentRecord = modelDataService.readById(User.class, sysID, userContext);
        // Build a JSON object with the data.
        JSONArray jsonArray = new JSONArray(); // Initialize a temporary JSON array to store data about just this one user.
        jsonArray.put(currentRecord.getName()); jsonArray.put(currentRecord.getEmail());
        jsonArray.put(currentRecord.getFirstName()); jsonArray.put(currentRecord.getMiddleInitial());
        jsonArray.put(currentRecord.getLastName());
        outputMessage.put(jsonArray); // Add this iteration's JSON object to the larger array.
        }
        try {
        LOG.info("The transformed outbound message is: " + outputMessage.toString());
        outboundProcessingContext.getOutputStream().write(outputMessage.toString().getBytes("UTF-8"));
        } catch (IOException e1) {
        LOG.info("Error writing to output stream.");
        e1.printStackTrace();
        }
        LOG.info("Finished generating outbound content.");
        }
        }
      9. Save the file.

      10. Double click on "Enterprise Process Template.ept" in the Package Explorer.

      11. Click the Submit to Server button.

    3. Link the Java Class to the Outbound Interface:

      1. Double click on "Enterprise Process Template.ept" in the Package Explorer view on the left of the Platform SDK.

      2. Click on the Outline tab in the upper right of the Platform SDK.

      3. Expand: AcmeIndustries EPT → Integration Interfaces → Inbound → EPT.AcmeIndustries.CustomUser_OB

      4. Click on 1.0 under "EPT.AcmeIndustries.CustomUser_OB" in the Outline view.

      5. Select the Generator sub-tab in the middle of the Platform SDK.

      6. In the Generator field, under "Provide the fully-qualified name of a class implementing one or more...", enter: com.acmeindustries.integ.UserCustomOutboundGenerator

      7. Click the Save button.

      8. Submit the change to the server.

    4. Create a MessageQueue for the custom interface.

      1. See the "Create a MessageQueue for an Outbound Interface" section above for an example.

    5. Create an Interface Group.

      1. See the "Create an Outbound Interface for a Customer Enterprise" section above for an example.

    6. Add subscription options and user role permissions to the Interface Group.

      1. See the "Create an Outbound Interface for a Customer Enterprise" section above for an example.

    7. Set up a Subscription to the Outbound Interface.

      1. See the "Create the Subscription From the UI" section above for an example.

    8. Test the interface by creating a new user. This can be performed using the same steps as the "Test Our Inbound Interface" and changing the user data .

      1. Note: You should be able to confirm from the Message contents that the data was reformatted properly by logging into http://localhost as InstanceAdminUser.

More Information about Custom Interfaces

For more information about Custom Interfaces see:
https://devnet.onenetwork.com/oms/apps/DeveloperNetwork/www/docs/guides/SdkUsersGuide/help/index.html#Integration/Custom