Adding a Query Template Step

Follow the instructions below to add a reusable query template step.

  1. In the Anzo console, expand the Blend menu and click Graphmarts.
  2. On the Graphmarts screen, click the name of the graphmart that you want to change.
  3. Click the Data Layers tab. Anzo displays the existing data layers.
  4. Click the ellipses () on the layer for which you want to create a step, and then select Add Step/View. Anzo opens the Add step dialog box.

  5. Follow one of the options in this step, depending on whether you want to create a step from scratch or clone an existing template step for reuse:
    • Select Templated Step, and then click OK. Anzo opens the Create templated step screen. Proceed to the next step.

    • If you want to clone an existing step and add it to this layer, click the Existing Steps tab and follow these steps:
      1. Select the templated step that you want to clone and click OK. Anzo displays the Clone dialog box, which asks if you want to copy the permissions from the existing step.

      2. On the Clone dialog box, click Yes to copy the permission configuration from the existing step or click No to copy the step without the permission configuration.

        Anzo clones the step, adds the copy to the layer, and returns to the Data Layers screen.

      3. On the Data Layers screen, click the ellipses () on the cloned step and select Edit. Anzo opens the Edit load data step screen. Proceed to the next step.
  6. Under Details, type a name for the step in the Title field and add an optional description in the Description field.
  7. By default the Enabled option is selected, indicating that the step is enabled and will run when the layer is loaded. If you want to disable the step so that it is not processed, clear the Enabled check box.
  8. Click the Source drop-down list and configure the source data for this step. Steps can build upon the data generated by steps in other layers or can be self-contained, applying changes that relate only to the data defined in the layer that contains this step. You can select any number of the following options:
    • Self: This option is selected by default and means that the query runs against only the data that is generated in the layer to which this step belongs.
    • All Previous Layers Within Graphmart: Choosing this option means that the query runs against the data that is generated by all of the layers in the graphmart that precede this layer.
    • Previous Layer Within Graphmart: Choosing this option means that the query runs against only the data that is generated by the one layer that precedes this layer.
    • Layer Name: The Source drop-down list also includes options for specific layer names. You can choose a specific layer to run the query against only the data that is generated by that layer.

      You can remove any of the source options by clicking the X to the left of the option name.

  9. Click the Data models drop-down list and select the model or models to use for this step to run against.
  10. Click the Template tab. Anzo displays the Template screen.

  11. Follow the steps below to create a template query that uses parameters to represent key/value pairs:
    1. On the left side of the screen, use the transformation template to write the query that this step will run. The template includes the syntax for writing SPARQL INSERT and DELETE queries and includes source and target graph parameters that Anzo replaces at runtime. Edit the template text as needed.

      In the query, include parameters in the format ${key_name} that you intend to replace at runtime with the value that you define for the key. Anzo automatically adds the key to the Key/Value Table on the right side of the screen.

      For example, the following INSERT query includes several parameters that represent properties and functions:

      INSERT {
        GRAPH ${targetGraph}{
          ?lsubj ${linkProperty} ?rsubj
        }
      }
      ${usingSources}
      WHERE {
        ?lsubj <${sourceProperty}> ?lobj .
        ?rsubj <${targetProperty}> ?robj .
        FILTER (${lFunction}(?lobj) ${operator} ${rFunction}(?robj))
      }
    2. On the right side of the screen above the Key/Value Table, click Refresh Keys. Anzo adds each key in the template to the table. For example:

    3. In each row, type the desired Value for each key. For example, the row below specifies an eventid property URI (http://cambridgesemantics.com/ont/autogen/5j/Tickets#tickit_sales_eventid) as the value for the linkProperty key:

      To delete a key/value row, click the trashcan icon () to the right of the row.

  12. Click Save to save the template and add the step to the data layer. Anzo adds the step as the last step in the layer. If you want to change the order of the steps, click the black bar on the left side of a step and drag it up or down.

The new Templated Step becomes available to clone into other data layers. Users can select the step from the Existing Steps tab when they add steps.

Related Topics