19 Using the Query Tool to Test ECE

This chapter provides instructions for using the query tool when testing an Oracle Communications Billing and Revenue Management Elastic Charging Engine (ECE) implementation.

Important:

The ECE data model within the Coherence cache is subject to change. Oracle does not recommend that client applications directly use the Coherence API or the query tool for accessing ECE cache data. For querying ECE cache data, write your client applications to use the ECE APIs such as the balance query and authentication query APIs.

About the Query Tool

The query tool query.sh is a wrapper around the Coherence query utility CohQL which uses an SQL-like language. The query tool provides access to ECE cache content by way of CohQL, enabling you to execute queries on ECE Coherence caches. The query tool is meant to be used for debugging purposes only.

For information about how to use CohQL, see Oracle Coherence Developer's Guide:

http://docs.oracle.com/cd/E24290_01/coh.371/e22837/api_cq.htm#CDDIBCDH

With access to the ECE domain model Javadoc documentation, you can use the query tool for writing scripts that interact with the ECE domain objects, constructing CohQL queries. The query tool supports all ECE caches and objects.

The query tool program is included with the ECE Server software in ECE_home/oceceserver/bin where ECE_home is the directory in which ECE Server software is installed.

You can use the query tool as follows:

  • For debugging

  • For development

  • For learning about the ECE Customer domain model

  • For generating reports

To learn about query tool options, use the help command:

$ ./query.sh -h

Using the Query Tool

Use the query tool query.sh to write scripts for interacting with ECE domain objects.

For interactive use of the query tool, see "Using the Query Tool Interactively".

For non-interactive use of the query tool, see "Using the Query Tool Non-Interactively".

Using the Query Tool Interactively

The following shows interactive use of the query tool:

$ ./query.sh
Coherence Command Line Tool
CohQl> select count () from Customer;
Results
1000
CohQL> select key(), value().getCode().toString() from BalanceElement
Rusults
840, "USD"

Using the Query Tool Non-Interactively

The following shows non interactive use of the query tool:

$ ./query.sh -s -c -l "select sum(getAvailableBalance(\'USD\',null).getQuantity()) from Balance"

Query Tool Logfile

The query tool log file is ECE_home/oceceserver/logs/query_out.log.

Query Tool Command History

The query statement history is contained in ECE_home/oceceserver/bin/.cohql-history. You can use the up and down arrows to move through the command history.

Query Examples

This section provides examples for querying data in ECE using the query tool.

Query a Customer Balance

Following is an example of how to query a customer's balance. First, you query a specific customer to find the balance ID, and then you query a specific balance to find the balance element and balance amount.

Tip:

You can use the same model for querying a customer's active session object.

Step 1: Query the customer to find the balance ID

To query the customer and find the balance ID:

$ ./query.sh
Coherence Command Line Tool
CohQl> select key(), value() from Customer where key() = "Cust#6500000001"
Results
"Cust#6500000001", 
 ####################################### Customer Begin ############################################
CustomerImpl
{ customerId='Cust#6500000001
, inTransaction='null
, defaultBalanceId='Bal#6500000001
, externalReference='1
, version=0
, profiles={Birthday=[RatingProfileValueImpl{name=NUMBER, value=2013-08-21,
 validFrom=1970-01-01T00:00:00.000Z, validTo='292278994-08-17T07:12:55.807Z}]}
, subscriberPreferences={}
, subscribedPreferences=null
, AlterationSharingAgreements ={}
, DistributionSharingAgreements ={}
, productMap={Pro#6500000001=ProductImpl{
...
, balanceId = 'Bal#6500000001'
,         profiles = {FriendsAndFamily=[RatingProfileValueImpl{name=NUMBER,
 value=6501234567, validFrom=1970-01-01T00:00:00.000Z,
 validTo='292278994-08-17T07:12:55.807Z}]}
,         subscriberPreferences = {}
,         subscribedSpendingLimitCounters = {}
,         Life cycle state = 102
,         Life cycle Expiration time = 0
,         activeSessions = {}
,         debitRefundSessions = {}
,         audited purchased charge offerings = {}
,         audited purchased alteration offerings = {}
,         audited profiles={}
,         audited UsedAlterationSharingAgreements={}
,         audited UsedDistributionSharingAgreements={}
         balance=null
}}
, balances={}
,
 billingUnits={BillingUnit#6500000001=[BillingUnitImpl
{billingUnitId=BillingUnit#6500000001},
{accountingCycle=[Triple{first=2013-08-21T11:10:16.224-07:00},
{second=2013-09-21T11:10:16.224-07:00},{third=2013-10-21T11:10:16.224-07:00},]},
{billingCycle=[Triple{first=2013-08-21T11:10:16.224-07:00},
{second=2013-09-21T11:10:16.224-07:00},{third=2013-10-21T11:10:16.224-07:00},]},
{billingFrequency=1},]}
, auditedProducts={}
, auditedProfiles={}
, audited AlterationSharingAgreements={}
, audited DistributionSharingAgreements={}
, customerRerateProcessingInfo=CustomerRerateProcessingInfoImpl
{ RerateProcessingStatus='NOT_IN_RERATING, ReratingJobId='null}
 #####################Customer End ######################################### 

Step 2: Query the balance to find the balance element

To query the balance to find the balance element, you specify two components of the associated key (composite key) that links the customer to the balance.

$ ./query.sh
Coherence Command Line Tool
CohQl> select value() from Balance where key().getId() = "Bal#6500000001" and
 key().getAssociatedKey() = "Cust#6500000001"
Results
[BalanceImpl{BalanceId=Bal#6500000001}
{externalRevision=0}{OwnerId=1}
{BillingUnitId=BillingUnit#6500000001}
{BillingUnit=null}ActiveReservationMap{}}
balanceItemSpecs{{USD=BalanceItemSpecImpl{beCode='USD', unit=Money{cur=USD}
, creditProfile=oracle.communication.brm.charging.config.creditprofile.internal.
CreditProfileReference@1dc79d4
, consumptionRule=EARLIEST_START}}}
balanceItems{([BalanceItemImpl{balanceItemId=0}{currentBalance=-10000}
{balanceItemSpec=BalanceItemSpecImpl{beCode='USD', unit=Money{cur=USD}
, creditProfile=oracle.communication.brm.charging.config.creditprofile.internal.
CreditProfileReference@1dc79d4
, consumptionRule=EARLIEST_START}{validity=null}{validityRule=null}]),]

Query the Subscriber Base Balance Summary

Here is an example of how to summarize balance amounts across the entire subscriber base (total balance) in the grid:

$ ./query.sh -s -c -l "select sum(getAvailableBalance(\'USD\',null).getQuantity()) from Balance"