Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

What is a Business Object?

Implementing business objects with cDevWorkflow

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 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.

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<string> getInputParameterKeys()
		{
			List<string> oList = new List<string>();
			oList.Add("name");
			oList.Add("age");
			return (oList);
		}
 
		public Type getObjectType()
		{
			return (typeof(clsPerson));
		}
 
		public List<string> getDynamicPropertyList()
		{
			List<string> oList = new List<string>();
			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; }
	} 
}

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.

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”.

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

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

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

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

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.

Click the “getbusinessobject” step to configure its properties:

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.

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.

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

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

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

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

The rendered Instance will look as follows:

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

The decision step should render as follows:

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.

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

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.

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

The post What is a Business Object? appeared first on cDevWorkflow.



This post first appeared on MARK4FIT, please read the originial post: here

Share the post

What is a Business Object?

×

Subscribe to Mark4fit

Get updates delivered right to your inbox!

Thank you for your subscription

×