Introduction

This set of tutorials lead you through the various aspects involved in building a LogicBlox Modeler application. While each tutorial is self-contained, we recommend you follow the tutorials in their numeric order. If you have not worked with the LogicBlox platform before, please familiarize yourself first with the basics of LogiQL. You can start with the LogiQL in 30 minutes tutorial, as well as the tutorials on developer.logicblox.com.

Tutorial 1 introduces you to basic data modeling and UI configuration options. It is a prerequisite for Tutorial 2, in which you learn about more advanced data modeling and UI configuration. You will learn how to query data using CubiQL expressions in tutorial 3 where we will also introduce a number of Modeler features that are configured using CubiQL expressions. The configuration of business rules is the focus in tutorial 4.

1. Installing LogicBlox development environment on Linux/macOS

Let's make sure that your local development environment is set up correctly. You need to:

  1. Download the latest version of LogicBlox for your platform (Linux or macOS). Follow the installation instructions on the download page.
  2. You need to have Open Java Development Kit (OpenJDK) version 11 installed. You can check which version you have installed by running the following command:
    $ java -version
    Download and install an OpenJDK distributions such as AdoptOpenJDK and Amazon Corretto.
  3. We use NGINX (a free, open-source, high-performance HTTP server and reverse proxy) to run the Modeler-based web application on our local development machine. Please follow the installation instructions on the NGINX installation page.
  4. You will also need an installation of Node.js and the npm package manager. Please follow the installation instructions on npmjs.com. Information about installing Node.js and npm via a package manager on Linux and macOS can be found here.

2. Build the tutorial application

Throughout the tutorials, we use an example application to build upon and exercise the material covered. Download the example application from the LogicBlox developer website. You should now have a file modeler-training.tar.gz in your download folder.

Build the example application as follows. This process should also ensure that you have satisfied the software prerequisites:

  1. Extract the contents of the downloaded training application in the directory of your choice:
    $ tar -xzvf modeler-training.tar.gz 
    This should create a directory modeler-training. From now on, we refer to this directory as <TRAINING_HOME>
  2. Start LogicBlox services:
    $ lb services start
  3. Go to the directory <TRAINING_HOME>, and download the required node packages:
    $ cd <TRAINING_HOME>
    $ npm install
    Note that the npm command needs to be run any time you delete and recreate the `modeler-training` directory.

Ok, it's time to build the tutorial application!

  1. Build the lesson source code:
    $ lb config
    $ make

    Note

    Do not worry about trying to understand what each of these steps is doing at this point. We are going to discuss these build steps in detail during the next lessons and you will also learn how to modify the build script to serve your needs.

  2. Open a separate terminal and start the nginx server by running the following command:
    $ cd <TRAINING_HOME>
    $ make start-nginx 

    Tip

    By using a separate terminal, you can keep your NGINX server running while you rebuild your application, rather than having to restart NGINX constantly. Note that this command will not exit and will not print anything if it starts successfully! You can stop it again any time by hitting <CTRL+C>.

  3. You can now access the application via your browser at http://localhost:8086 and log in with user user1 and password as password.

3. Tips on building the tutorial application

Building the application from scratch may take a while. There are many changes that do not require a complete rebuild. We will often ask you throughout the tutorial to perform various incremental builds as listed below.

Loading test data

If you follow the tutorial exactly, you would never need to separately load the test data. The make command both builds as well as loads data for you. However, sometimes, when you make a mistake in changing the workflow files we have provided, separately load test data would be a faster way of correcting the mistake. To only load data, you can use the following command:

$ make load-test-data

Applying UI configuration changes

When we make UI changes, constrained to the canvas, sheet, and action configuration, these changes can be reloaded using the following command:

$ make load-ui

You will appreciate this command as it is much faster than rebuilding the application in its entirety.

4. Restoring base source code and answers

We have setup this training application for you in a way that allows you to restore the application at any point to either the base source code for a tutorial, or the answer source code: The base source code contains source code ready to be built on by following the lessons in a tutorial, whereas the answer source code represents the code you should have at the end of a tutorial, if you had followed all instructions correctly.

To restore to the base of a tutorial, run the following command from <TRAINING_HOME>:

$ ./tools/restore-base <tutorial-number> 

To restore to the answers of a tutorial, run the following command from <TRAINING_HOME>

$ ./tools/restore-answers <tutorial-number> 

Example 1. 

The command below restores the application to the base of tutorial 2:

$ ./tools/restore-base tutorial-2

At the beginning of each tutorial we will ask you to restore the application to the base version of that tutorial, as often we have prepared some new files or made modifications to existing files that you need to use as input for the tutorial.

Tip

If you restore to the base or answers of a tutorial, all your local changes are overwritten. If you want to keep your changes, make sure that you make a local copy of them, before you run the script.