What is a Business Object?

Posted by Dileepa Wijayanayake on Feb 29, 2016 7:49:57 PM

 

 

 

 

A cDevWorkflow business object (BO) is an object that provides design and runtime integration with API-accessible elements of other applications. cDevWorkflow business objects are implemented using the “deIBusinessObject” interface.

 

Business Object 1

 

Business objects are configured with a class name, namespace and their DLL file name. Once configured, these business objects become available within the workflow designer and can be used to get and set their BO property values in workflow processes. By using the “getBusinessObject” step, the business object can be retrieved at runtime and its properties used within other workflow logic. For example, if a “Person1” BO has a property called “age”, this “age” property can be referenced within a “Decision” step evaluation statement: int.Parse("cDevBO.Person1.age") == 15

 

Writing a custom Business Object

A custom BO can be implemented using the interface “deIBusinessObject”. Below is sample code for clsPersonBO business object.

[csharp]
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using cDevWorkflow.cDevDecisionEngine;

namespace cDevWorkflow.cDevBusinessObjects
{
public class clsPersonBO : deIBusinessObject
{
public object getObject(clsEngineContext oEngineContext, Hashtable oInputParameters)
{
clsPerson oPerson = new clsPerson(oInputParameters["name"].ToString(), int.Parse(oInputParameters["age"].ToString()));

return (oPerson);
}

public List getInputParameterKeys()
{
List oList = new List ();
oList.Add("name");
oList.Add("age");
return (oList);
}

public Type getObjectType()
{
return (typeof(clsPerson));
}

public List getDynamicPropertyList()
{
List oList = new List ();
oList.Add("alpha");
oList.Add("beta");
return (oList);
}

public string getDynamicPropertyValue(clsEngineContext oContext, string key)
{

return (key + 1.ToString());
}

public bool setDynamicPropertyValue(clsEngineContext oContext, string key, string val)
{
File.AppendAllText(@"c:\temp\eventdata\dyna.txt", key + " - " + val);
return (true);
}
}

public class clsPerson
{
public string name { get; set; }
public int age { get; set; }

public clsData oData { get; set; }

public clsPerson(string name, int age)
{
this.name = name;
this.age = age;

Random rnd = new Random();
this.age = rnd.Next(1, 100);

this.oData = new clsData() { num1 = 5, num2 = 7 };
}
}

public class clsData
{
public int num1 { get; set; }
public int num2 { get; set; }
}
}
[/csharp]

Configuring the Business Object

 

Once the custom business object is compiled, place the DLL file in the cDevWorkflow’s “bin” folder and use the Auto Detect feature to configure it.

Business Object 2

 

 

Using the Business Object within a Workflow process

First, make sure the above described “clsPeronBO” object has been configured within the Business Objects section of cDevWorkflow’s Configuration Manager. Create a new Workflow Definition called “TestBO Def”.

 

Business Object 3

 

Next, open the new “TestBO Def” definition within the graphical designer.

Business Object 4

 

Using the designer toolbar button “Manage Business Objects”, let’s define a business object to be used within the process.

Business Object 5

 

Manage Business Objects UI will render within the right pane as follows:

Business Object 6

 

 

Let’s create a process level Business Object called “Person1” that is type “clsPersonBO”.

Business Object 7

 

 

Now that the Business Object is defined, we can use it within the process. Add a “getBusinessObject” step to the workflow design and connect it to the “start” step. Business Object 8

 

 

Click the “getbusinessobject” step to configure its properties:

Business Object 9

 

 

You can also configure properties such as the time to live (ttl) and whether to load properties on demand for the business object. If ttl is configured, the business object will automatically update itself after the expiration period. For example, if the BO has an expiration of 10 minutes, whenever the workflow runtime accesses that business object it will check to see if the BO property values have been retrieved from the source system within the last 10 minutes. If the ttl has expired, the BO will refresh itself automatically to provide the latest information to the process.

Since our sample BO has a property called “age”, let’s use that property to make a decision. Add a “decision” step to the designer canvas and connect it to the “getbusinessobject” step.

Business Object 10

 

Let’s use the decision step to figure out if Person1.age is greater than 18 years. Click the “decision” step and configure the properties as shown below.

 

Business Object 11

 

Save the changes to the definition so that it is ready to execute.

Business Object 12

 

Navigate to the Workflow Instances menu item and create a new Instance, selecting definition “TestBO Def” and entering an instance name.

Business Object 13

 

Once the Instance is created, select the Instance and execute it.

 

Business Object 14

 

 

Once execution is complete, the Instance should have a status of “finish”. Click the “Render” button on the toolbar to render the executed Instance.

Business Object 15

 

The rendered Instance will look as follows:

Business Object 16

 

Click the “check age is > 18” step to drill down into the step information.

Business Object 17

 

The decision step should render as follows:

Business Object 18

 

As we can see in the above graphic, the decision step evaluated the expression ‘int.Parse(“cDevBO.Person1.age”) > 18’ and returned a value of “True” for the return value of the step. Click the “Properties” button to view the properties for the step.

Business Object 19

 

 

Click the icon next to the condition to view the expression with BO replacement values:

Business Object 20

 

 

You may also be interested in reading more on the subject of Configuring a Custom Workflow Step.

A small sampling of the Workflow Technology for BPM Solutions contained within our cDevWorkflow product offering can be found here: Workflow Technology That Works.

[hs_form id="9"]

Learn more about our Process Automation & IT, QA Services or Software Development products and solutions on the Web!  Visit us at: Innovative Process Solutions

Topics: Blog, Business Objects, Business Object, workflow business object, Business Object Code