Sidebar
0 votes
1.2K views
by brandon-w-8204 (34.2k points)

3 Answers

0 votes

Parameter maps are objects that store key-value pairs.

Example

In QIE we use them most commonly to combine like items. (OBX-5 values for  like segments)

Below is a list of basic commands:

// Create parameterMap
var parameterMap = qie.newParameterMap();
 
//Add or update a value in a parameter map
parameterMap.put('key', 'value');
 
//Get a value from a parameter map
parameterMap.get('key');
 
//Check if a value is in the paramter map
if (parameterMap.get('key') === null) {
   //value is not in parameterMap
   qie.debug('do something if the value is not in the map');
} else {
   //value is in parameterMap
   qie.debug('do something if the value is in the map');
}
by brandon-w-8204 (34.2k points)
edited by terrie-g-7436
0 votes

Just as an example here is a sample JSON message that I will use to create a parameter map and then debug the parameter map keys and values.

Sample JSON:

{
  "attachments": [
    {
      "id": "111",
      "myDoc": "My first document"
    },
    {
      "id": "222",
      "myDoc": "My second document"
    },
    {
      "id": "333",
      "myDoc": "My third document"
    }
  ]
}

Sample Mapping Function:

// Initialize your map
var attachments = qie.newParameterMap();

var docId, myDoc;
// Add keys and values to your map
for (var i=1 ; i <= message.getCount('/attachments') ; i++) {
   docId = message.getNode('/attachments/['+i+']/id');
   myDoc = message.getNode('/attachments/['+i+']/myDoc');
   attachments.put(docId, myDoc);
}

qie.debug('attachments.size(): ' + attachments.size());

// Pull the data we just added back out from your map
var iterator = attachments.keySet().iterator();
while (iterator.hasNext()) {
   var docIdKey = iterator.next();
   qie.debug('docIdKey: ' + docIdKey);

   var myDocValue = attachments.get(docIdKey);
   qie.debug('myDocValue: ' + myDocValue);
}

by michael-h-5027 (14.8k points)
0 votes

ParameterMaps, channelCache, and messageCache in QIE are all key-value variables that let you store and retrieve data using a unique key name. The main difference between them is scope and syntax. channelCache stores values shared across the entire channel and is accessible throughout the interface; messageCache stores data specific values for a single message as it moves through the channel; and parameterMaps typically hold named key-value values within a given script or step. While channelCache and messageCache use function-style access like getValue(key) and setValue(key, value), parameterMaps use Java-style methods such as get(key) and put(key, value). Despite the differences in how they're accessed, all three are used to temporarily manage data in the form of key-value pairs during interface execution.

For a list a parameterMap Methods see Java Docs HashMap methods: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/HashMap.html?utm_source=chatgpt.com

Here is a table listing the popular HashMap (parameterMap) methods along with the QIE channelCache and messageCache functions.

OperationparameterMaps (Methods)channelCache & messageCache (Functions)
Check if key existsmap.containsKey("key")channelCache.checkValueExists("key")
messageCache.checkValueExists("key")
Get valuemap.get("key")channelCache.getValue("key")
messageCache.getValue("key")
Set valuemap.put("key", "value")channelCache.setValue("key", "value")
messageCache.setValue("key", "value")
Remove valuemap.remove("key")channelCache.removeValue("key")
Get as boolean(Use cast or comparison logic)channelCache.getBoolean("key", defaultValue)
Get as numberNumber(map.get("key"))channelCache.getNumber("key", defaultValue)
Get as dateUse map.get then parse with QIE date functionschannelCache.getDate("key", defaultValue)
Iterate over keysmap.keySet().toArray()
Get sizemap.size()
Clear all entriesmap.clear()
Contains a Keymap.containsKey(Object key)
Contains a Valuemap.containsValue(Object value)
Remove All entriesmap.clear()
Returns all key entriesmap.keySet()
Returns all Value entriesmap.valueSet()
Returns all keys and entriesmap.entrySet()

ago by gary-t-8719 (15.2k points)
edited ago by gary-t-8719
...