Baseline comparison sample details

You can run and rebuild this sample, and you can also look at source files to understand how this sample works.

Running this sample

To run this sample:

  1. Create the DiffProjectTest project

  2. Modify the current baseline of DiffProjectTest

  3. Report the differences between the two baselines

You create a project called DiffProjectTest with some artifacts, and create a baseline named V1.

Create the DiffProjectTest project

To create the DiffProjectTest project:

  • Execute the create-project command from the Samples Console.

    The Console displays the following output:

    create-project:
    [echo] Running...
    [java] Create the projet and elements in the project, and then create a 
    baseline...
    [java] referenceUser=rtsAdmin
    [java] referencePassword=********
    [java] referenceUrl=http://localhost:<PORT>/teamserver
    [java] referenceDatasource=jdbc/ilogDataSource
    [java] referenceProjectName=DiffProjectTest
    [java] baseline=V1
    [java] Baseline 'V1' successfully created.

This command creates:

  • A project named DiffProjectTest

  • Different kinds of project elements (action rule, decision table, function, query, technical rule, template, variable set)

  • A baseline named V1

Modify the current baseline of DiffProjectTest

To modify the current baseline of DiffProjectTest:

  1. From the samples console, execute the modify-project command.

    The console displays the following output:

    modify-project:
    [echo] Running...
    [java] Modify artifacts in a project ...
    [java] referenceUser=rtsAdmin
    [java] referencePassword=********
    [java] referenceUrl=http://localhost:<PORT>/teamserver
    [java] referenceDatasource=jdbc/ilogDataSource
    [java] referenceProjectName=DiffProjectTest
    [java] baseline=.
    [java] Create brm.ActionRule:myrule2
    [java] ...
    [java] ...
    [java] ...
    [java] Baseline '.' successfully modified.

    To modify the current project baseline, you create, modify or delete elements in the project.

  2. Connect to the Decision Center Enterprise console using the following URL: http://localhost:<PORT>/teamserver.

  3. Sign in using the following details:

    Username: rtsAdmin

    Password: rtsAdmin

  4. On the Home page, select DiffProjectTest as the Project in use.

  5. On the Home page, click View a baseline in the Current action drop-down list to confirm that the V1 baseline is created (do not select it).

  6. Click the Explore tab.

    The Enterprise console displays project elements.

  7. Select the new name rule, and then click History.

    The Enterprise console displays two versions of the rule. The V1 baseline uses version 1.0, and the current version is 1.1.

  8. Select the two check boxes: version 1.1 and version 1.0.

  9. Click Compare 2 Versions.

    The Enterprise console displays the differences between versions 1.0 and 1.1. You see that some properties have changed.

  10. Click the Content link in the table to see the differences in rule content between the two versions.

  11. Sign out of the Enterprise console.

You can also obtain a global view of the differences between the two baselines.

Report the differences between the two baselines

To report on the differences between the two baselines:

  1. Execute the print-differences command in the samples console.

    The console displays the following output:

    Executing print-differences
    Running...
    Difference between 2 RTS baselines
    referenceUser=rtsAdmin
    referencePassword=********
    ...
    R E P O R T : Wed Sep 10 16:18:16 CEST 2011
    Baseline reference (1) Project : DiffProjectTest Baseline : . Url : http://localhost:<PORT>/teamserver 
    Datasource : jdbc/ilogDataSource
    Baseline other (2) Project : DiffProjectTest Baseline : V1 Url : http://localhost:<PORT>/teamserver 
    Datasource : jdbc/ilogDataSource
    Create brm.ActionRule:myrule2
    Create brm.DecisionTable:mydt2
    ...
    Delete brm.ActionRule:myrule1
    Delete brm.DecisionTable:mydt1
    Delete brm.Function:myfunc1
    ...
    Update brm.ActionRule:new 
    name[definition[].body,documentation,group,lastChangedOn,name,tags[a tag]-
    ,tags[new tag]+]
    Update brm.DecisionTable:mydt[definition[].body,lastChangedOn]
    Update 
    brm.Function:myfunc[arguments[arg0].argumentType,arguments[arg0].name,argume
    nts[arg1]+,lastChangedOn,returnType]
    Update brm.Query:findRule[definition,lastChangedOn]
    Update brm.TechnicalRule:new technical 
    name[definition[].body,documentation,group,lastChangedOn,name,tags[a tag]-
    ,tags[new tag]+]
    Update brm.Template:mytemplate[definition,lastChangedOn]
    Update 
    brm.VariableSet:myvariables[lastChangedOn,variables[v1].bomType,variables[v1
    ].verbalization,variables[v2]+]

The arguments for this command define two baselines: a first baseline qualified as reference, and a second baseline qualified as other. When running this command, the sample connects to the two baselines and navigates through all the reference baseline project artifacts, as follows:

  • An element is found in the reference baseline and not found in the other baseline: it is created.

  • An element is not found in the reference baseline and found in the other baseline: it is deleted.

  • An element is found in both baselines. The command then examines all properties (attribute and reference) to test their values.

The report displays the attributes of the compared baselines (project, baseline name, server URL, and datasource) and shows the differences between the two baselines. The report is formatted as follows:

Report heading Description
Create brm.ActionRule:myrule2 An action rule myrule2 is created.
Delete brm.ActionRule:myrule1 An action rule myrule1 is deleted.
Update brm.ActionRule:new name[definition[].body,documentation,group,lastChangedOn,name,tags[a tag]-,tags[new tag]+]

An action rule new name is updated. The modified attributes are:

  • definition

  • documentation

  • group

  • lastChangedOn

  • name

  • tags (A tag named a has been removed and a tag new tag has been added.)

Rebuilding this sample

To rebuild this sample:

  1. In the Samples Commands view, navigate to Samples Commands > Decision Center > Baseline comparison.

  2. Execute the build command to restore the sample to its original state.

How this sample works

This sample is run in three steps. In the first step the sample creates a project called DiffProjectTest, some artifacts, and a baseline named V1. The second step modifies elements in the project, and the last step prints the differences between the baseline and the current state of the project.

The main class that executes the first step is baselinesdiff.factory.CreateBaseline. It takes the following arguments:

  • referenceUser: The user to connect to the reference baseline

  • referencePassword: The password to connect to the reference baseline

  • referenceUrl: The URL to connect to the reference baseline

  • referenceDatasource: The datasource of the reference baseline

  • referenceProjectName: The reference project name

  • baseline: The baseline to create

The main class that executes the second step is baselinesdiff.factory.ModifyBaseline. It takes the same arguments as above, except:

  • baseline: The baseline to modify, that is, the current version

In the third step, the sample reports differences between the current state of the project and the V1 baseline. The main class executing these actions is baselinesdiff.DifferenceBaseline. It takes the same arguments as above, except baseline, and the following additional arguments:

  • otherUser: The username to connect to the other baseline

  • otherPassword: The password to connect to the other baseline

  • otherUrl: The URL to connect to the other baseline

  • otherDatasource: The datasource of the other baseline

  • otherProjectName: The other project name

  • otherBaseline: The other baseline

  • processor: The default report processor

You can customize this sample using the report processor provided with the sample. To modify the -processor argument, you set a fully qualified class name that implements the baselinesdiff.model.event.EventProcessor interface.

Each of the following factory classes contains a createARTIFACT_TYPE, a modifyARTIFACT_TYPE, and a deleteARTIFACT_TYPE method to create, modify, and delete artifacts:

Factory class Description
ActionRuleFactory Use to manage ActionRule artifacts
BaselineFactory Use to manage Baseline artifacts
DecisionTableFactory Use to manage DecisionTable artifacts
FunctionFactory Use to manage Function artifacts
ProjectFactory Use to manage Project artifacts
QueryFactory Use to manage Query artifacts
TechnicalRuleFactory Use to manage TechnicalRule artifacts
TemplateFactory Use to manage Template artifacts
VariableSetFactory Use to manage VariableSet artifacts

To retrieve artifacts from projects, see the method RTSHelper.getProjectElements (IlrSession session, IlrRuleProject project, int scope).

To obtain the differences between baselines, see the method DiffHelper.DifferenceBaseLineReport getDifferences (Baseline reference, Baseline other).

To report the baseline differences, see the method DefaultProcessorImpl.process (DifferenceBaseLineReport report).

Source files

This sample is located in <InstallDir>/teamserver/samples/serverbaselinesdiff/src/baselinesdiff.

You can also view and modify the sample source files in Rule Designer. To import the sample into your workspace, click the Import projects link in the Samples and Tutorials view, and switch to the Java™ perspective.