View source | Discuss this page | Page history | Printable version   

External System/UserGuide

Contents

Introduction

An external system represents an application or machine which Openbravo is able to communicate with. In the External System window we can register the configuration data required to communicate with an external system.

Bulbgraph.png   This feature is available starting from 22Q3.

External System

To create a new external system configuration we have to navigate to the External System window, create a new record in the header and populate the following fields:


ExternalSystemHeader.png

HTTP External System

If the selected protocol is HTTP then the HTTP subtab is displayed, allowing to configure the specific HTTP settings for the external system:

Note that it is only supported to have one active HTTP configuration per external system at a time.


HttpExternalSystem.png

Authorization Type

By default three types of authorization types are supported:

Oauth2 config.png

Connectivity Check

Once the configuration of an external system is entered it is possible to test the connectivity with that external system by clicking on the Test button.


CheckConnectivity.png

Programmatic API

Backend

There is a programmatic API that can be use to communicate with the configured external systems. The different types of external systems extend the ExternalSystem class which defines the API. Let's see an example of use:

  @Inject 
  private ExternalSystemProvider externalSystemProvider;
  ...
  ...
  ExternalSystem externalSystem = externalSystemProvider.getExternalSystem(externalSystemId).orElseThrow();
  CompletableFuture<ExternalSystemResponse> response = externalSystem.send(Operation.READ, "path", Map.of("queryParameters", Map.of("param", "1234")));
  1. We first need to inject the ExternalSystemProvider that helps us to get the external system we want to communicate with.
  2. We retrieve the external system instance with externalSystemProvider.getExternalSystem(externalSystemId), where externalSystemId is the ID of the external system configuration (C_External_System record).
  3. We use the send method to send the information to the external system with an specific operation. In the example we are using the READ operation to retrieve data from the external system, the "path" url segment and a query parameter. Note that the send method returns a CompletableFuture containing the response coming from the external system.

The available send operations are:

HTTP External System Send Methods

For HTTP external systems each of the operations is implemented with a different HTTP method:

Client Side

The external system Javascript API allows to communicate with external systems from the different mobile applications.

  // Retrieve the external system instance  
  const externalSystem = OB.App.ExternalSystem.get(externalSystemId);
  // Prepare the data and the configuration of the send operation
  const data = {p1: '1', p2 :'2'};
  const configuration = {operation: 'CREATE', path: 'myPath'};
  // Send the information to the external system
  const response = await externalSystem.send(data, configuration);

In this example we get a new external system instance from the ID of a known external system using OB.App.ExternalSystem.get. If the provided ID belongs to an external system that is unknown then the OB.App.ExternalSystem.get will throw an error.

Bulbgraph.png   A known external system for a mobile application is an external system whose definition is included in the externalSystems terminal property

Once we have the external system instance, we can use it to send information to the external system with the following parameters:

HTTP External System Send Methods

For external systems based on the HTTP - Frontend protocol a different HTTP method is used by the send method depending on the operation provided in the configuration:

Loading External Systems into the POS

As explained in the previous section, the known external systems for a terminal of a mobile application are kept in the externalSystems terminal property.

To be able to load the external systems into that property for the POS, the org.openbravo.retail.posterminal provides the ExternalSystemLoader interface that can be implemented to specify the external systems whose information must be loaded into the terminal. This way different modules, by following its own logic, can specify the external systems that can be referenced by its ID.

public class ExternalSystemLoaderExample implements ExternalSystemLoader {
  @Override
  public Set<String> getExternalSystems(JSONObject jsonSent) throws JSONException {
    return Set.of("externalSystemID1", "externalSystemID2");
  }
}

Retrieved from "http://wiki.openbravo.com/wiki/External_System/UserGuide"

This page has been accessed 715 times. This page was last modified on 25 September 2023, at 10:24. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.