Skip to content

Latest commit

 

History

History
179 lines (129 loc) · 4.05 KB

File metadata and controls

179 lines (129 loc) · 4.05 KB
layout wmt/docs
title JSON Store Task
side-navigation wmt/docs-navigation.html
description Plugin for interacting with Concord's JSON Store API

{{ page.title }}

The jsonStore task provides access to JSON Stores. It allows users to add, update and remove JSON store items using Concord flows.

This task is provided automatically by Concord.

Usage

Check if Store Exists

Syntax:

- ${jsonStore.isStoreExists(orgName, storeName)}
- ${jsonStore.isStoreExists(storeName)}

The task uses the current process' organization name if the orgName parameter is omitted.

The expression returns true if specified store exists.

Check if Item Exists

Syntax:

- ${jsonStore.isExists(orgName, storeName, itemPath)}
- ${jsonStore.isExists(storeName, itemPath)}

The task uses the current process' organization name if the orgName parameter is omitted.

The expression returns true if specified item exists.

Create or Update an Item

Syntax:

- ${jsonStore.put(orgName, storeName, itemPath, data)}
- ${jsonStore.put(storeName, itemPath, data)}
- ${jsonStore.upsert(orgName, storeName, itemPath, data)}
- ${jsonStore.upsert(storeName, itemPath, data)}

The data parameter must be a JSON-serializable Java Map object.

If the orgName parameter is omitted the current organization is used. The task uses the current process' organization name if the orgName parameter is omitted.

The upsert method creates the specified JSON store if it doesn't exist.

Example:

configuration:
  arguments:
    myItem:
      x: 123
      nested:
        value: "abc"

flows:
  default:
    # uses the current organization
    - "${jsonStore.put('myStore', 'anItem', myItem)}"

Retrieve an Item

Syntax:

- ${jsonStore.get(orgName, storeName, itemPath)}
- ${jsonStore.get(storeName, itemPath)}

The expression returns the specified item parsed into a Java object or null if no such item exists.

Example:

flows:
  default:
    - expr: "${jsonStore.get('myStore', 'anItem')}"
      out: anItem

    - if: "${anItem == null}"
      then:
        - log: "Can't find the item you asked for."
      else:
        - log: "${anItem}"

Remove an Item

Syntax:

- ${jsonStore.delete(orgName, storeName, itemPath)}
- ${jsonStore.delete(storeName, itemPath)}  

The expression returns true if the specified item was removed or false if it didn't exist.

Create or Update a Named Query

- ${jsonStore.upsertQuery(orgName, storeName, queryName, queryText)}
- ${jsonStore.upsertQuery(storeName, queryName, queryText)}

The task uses the current process' organization name if the orgName parameter is omitted.

Execute a Named Query

Syntax:

- ${jsonStore.executeQuery(storeName, queryName)}
- ${jsonStore.executeQuery(storeName, queryName, params)}
- ${jsonStore.executeQuery(orgName, storeName, queryName)}
- ${jsonStore.executeQuery(orgName, storeName, queryName, params)}

The expression returns a List of items where each item represents a row object returned by the query.

Query parameters (the params arguments) must be a Java Map object that can be represented with JSON.

You can also pass the parameters directly in the expression:

- "${jsonStore.executeQuery('myStore', 'lookupServiceByUser', {'users': ['mike']})}"

Example:

configuration:
  arguments:
    myQueryParams:
      users:
        - "mike"

flows:
  default:
    - expr: "${jsonStore.executeQuery('myStore', 'lookupServiceByUser', myQueryParams)}"
      out: myResults

    - log: "${myResults}"

(see also the example on the JSON Store page).