Adding the onTicker Rule

This rule computes the Ticker metric. It also creates a customer and employee for the Ticker company, if one does not exist.

Procedure

  1. Right click the Rules folder, and select New > Rule.
  2. Name the rule onTicker. Click Finish.
  3. Use the following section to help you enter the rule details manually.

    (In Source view you can replace the rule editor text with the text given. Copy and paste will work only if you have configured your project exactly according to the instructions. Also check for extra spaces introduced due to line breaks in the document.)

    /**
     * @description
     * @author TIBCO
     */
    rule Rules.onTicker {
      attribute {
        priority = 5;
        forwardChain = true;
      }
      declare {
        Events.Ticker ticker;
      }
      when {
      }
      then {
        System.debugOut("Received Ticker Event[ticker="+ticker.Ticker+",price="+ticker.Price+",volume="+ticker.Volume+",company="+ticker.CompanyName+"]");
        //compute the M_Ticker metric
        Dashboards.M_TickerTracker tickerTracker = Dashboards.M_TickerTracker.compute(ticker.Ticker,ticker.Price,ticker.Volume, ticker.CompanyName);
        System.debugOut("Computed Dashboards.M_TickerTracker[ticker="+tickerTracker.Ticker+",price="+tickerTracker.Price+",volume="+tickerTracker.Volume+"]");
        //Add concept instances for Company and Employees (used for an internal URL link in M_TickerTracker.metric)
        if (Instance.getByExtId(ticker.Ticker+"_Company") == null) {
          Concepts.Employees employees = Concepts.Employees.Employees(ticker.Ticker+"_Employee",Math.round(Math.random()) * 1000);
          Concepts.Company company = Concepts.Company.Company(ticker.Ticker+"_Company",ticker.CompanyName,ticker.Ticker,employees);
        }
      }
    }

Result

Postrequisites

You created the resources necessary to process inputs into a metric instance, and make it available to Dashboard. Next you’ll add some charts to display the data.