10 Modeling Business Objects

Using business objects in a BPM project help you to manage the data in your process efficiently and also enable you to reuse existing components. Reuse of existing components, reduces the complexity of process making it easier to maintain.

10.1 Introduction to Business Objects

Business objects allow you to model and develop the business entities that are part of your process using the Object Oriented paradigm. Using business objects simplifies the management of the data in your process by encapsulating the data and business behavior associated with the business entity it represents.

A business object is composed of a set of attributes and a set of methods. Attributes store the data related to the entity you are modeling. Methods manipulate the value of these attributes, or perform calculations based on their values.

Typically business objects represent entities in an actual business, but you can also use them to encapsulate business logic that is not associated to any particular entity.

Generally when your process contains a large number of data objects, you can group those that describe the same identity in a business object. For example, in the Sales Quote example you can group the following data in a Quote object:

  • Quote Summary

  • Quote Request Status

  • Recommended Discount

Using business objects to manage a group of related data reduces significantly the complexity of your process by replacing multiple process data objects by a single data object of the type of the business object you defined. Additionally it provides you other benefits described in the Benefits of Modeling Using Business Objects.

In a Sales Quote example you can identify the following business entities:

  • Quote

  • License Terms

  • Product Item

  • Approval Flow

  • Contract

Each of these entities groups a set of highly related data. This data is represented in the attributes of an business object. The attributes define and describe the same business entity. The value of these attributes defines the state of the business object.

The business objects you define in your BPM project are stored in user-defined modules in the business catalog. When you open a business object, its editor shows you its description and the attributes that compose it.

Business objects support inheritance enabling you to reuse the data and behavior they define. For more information about inheritance, see Introduction to Business Object Inheritance and Working with Business Object Inheritance.

Oracle BPM Studio provides an editor to view and edit the structure of a business object. The editor enables you to:

  • Add a description

  • Add documentation

  • Add, edit, and remove attributes.

  • View the namespace information

Figure 10-1 shows the Business Object Editor editing a Quote object created manually.

Figure 10-1 Business Object Editor

Description of Figure 10-1 follows
Description of "Figure 10-1 Business Object Editor"

10.1.1 Types of Business Objects

The way you create a business object determines its characteristics and functionality.

The following are different ways of creating a business object:

  • Manually: You can build a business object manually by creating it and then adding attributes and documentation.

  • Based on an XML schema element or complex type: The resulting business object contains one or more attributes that map the selected schema element or complex type. You cannot remove these attributes, but you can add new attributes.

  • By customizing a synthetic type in the Types module: You can customize the types that the business catalog adds to the Types predefined module when you add a Service or a Reference that require them as arguments. When you customize a type you can store it in a user-defined module, change its name and add attributes to it.

10.1.2 Benefits of Modeling Using Business Objects

Using business objects to manage the data in your process provides you the following benefits:

  • Simpler Processes: Using business objects reduces the quantity of process data objects in your process. This makes your process simpler and easier to read.

  • Coupling Reduction: If your process has fewer data objects, the subprocesses and activities that compose it, require less parameters.

  • Re-use: You can use a business object you defined for a particular process in other processes that do not necessarily belong to the same project. Reusing business objects can dramatically reduce the development time of your project. You can also reuse the data and behavior defined in a business object within the same project, using business object inheritance. For more information about inheritance, see Introduction to Business Object Inheritance and Working with Business Object Inheritance.

  • Easy Maintenance: If you update or fix a bug in a business object all the processes using it benefit from those changes.

  • Parallel Development: After you agree on a certain interface for the business objects in your process, some members of your team can work on the development of those business objects while others work on the development of the process.

  • Unit Testing: You can test each of the business objects in your process separately. Unit Testing reduces the complexity of your test cases and improves significantly the quality of your project.

10.1.3 Naming Conventions for Business Objects

When you name a business object you should respect the following rules:

  • Use one or more nouns, or nouns modified by adjectives.

  • Do not start the name with a number.

  • Use capital letters only to distinguish internal words.

  • Keep names simple and descriptive.

  • Use whole words; avoid using acronyms unless they are widely known.

Note:

Oracle BPM Studio forces the first letter of the name of a business object to uppercase.

10.2 Working with Business Objects

You can add business objects to your BPM project to store data related to the processes it contains. The business objects you add are stored in the business catalog.

For more information about the business catalog, see Using the Business Catalog.

When developing a business object you can modify it, rename it, or delete them. You can also add documentation that helps you identify the functionality of the business object or describes how to use it.

10.2.1 How to Add a Business Object

You can add business objects to the business catalog to model the business entities to store the data in your BPMN process.

To add a business object:

  1. Right-click a user-defined module in the business catalog.
  2. Select New and then select Business Object.
  3. Enter a name to identify the new business object.

    Note:

    You cannot repeat a name within the same module. However you can assign the same name to business objects in different modules.

  4. Click OK.

10.2.2 What Happens When You Add a Business Object

The business object appears in the business catalog. You can use this business object to define the type of the following elements in your BPMN process:

  • Arguments in data associations

  • Process data objects

  • Project data objects

10.2.3 How to Modify a Business Object

You can modify an existing business object by:

10.2.4 How to Delete a Business Object

You can delete a business object that you do not use or need. If your project contains flow objects or data associations that use the deleted business object, then you must remove them manually.

To delete a business object:

  1. In the Applications window, right-click the business object you want to delete.
  2. Select Delete.

    A confirmation message appears.

  3. Click OK.

10.2.5 What Happens When You Delete a Business Object

Oracle BPM Studio removes the business object from the business catalog. If there are any flow objects in your process that use the removed business object, then you must remove these references manually.

10.2.6 How to Document a Business Object

You can add documentation to a business object for other process developers to understand its functionality and data structure.

To Document a business object:

  1. Edit the business object.
  2. In the business object editor, in the business object Editor, click the Edit button next to the Documentation field.
  3. Add the documentation for the business object.

    See Introduction to the Documentation Editor, for details on how to create and edit documentation.

  4. Click Close.

10.2.7 What Happens When You Document a Business Object

The documentation is available for other process developers to read and modify.

10.3 Using a Business Object in a Process

Business objects store data related to your process. You can update the information in this data object from any of the activities in the process.

To use a business object in your project, add a process data object to your process and set its type to the business object you created.

10.3.1 How to Use a Business Object in a Process

You can create a complex data object in your process that defines its type using a business object.

To use a business object in a Process:

  1. Add a process data object to your process. Use the business object as the type of the data object.

    See How to Add a Process Data Object, for information on how to add a process data object.

    Note:

    When selecting the type of the data object use the Browse More Types... button to display the complete list of types. Then select <Component> to display the list of available business objects.

  2. Initialize the value of the data object in the process using a Script Task or Data Associations.

10.3.2 What Happens When You Use a Business Object in a Process

The data object you defined has the structure defined in the business object. The type of the data object is the name of the business object. For example, if you define a business object SalesQuote and then create a data object that uses this business object as its type, then the type of the data object is SalesQuote.

You can assign values to the data objects that use these types using data associations and script tasks.

10.4 Adding Business Objects Based on a XML Schema Element or Type

You can create a business object based on an XML schema element or complex type. The XML schema element or complex type you use to create your business object has to be part of your BPM Project.

You can add an XML schema that contains the element or complex type to your project, or you can use a use a type defined inline in a WSDL file. For the latter you must add the WSDL file to your project by adding an SOA Adapter of type Web Service.

The business objects are based on an XSD schema and business object elements are initialized based on their XSD definition. The default data values are applicable only to process data object and not business object. If we apply default data values on business objects, the schema definition is not honoured.

When you create a business object using an XML schema element, the selected element becomes an attribute of the resulting business object.

When you create a business object using an XML schema element, the selected element becomes an attribute of the resulting business object.

If you create a business object based on a schema contained in a WSDL file, then you cannot use the resulting business object as the type of an attribute of another business object.

10.4.1 How to Add a Business Object Based on a XML Schema Element or Type

Before following this procedure ensure that the business catalog contains the XML schema you want to use as a base for your business object.

To add a business object based on an XML schema or complex type:

  1. Right-click a user-defined module.
  2. Select New and then select Business Object.

    The Create Business Object Dialog appears.

  3. Enter a name to identify the new business object.
  4. Select Based on External Type.
  5. Click the Browse button next to the External Type field or add a new XML schema following the procedure described in How to add an XML Schema to Your BPM Project.
  6. Select the external type from which to create the new business object.

10.4.2 What Happens When You Create a Business Object Based on an XML Schema Element or Type

You cannot modify or add attributes to the business object. The structure of the business object is based on the structure of the XML schema element or type.

10.4.3 How to add an XML Schema to Your BPM Project

From the Create Business Object dialog box you can add an XML schema to your project.

To add an XML schema to your BPM project:

  1. In the Create Business Object Dialog, select the Based on External Schema option.
  2. Click the Schema Browser button.

    The Type Chooser dialog box appears.

  3. In the upper right corner, click the Import Schema Files button.

    The Import Schema File dialog box appears.

  4. Click the Browse Resources button next to the URL field.

    The SOA Resource Browser appears.

  5. Browse your file system and select a schema file.
  6. Select Copy to Project.
  7. Click OK.

    If the XML schema contains references to other types a dialog box to confirm their import appears.

    The Browse Resources dialog box closes and the Type Chooser dialog box appears.

  8. Select an element to use as the base of your business object.

10.4.4 What Happens When You Add a Schema File to Your Project

The Schema Browser copies the selected XML schema to the Schemas directory in your project. You can use it to create new business objects without having to re-add it

10.5 Introduction to Business Object Attributes

Attributes store data that defines and describes the business object. The attributes in a business object are equivalent to instance variables in Object Orientation.

In the Sales Quote example you can identify the following attributes in the Quote object:

  • Summary

  • Product Items

  • Quote Request Status

  • License Terms

  • Recommended Discount

These attributes describe the product and are relevant to the process. The ID or SKU serves to identify the chosen product. The description is probably used to show the user what the product does. And the price is used to show the customer how much the product costs and later in the process to calculate the total amount due.

When you define an attribute you must specify:

  • Name: used to identify the attribute.

  • Type: that defines the type of data you can store in the attribute. Attributes support simple types or other defined business objects.

Additionally you can define the following:

  • Description: provides details about the attribute that help other process developers to understand its use.

  • Documentation. See How to Document a Business Object Attribute.

  • Custom default value

  • Not null constraint.

10.5.1 Supported Data Types for Business Object Attributes

The following table describes the supported data types for an attribute in a business object:

Table 10-1 Supported Data Types

Data Type Description

string

Alphanumeric values

int

Integer numbers

boolean

True or false values

double

Double numbers

decimal

Decimal numbers with defined precision

dateTime

Unit of time, stores the date and the time

long

Long numbers

duration

Intervals of time

base64Binary

Binary values (For example: images, files)

float

Float numbers

byte

An 8-bit signed two's complement integer

short

A 16-bit signed two's complement integer

date

Unit of time, stores the date only

time

Unit of time, stores the time only

Array

A collection of elements of a specified data type

Complex Types

Other business objects

10.5.2 Naming Conventions for Business Object Attributes

When you name a attribute of a business object you should respect the following rules:

  • Use one or more nouns, or nouns modified by adjectives

  • Use capital letters only to distinguish internal words

  • Keep names simple and descriptive

  • Use whole words; avoid using acronyms unless they are widely known

  • Do not start the name with symbols

  • Use short but meaningful names

  • Avoid using one-character names

Note:

Studio forces the first letter of the name of an attribute to lowercase.

10.6 Working with Business Object Attributes

To model a business object you must add its attributes. These attributes store the data related to your process.

You can add, modify and delete attributes as necessary. You can also add them to documentation that describes the data they store and provides any necessary information to the user of the business object.

10.6.1 How to Add a Business Object Attribute

To model a business object that you created from the start, you must add attributes.

To add an attribute to an existing business object:

  1. In the Applications window right-click the business object where you want to add the attribute.
  2. Select New and then select Attribute.

    Note:

    Another alternative for the previous steps is editing the business object and clicking the Add button in the Attributes section.

  3. Enter a name to identify the new attribute.

    Note:

    You cannot use the following reserved words for attribute names.

    abstract, any, as, assert, boolean, break, byte, case, catch, char, class, const, continue, def, default, do, double, else, enum, extends, false, final, finally, float, for, goto, if, implements, import, instanceof, int, interface, long, native, new, null, package, private, protected, public, return, short, static, strictfp, super, switch, synchronized, this, threadsafe, throw, throws, transient, true, try, void, volatile, while

  4. From the type list, select a type for the new attribute, or click the Browse More Types button to select a complex type.

    Note:

    To use the array type, click the Browse More Types button, select the type of the array and select the Array check box.

  5. Click OK.

10.6.2 How to Remove a Business Object Attribute

You can delete a business object that is no longer useful to your project.

To delete an attribute from an existing BPM Object:

  1. Edit the business object that contains the attribute you want to remove.
  2. In the Attributes section, select the attribute you want to remove.
  3. Click the Remove button at the top of the table.

    A confirmation message appears.

  4. Click OK.

10.6.3 How to Document a Business Object Attribute

You can add documentation to a business object attribute for other process developers to understand its functionality.

To document a business object Attribute:

  1. Edit the business object that contains the attribute you want document.
  2. In the Attributes section, expand the business object attribute you want to document.
  3. Click the Edit Documentation button next to the Description field.

    The Documentation Dialog appears.

  4. Add the text to document the functionality of the selected attribute.

    See Introduction to the Documentation Editor, for details on how to create and edit documentation.

10.6.4 What Happens When You Document a Business Object Attribute

The documentation is available for other process developers to read and modify

10.7 Working with Business Object Methods

A business object can contain methods that manipulate and perform operations with the data it contains. These methods represent the behavior of the business object.

You can add, modify and delete attributes as necessary. You can also add them todocumentation that describes the operations they perform and provides any necessary information to the user of the business object.

10.7.1 How to Add a Business Object Method

You can define business objects methods to manipulate and perform operations based on the data of the business object.

To add a business object method:

  1. Open the business object.
  2. In the Methods section, click the Add Method button.

    The Method dialog box appears.

  3. Enter a name to identify the method.
  4. Click OK.

    The new method appears in the Methods section.

  5. Expand the method and add the script code in the text area that appears.

    For more information on BPM Scripting, see Writing BPM Scripts.

  6. Optionally you can change the signature, see How to Change the Signature of Business Object Method.

10.7.2 How to Change the Signature of Business Object Method

You can change the signature of a business object method by changing the name or the return type, or by modifying the input arguments.

To change the signature of a business object method:

  1. Open the business object that contains the method in the Business Object editor.
  2. Expand the Methods section.
  3. Expand the method that you want to modify.
  4. Click the Change Signature button located next to the Remove button.

    The Change Signature dialog box appears.

  5. You can edit the following elements of the method signature:
    • the name of the method

    • the type of the return parameter

    • add, remove or modify input arguments

10.7.3 How to Remove a Business Object Method

You can remove a business object method that you no longer use.

To remove a business object method:

  1. Open the business object that contains the method you want to remove, in the Business Object editor.
  2. Expand the Methods section.
  3. Click the Remove button for the method you want to remove.

10.7.4 How to Document a Business Object Method

You can add documentation to a business object method for other process developers to understand its functionality.

To document a business object Attribute:

  1. Edit the business object that contains the method you want document.
  2. In the Methods section, expand the business object method you want to document.
  3. Click the Edit Documentation button next to the Description field.

    The Documentation Dialog appears.

  4. Add the text to document the functionality of the selected method.

    See Introduction to the Documentation Editor, for details on how to create and edit documentation.

10.8 Sharing Business Objects

You can share business objects between different projects by exporting them to a file and then importing them.

You can choose to export a single business objects or multiple business objects. When exporting multiple business objects you can also export exceptions. The file that contains the exported business object has the extension .bob. If the business object depends on other business objects, then those dependencies are also included in the export file.

You can import the business objects from the export file in any other project. When you import a business object, Studio also imports the module where it was stored if the module does not exist already.

10.8.1 How to Export a Business Object

You can export a business object to share it with other developers.

To export a business object:

  1. In the Applications window, right-click the business object.
  2. Select Export.

    The Select Object File dialog box appears.

  3. Select a directory where to store the exported business object.
  4. In the File Name field, enter a name for the exported business object.
  5. Click Save.

    The exported business object file is stored to the selected directory.

10.8.2 How to Import Business Objects from a File

You can import a business object that was exported from another project.

To import business objects from a file:

  1. In the Applications window, right-click the Business Catalog node.
  2. Select Import Business Objects.

    The Select Object File dialog box appears.

  3. Select the file that contains the exported business objects.
  4. Click Open.

    The business objects contained in the selected file appear in the business catalog.

10.9 Introduction to Business Object Inheritance

Inheritance enables you to reuse the data and behavior defined in a business object. This avoids duplicating data structures and scripts, making maintenance easier and less error-prone.

To use inheritance you create a business object as the child of another business object that defines the attributes and methods that you want to reuse. The latter is called the parent object.

The child object has access to the attributes and methods of the parent objects as if it defined them.

In a business process that manages the payroll of a company, you can define a business object Employee and then a child business object Manager that inherits the data and methods of Employee and re-defines some of them.

10.9.1 Method Overloading

The child business object can re-define the methods defined in the parent object, assigning them a different behavior specific to that child business object. The input arguments and return parameters of the re-defined method must match the ones in the method from the parent object.

10.9.2 Polymorphism

The child business object is a sub-type of the parent business object. This means that you can define a data object using the type of the parent business object and then assign it an instance of the child business object. When you do this, you only have access to the attributes and methods defined in the parent business object. However, those methods that were re-defined in the child business object, behave in the way they were defined in the child object.

10.9.3 Method Overriding

A business object can have multiple methods with the same name but different sets of arguments. The runtime engine decides which method to run based on the arguments passed when invoking the method.

10.9.4 Attribute Shadowing

The child business object can define an attribute of the same name and type of an attribute defined in the parent object.

10.9.5 Abstract Business Objects

You can mark a business object as abstract to indicate that it only defines data and methods to reuse in child business objects, but it does not make sense to create an instance of this business object. Marking it as abstract ensures that you cannot create an instance of this business object.

10.10 Working with Business Object Inheritance

You can use business object inheritance to reuse data and methods, avoiding code duplication and making maintenance easier.

This section describes how to create a child business object and how to mark an object as abstract.

10.10.1 How to Create a Child Business Object

You can create a child business object to reuse the attributes and methods defined in a business object.

To create a child business object:

  1. In the Applications window, right-click the business object you want to use as the parent business object.
  2. Select Create Child Object.

    The Create Business Object dialog box appears.

  3. Enter a name and select a destination module.
  4. Click OK.

    The Business Object editor with the child business object opens. Note that there is a parent field that indicates which is the parent object.

    Note:

    You can also define a child object by selecting its parent object for an existing business object.

The child object can use the attributes and methods defined in the parent business object.

10.10.2 How to Mark a Business Object as Abstract

You can mark a business object as abstract to indicate that it only defines behavior and data.

To create an abstract business object:

  1. Open the business object you want to mark as abstract in the Business Object editor.
  2. Select the Abstract check box.

You can mark a business object as abstract to indicate that it only defines behavior and data for child objects to reuse. You cannot instantiate an abstract business object, you can only use it to define the type of a data object and then assign it an instance of a child business object.