Tutorials and samples - Operational Decision Manager


Tutorials and samples

You compile and run most of the tutorials and all of the samples using the samples console and sample server. Tutorials take 30 to 45 minutes to complete. Samples take less than 10 minutes to compile and run.

The rule projects for the samples are available only in American English (en_US). Make sure that you start the samples console in the en_US locale, see Importing and running tutorials and samples.


Getting started tutorials

You need the sample server to complete the getting started tutorials. The sample server runs on WebSphere Application Server Network Deployment.

The getting started tutorials are aimed at beginners and users who want to learn the basic workflows of Operational Decision Manager. They are designed to give you quick exposure to ODMs and give you an introductory understanding of the steps required to create a decision service. The tasks in each tutorial are to be completed in the order they are listed, because subsequent tasks often rely on the results of the previous task.


Product tutorials

You run the distributed platform tutorials using the sample server. The sample server runs on WebSphere Application Server Network Deployment.


Product samples

Use this topic to help you locate the samples that are of interest to you.

You run the distributed platform samples using the sample server. The sample server runs on WebSphere Application Server Network Deployment. For more information, see Using the sample server.

The following samples make use of example code and example applications to help you to learn how to use the Operational Decision Manager APIs, and accelerate your own development or administration tasks.

Site map for samples

Samples Where to find them
Decision Server Rules Decision Server V8.5 > Decision Server Rules > Samples

These samples demonstrate features developed in Decision Server Rules.

Decision Center Decision Center V8.5 > Samples

These samples show how to customize Decision Center and test your business rule applications.



Using the sample server

To run the samples and the tutorials, you must start the sample server.



Related information:

Importing and running tutorials and samples


Overview: Sample server

You run the samples and tutorials using the sample server. The sample server runs on WebSphere Application Server Network Deployment.

Operational Decision Manager contains a sample server. The sample server provided is a profile on WAS.

WAS is installed as part of Decision Server. It provides a default, pre-configured execution environment for Rule Execution Server and for Operational Decision Manager samples and tutorials, for the convenience of Operational Decision Manager users.

The sample server is only installed on distributed platforms.

For Decision Server Rules, if you do not want to use the provided sample server, it is not mandatory to use of WAS. All Java™ EE-dependent features can use an alternative Java EE application server from the list of Operational Decision Manager supported platforms. However, the event runtime requires WAS Network Deployment.

You can start and stop the sample server from the start menu shortcuts, directly from the command prompt, or from the samples console in Rule Designer. The samples console also displays message traces produced by the Sample Server.

Single sign-on (SSO) authentication is activated for the sample server. SSO allows users to log in once and gain access to all applications without being prompted to log in again for each of them. If you use different sign-on credentials for the applications on the sample server, for example when performing certain samples and tutorials, you get an error message when you attempt to sign in to the second application.

To avoid this issue, you must sign out of the first console and then sign in to the second console. Alternatively, you can sign in to all of the applications on the server using the credentials that you entered at installation time.



Starting and stopping the sample server

You can start and stop the sample server through the start menu shortcuts, from the command prompt, or from the samples console. You can also start the sample server in debug mode from the Samples Console.


Starting the sample server

To run some samples and tutorials, you must start the sample server. The first time that you start the sample server, a profile for the sample server is created on WebSphere Application Server.

Before you begin

On Windows 7, if you have installed ODM in the Program Files or Program Files (x86) directories, you must be an administrator to start the sample server. You can run the sample server as an administrator, or obtain the write permissions on the Operational Decision Manager installation directory.

You can start the sample server through the start menu shortcut, the command prompt, or the samples console.

The profile creation takes a while to complete. After starting the server, wait until the build has completed successfully.

To start the sample server:

It can take a while for the server startup procedure to complete.

Results

The command window displays server trace messages as the server starts. A message indicates when the server has finished loading and how long it took to start:
[samples.echo] GBRPS0029I: start.server is completed.

BUILD SUCCESSFUL
Total time: 20 minutes 3 seconds
Press any key to continue . . .



Set the server in debug mode

To use certain samples and tutorials, you must start the sample server in debug mode.

Clicking the debug icon starts the server, sets the debug property on WebSphere Application Server, stops the server, and restarts the server to take the modifications into account.

  1. In the samples console, click the Start the Sample Server in debug mode icon. In debug mode, a debugging tool connects to the sample server and steps into the Java™ code and the rules.

  2. Clicking the icon starts the server, sets the debug property on WAS, stops the server, and restarts the server to take the modifications into account. It can take a while for the server startup procedure to complete. The Console view displays feedback messages as the server starts. After setting the debug mode, the debug property remains activated on WAS. Therefore, you can now start the server using the Start the Sample Server icon, or the start menu shortcut, and the server is already in debug mode.



Stopping the sample server

When you have completed the samples and tutorials, and you are done with the sample server, you can stop the sample server from the samples console, from the command prompt, or through the start menu shortcut.

When you have completed the samples and tutorials, you have three ways to stop the sample server.

You can choose to stop the sample server from the start menu, the command prompt, or the samples console.

It can take a while for the server shutdown procedure to complete.

Results

The Console view shows the progress of the shutdown procedure. A message indicates when the server has finished shutting down.



Checking the server port number

To run Rule Execution Server, Decision Center, and other applications on the sample server, you must make sure that the port number is correct.

You must use the correct port number in the URLs. For example, when the documentation indicates the URL http://setgetweb.com:<PORT>/teamserver, you must replace <PORT> with the value used by your server.

The default port number for WebSphere Application Server is 9080, but it can be different depending on the installation.

The first time that you start the sample server, a was.properties file is created along with the WAS profile. The was.properties contains the information about the server host and port, and the path to the installation of WAS.

To check the port number:

  1. Open <WAS_InstallDir>/profiles/ODMSample<version>/data/was.properties.

    <WAS_InstallDir> refers to the installation directory of WAS. Depending on the installation, the installation directory of WAS can be located under the installation directory of Operational Decision Manager.

  2. Check the value of the server.port property.

    For example, if the value is 9081, you must add this value to the URLs of the applications that run on the sample server:

    • Rule Execution Server: http://setgetweb.com:9081/res
    • Decision Center Enterprise Console: http://setgetweb.com:9081/teamserver
    • Decision Center Business Console: http://setgetweb.com:9081/decisioncenter
    • Event Widgets: http://setgetweb.com:9081/EventWidgets/widgets/

  3. You can also look at the preferences in the samples console to view the URLs for Rule Execution Server and Decision Center. On the Window menu, click Preferences, and expand Operational Decision Manager > Samples Console.



Open the administrative console

The first time that you start the sample server, a specific profile is created on WebSphere Application Server. The applications and projects for samples and tutorials are deployed on this profile. You can open the administrative console to configure the sample server, and to view and manage the applications deployed on the sample server.

To open the administrative console:

  1. From the Start menu, click All Programs > IBM WebSphere > IBM WAS <version> > Profiles > ODMSample<version> > Administrative console.
  2. Enter your user ID and password. You created your user ID and password when you installed ODM.

  3. Click Log in.

    The Integrated Solutions Console opens.



Importing and running tutorials and samples

Samples illustrate particular features or functions of ODM. Use code samples to learn how to use and extend the APIs.


Overview: Samples console

You can import the sample projects, then compile and run the samples using the samples console and sample server.

The samples console provides a simple graphical interface that you can use to build and run code samples. Use the Samples Console as a convenient alternative to using Ant directly from the command prompt. You can also manage the sample server using the Samples Console. You require the sample server to use many of the samples. The samples console displays traces produced by both the server and the samples.

See Set up your environment to use Ant for more information about how to set up Ant on your system.

Use the samples console to:

You can import the projects of a sample and run the sample from the Samples Console perspective in Eclipse. The sample lists indicate the samples available from the samples console:


Open the samples console

You can open the samples console from the start menu shortcuts or from the Samples Console perspective. The Samples Console perspective opens the Samples Commands view and the Samples and Tutorials view. From the Samples and Tutorials view, you can import the projects to explore sample code. The Samples Console perspective also opens the Sample Server view which you can use to start and stop the sample server.

To open the samples console, do one of the following:



Related concepts:

Overview: Samples console


Importing tutorials and samples

You import tutorials and samples using the samples console or the Import wizard.

To import a sample from the Samples Console perspective:

To import a sample using the Import wizard:

  1. Click File > Import.

  2. In the Import wizard, select Operational Decision Manager > Samples and Tutorials and click Next.

  3. Locate the required sample and click Finish.

To view the source files for these samples and modify or debug them, import the sample from the Samples Console perspective, or with the Import wizard, and switch to the Java™ perspective.

The source files of these code samples are also available in the following directories:



Related information:

Import Samples and Tutorials wizard


Running samples from the samples console

You can run samples directly from the samples console.

To run a sample from the samples console:

  1. Open Rule Designer and switch to the Samples Console perspective.
  2. In the Sample Server view, click the Start the Sample Server icon.
  3. When the startup of the sample server is complete, click the Samples and Tutorials view to locate the sample or tutorial that you want to run.

  4. Click View instructions to display the relevant documentation.
  5. The Decision Center and Rule Execution Server samples provide Ant targets to compile and run the sample. Click View sample commands to open the Samples Commands view.
  6. When instructed to execute an Ant target, double-click the appropriate Ant target node. The Ant targets are identified by a green target icon.



Running samples from the Ant view

You can run the Ant targets on the projects that you have imported into your workspace.

If you prefer not to use the samples console, you can run the code samples using Ant directly from a Windows command prompt or a UNIX shell. See Set up your environment to use Ant for information about how to set up Ant on your system.

To run the Ant targets from the samples console:

  1. Switch to the Java perspective.
  2. In the Window menu, click Show View > Other, select Ant > Ant, and then click OK.
  3. In the Package Explorer view, expand the project, then drag the build.xml file and drop it in the Ant view.

  4. Click the Hide Internal Targets icon.
  5. In the Ant view, expand the project to view the Ant targets.
  6. Follow the instructions to run the sample and execute the targets from the Ant view instead of the Samples Commands view.



Troubleshooting the sample server and restoring databases

If the server does not start, or if the applications that run on the sample server do not run as expected, you can restore the sample server or the databases.

For other troubleshooting issues, see Troubleshooting and support.



Restoring the sample server

You can restore the server to its initial state. Restoring the sample server re-creates the profile and the databases.

Before you begin

To run the following commands, you must define the ANT_HOME variable. For more information, see Set up your environment to use Ant.

When you restore the sample server, all the deployed applications are deleted. Before restoring the server, make sure that you have done a backup of the existing profile and databases. Restoring the server has the following effects:

To restore the sample server:

  1. Open a command prompt, and go to <InstallDir>/shared/bin/.
  2. Type ant recreateserver, and press Enter.



Related concepts:

Overview: Sample server


Related information:

Starting and stopping the sample server


Restoring databases

You can restore sample databases to their initial state by using either the Ant task command or the samples console. You can restore your sample databases in one of two ways:

The sample server provides the following databases:



Restoring sample databases using Ant

You can delete the existing sample server databases and restore them to their initial state.

Before you begin

To run the following commands, you must define the ANT_HOME variable. For more information, see Set up your environment to use Ant.

If you want to keep the modifications that you have done to the existing databases, create a backup of the existing databases located in <InstallDir>/shared/data/derby.

To restore the databases:

  1. Stop the sample server if it is running.
  2. Open a command prompt, and go to <InstallDir>/shared/bin/.
  3. Type ant restoredb and press Enter.
  4. Start the sample server.



Related concepts:

Overview: Sample server


Related information:

Starting and stopping the sample server


Restoring sample databases from the samples console

You can restore the sample databases provided with the sample server to their original state. You learn how to restore your sample databases provided with the sample server to their state as they were when we first installed Decision Server)

When you restore the sample server, all the deployed applications are deleted. Before restoring the server, make sure that you have done a backup of the existing profile and databases.

To restore the databases to their original state:

In the samples console, click the Restore the Sample Server database icon.

It can take a while for the database restore process to complete. The Console view displays feedback messages as the database is being restored.



Set the encoding in the server trace

When you start the sample server, the trace might display meaningless characters depending on the operating system language. You can fix this by setting the encoding in the sample server start script.

To display the correct characters, specify the encoding in the startserver.bat script.

  1. Open a command prompt, type the chcp command, and press Enter.

    The window displays the number of the active console code page.

  2. Search for the Java encoding canonical name in Supported Encodings.

    For example, on a French machine the encoding might be Cp850.

  3. Open <InstallDir>/shared/bin/startserver.bat, and add the following line: set ANT_OPTS=-Dfile.encoding=Cp850.