Skip to content

How to create a Data Object Service in PDSOE to use with the JSDO

edselg edited this page Dec 2, 2022 · 2 revisions

Prerequisites:

  • OpenEdge Developer Studio (PDSOE)

Create an OpenEdge Database

Steps

  1. Create a copy of the sports2020 database in your OpenEdge working directory.
cd C:\OpenEdge\WRK
prodb sports2020 sports2020

Create an OpenEdge Project in PDSOE

Steps

  1. Launch Progress Developer Studio.
  2. Create a new OpenEdge project with the following values: Project name: Sports Category: Server/WEB [x] Create a Data Object Service (Generate a JSDO catalog)
  3. Use default values in the following pages:
  • ABL Web App deploy details
  • Create an ABL Service
  • Select an AVM and layout options
  • Define PROPATH
  1. At the Select database connections page, click on Configure database connections.
  2. Click on New to create a new database connection.
  3. Create a new database connection with the following values: Connection name: sports2020 Physical name: C:\OpenEdge\WRK\sports2020.db Host name: localhost Service/Port: 20000
  4. Use default values in the following pages:
  • Define a SQL connection
  • Add SQL Connection Profile
  • At the Define Database Server Configuration
  1. Click on Finish.
  2. Click on Apply and Close.
  3. Select the sports2020 database connection from the list.
  4. Click on Finish.

Create a Business Entity

Steps

  1. Click on File > New > Business Entity.
  2. Specify the following values for the new business entity:
  • Package root: \Sports\AppServer
  • Business entity name: Customer
  1. Next to Select a schema file. Set the following values:
  • Operations: (x) CRUD and Submit
  • (x) Select database table:
    • Connection: sports2020
    • Table: Customer
  1. Click on Finish.
  2. Using the Project Explorer view, expand the Sports project and edit the SportsService under Defined Services.
  3. Next to Create a Data Object service page. Select the Customer.cls from the list.
  4. Click on Finish.

Configure the database for the PASOE instance (oepas1)

Steps

  1. From Servers view, double-click on the oepas1 instance to open the Overview page.
  2. Click on Open launch configuration.
  3. Click on Databases.
  4. Select Show all.
  5. Select the sports2020 database from the list.
  6. Click on OK.

Start the PASOE instance (oepas1)

Steps

  1. From Servers view, right-mouse-click on the oepas1 instance and click on Start.

Access the SportsService and Customer data

Steps

  1. From Servers view, expand the oepas1 instance.
  2. Right-mouse-click on the SportsService item and click on Open Catalog URL. The JSDO catalog is shown in a web browser (http://localhost:8810/Sports/static/SportsService.json)
  3. Enter URL http://localhost:8810/Sports/web/pdo/SportsService/Customer to access the data from the Customer table.

Create JSDO test program

Steps

  1. Download progress.all.min.js library from https://github.com/progress/JSDO/blob/master/lib/progress.all.min.js and copy it to the PASOEContent/static folder in the project.
  2. Create a test.html HTML File with the following content:
<!DOCTYPE html>
<html>
<head>
    <meta charset="ISO-8859-1">
    <title>JSDO Example</title>
    <script src="./progress.all.min.js"></script>
    <script src="./test.js"></script>
</head>
<body>
</body>
</html>
  1. New files are published to the PASOE instance automatically (by default 15 seconds after an update).
/* global progress */

var
    serviceURI = "http://localhost:8810/Sports",
    catalogURI = "http://localhost:8810/Sports/static/SportsService.json";

progress.data.getSession({
    serviceURI: serviceURI,
    catalogURI: catalogURI,
    authenticationModel: "anonymous"
}).then(function (/* object */) {
    var jsdo = new progress.data.JSDO({ name: 'Customer' });
    jsdo.read("CustNum < 3125").then(function (object) {
        object.jsdo.ttCustomer.foreach(function (customer) {
            //console.log(jsdo.ttCustomer.Name);
            document.write(customer.data.CustNum 
                    + ' ' + customer.data.Name + ' ' 
                    + customer.data.Balance + '<br>');
        });
    }, function () {
        console.log("Error while reading records.");
    });
}, function () {
    console.log("Error while creating session.");
});
  1. Access the test program using the URL http://localhost:8810/Sports/static/test.html. The specified records will be shown on the screen.
Clone this wiki locally