Publish a Project

Print Friendly, PDF & Email

◷ Reading Time: 11 minutes

Introduction

To publish the created project, you should package it using the package builder. The packaging is a process by which to create Service Modules that are .frpd files or a folder containing all the dependent logic documents related to a scenario. A scenario can be any logic document (i.e., Flow, DRD, IRD, DT, etc). When you build a service module, the module becomes self-sufficient from the rest of the logic documents in your project. That means you can simply deploy the module by copying it to any destination.

Package Builder

When you open any logic document, you can find the Package Builder icon on the toolbar:

Or by going to Tools –> Publisher menu:

Package Builder has three tabs,

  1. Builder
  2. Package View
  3. Deployment

Builder

Once you launch the package builder, the window below will appear opening the Builder tab.

Properties

  • Platform: Command Line
  • Method: Copy to a Target Folder
  • Folder: <Path to create the package folder>
  • Include Project assemblies in this package: <State whether you need to include project assemblies in this package>
  • JSON Composer Input: <Path to the input JSON file>
  • Include Notifications: <File name to save notifications>
  • Include Execution Log: File name to save execution messages>
  • Write Output Parameters: <File name to save the output>
  • Include FlexRule Runtime in the deployment folder: <State whether you want to include FlexRule Runtime in the package folder>

In the Builder tab you can,

  1. Select a method that you would like to use for packaging
    1. Package file
    2. Folder
  2. Set some more detailed information for a package file
    1. Setting Identifier and Version of the package
    2. Manage metadata and certificate

There are two methods of building a package,

  1. Create a Package File: Single file that contains all related models
  2. Copy to Target Folder: Single folder that has all the related models

Create a Package File

This allows you to build a single file that has all the related models. You need to select the destination that the package file will be saved. To select the Package filename and its location, you need to click on the three dots button  to browse and select the destination file path. Then in the “Select package file to save” window, select your file path and choose a name for your Package.

Including Assemblies

If you are using any extensions (ex: FlexRule.Extensions.Robotics.dll for RPA) you have to tick the box, Include project assemblies in this project.

Advanced Options

Package allows you to add,

  1. Digital signature
  2. Metadata

These options are available only if a Package File is used.

Digital Signature

When a package is signed by a digital signature, FlexRule Server will highlight that package and show a tick box on the list of packages.

Digital Signature

When a package is signed by a digital signature, FlexRule Server will highlight that package and show a tick box on the list of packages.

Package View

By switching to the Package View tab, you can see all of the logic documents and dependencies that are required for this deployment.

As you see in this example, we opened the Car Flow.xml document of “Car Insurance” example.

Deployment

Deployment is the process of pushing the built package file to a server for hosting. By default, FlexRule Designer has direct integration with FlexRule Server.

  1. Switch to the Deployment tab
  2. In the combo box, please select the FlexRule Server.
Run it as a REST API

FlexRule Server is a product that allows you to host your logic of any kind as a service and consume it in a REST API manner. This enables you to use FlexRule in any technology stack (i.e., Python, PHP, JAVA, etc.), or if you want to build a Service Oriented Platform (SOA) based on your business logic.

Once the Deployment tab is selected, you will see the screen below.

Settings

In the deployment for FlexRule Server, below is the Configuration:

  • Server Address: is the address of the machine to where the FlexRule Server is installed (e.g., http://192.168.10.10:9000)
  • User Account: is the login name to the FlexRule Server that has the access to upload package. (Admin by default has the permission).
  • Password: is the password for the above credential (login).
  • Grant the package ownership to the current login: Will make the above login the package owner so it can manage the package.
  • Enable the package: when this ticked, it start the package and service automatically after deployment is finished.
  • Grant the applications below ownership for execution: This associates an application account for executing (calling) the service (by default app1 account is created during the installation).
Create a Package File

On the Builder tab, make sure the Packaging Logic Method is set to Create a Package File to be able to deploy it to FlexRule Server.

You can set it up as shown in the image below:

Press the Publish button and the package will be deployed to the server. Its logic is ready to be consumed as a REST API service.

Creating Engine from Package

Once a package is built using the File or Folder method, FlexRule Runtime can load it and create an engine to process requests.

File

// Get the stream for your package (i.e., from database, file system, Azure, etc.)
var xbrlStream = File.OpenRead("BalanceSheetClassified.frdp"); // in this example we are building a stream from file system
// pass the stream to PackageLoader class
var loader = new PackageLoader(xbrlStream);
// Your package always has only one module, get the first one
var module = loader.Modules.First();
// Create an engine using the service module RuleSet and Entry
var engine = RuntimeEngine.FromRuleSet(module.RuleSet, module.Entry);

Folder

When the Folder option is selected, then there are two options:

  1. Loading the folder as a ruleset, preserving the folder structure, and creating an engine with the ruleset OR
  2. Loading the logic document from address

RuleSet

// Get the stream for your package (i.e., from database, file system, Azure, etc.)
var xbrlStream = File.OpenRead("BalanceSheetClassified.frdp"); // in this example we are building a stream from file system
// pass the stream to PackageLoader class
var loader = new PackageLoader(xbrlStream);
// Your package always has only one module, get the first one
var module = loader.Modules.First();
// Create an engine using the service module RuleSet and Entry
var engine = RuntimeEngine.FromRuleSet(module.RuleSet, module.Entry);

Logic document

var baseFolder = @"C:\rules\xbrl\balancesheet";
var logic = @"Networks\BalanceSheetClassified\BalanceSheetClassified Flow.xml";
// Get the stream to logic
var stream = File.OpenRead(Path.Combine(baseFolder, logic));
// Create engine using stream
var engine = RuntimeEngine.FromXml(stream, baseFolder);

NuGet

You can automate the packages building process using NuGet.exe command line. Once the NuGet package for the FlexRule models is created, then the application can use PackageLoader to load the Module from the NuGet package.

In order to let FlexRule Runtime loads the package and creates a Module the structure of the NuGet package must follow below:

  • Your Package
    • Bin: folder for your custom assemblies
    • Decisions: folder that has the root to models
      • Package Identifier Folder: the root to models
        • All your Models: all files and folders for your models
    • Info: Folder that has the package and module information
      • Package.xml: The xml file that describes the module specification

Package.Xml

This file provides the module information. The PackageLoader will query this file to populate the module information.

<Package name='test' builderVersion='2'>
	<Decisions>
		<Add name='' entry='' title='' description='' version='' />
	</Decisions>
</Package>

The Package.Xml allows only one module at a time. And below are the description of modules.

  • name: Name of the module, which must match the name of the folder under Decisions
  • entry: Entry point to the RuleSet of the module
  • title: Display name of the module
  • description: Description of the module
  • version: The version of module. i.e. At FlexRule Runtime that will be the service version.

Here is an example:

<Package name='test' builderVersion='2'>
	<Decisions>
		<Add name='Car Flow' entry='Car Flow.xml' title='Car Flow' description='' version='1' />
	</Decisions>
</Package>

Nuspec

Nuspec allows NuGet.exe to create the nuget package. Below is the examples of a nuspec.

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
    <metadata>
        <id>Car-Insurance</id>
        <version>1.0</version>
        <authors>FlexRule</authors>
        <owners>FlexRule</owners>
        <projectUrl>https://resource.flexrule.com</projectUrl>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <releaseNotes></releaseNotes>
        <description>Sample for FlexRule's car insurance models</description>
        <copyright>Copyright ©2019 by FlexRule</copyright>
        <tags>FlexRule</tags>
        <dependencies>
            <dependency id="FlexRule.Runtime" version="8.0" />
        </dependencies>
    </metadata>
 
    <files>
        <file src="bin\**" target="bin" />
        <file src="decisions\**" target="decisions" />
        <file src="info\**" target="info" />
    </files>
</package>

Loading NuGet Package

PackageLoader will allow you to create module from a NuGet package.

var nugetFile="PATH_TO_YOUR_NUGET";
var loader = new PackageLoader(File.OpenRead(nugetFile));
var module = loader.Modules.First(); // Package contains only one module
var engine = RuntimeEngine.FromRuleSet(module.RuleSet, module.Entry);

Sample

The attached sample zip file (Sample-nuget-package.zip) shows the structure of the Car Insurance models for building a NuGet package.

Updated on August 12, 2019

Article Attachments

Was this article helpful?

Related Articles