Generic Functions in QPR ProcessAnalyzer: Difference between revisions
Line 900: | Line 900: | ||
# query (string) | # query (string) | ||
|| | || | ||
Runs the given query to the given ODCB datasource | Runs the given query to the given ODCB datasource, and returns data as a DataFrame. [[PA_Configuration_database_table_in_QPR_ProcessAnalyzer|AllowExternalDatasources]] setting needs to be True to be able to use the ImportODBC function. Note also that the ODBC connection requires an ODBC driver specific to the datasource to be installed in the QPR ProcessAnalyzer Server computer. | ||
Examples: | Examples: | ||
<pre> | <pre> | ||
ImportOdbc("Driver={SQL Server};Server=localhost;DataBase=QPR_PA1;Trusted_Connection=yes", "SELECT * FROM OdbcTest") | ImportOdbc("Driver={SQL Server};Server=localhost;DataBase=QPR_PA1;Trusted_Connection=yes", "SELECT * FROM OdbcTest") | ||
Returns: The contents of OdbcTest table in given ODBC data source inside a DataFrame. | |||
</pre> | |||
|- | |||
||<span id="ImportOdbcSecure">ImportOdbcSecure</span> (DataFrame) | |||
|| | |||
# Project id (Integer) | |||
# connection string key (string) | |||
# query (string) | |||
|| | |||
Similar command as the ImportODBC, except instead of a plaintext connection string, a [[Secure Strings|secure string key]] is provided. Also a project id, from where to fetch the connection string key, needs to be provided. | |||
Examples: | |||
<pre> | |||
ImportOdbcSecure(12, "MySecureConnectionString", "SELECT * FROM OdbcTest") | |||
Returns: The contents of OdbcTest table in given ODBC data source inside a DataFrame. | Returns: The contents of OdbcTest table in given ODBC data source inside a DataFrame. | ||
</pre> | </pre> |
Revision as of 18:43, 15 March 2020
Aggregation Functions
There are following aggregation functions: Average, Count, Median, Min, Max and Sum. The aggregation operations work for numbers, DateTimes and TimeSpans, except Sum for DateTime is not possible.
Examples:
Sum([3, 2, 4]) Returns: 9 Count([[1, 2], [3, 4, 5]]) Returns: [2, 3] Sum([[1, 2], [3, 4, 5]]) Returns: [3, 12] Sum([]) Returns: null
When aggregating numerical values and there are null values, nulls are treated as zeros. When aggregating DateTimes and TimeSpans, and there are null values, error is given. In the Min and Max functions, nulls are ignored. Null values can be removed before aggregating (the following example shows how).
Average([1, 5, null]) Returns: 2 Average([1, 5, null].(_ ?? _remove)) Returns: 3
Aggregation operations are performed to the leaf level. i.e. the deepest level in the hierarchy. When aggregating, the leaf level arrays are replaced by the aggregated values, and thus the depth of the hierarchy decreases by one. In addition to the aggregation functions, functions that modify the contents of leaf arrays (OrderBy, Distinct, ...), the operation will be performed separately for every leaf array.
OrderByValue([[4, 3], [2, 1]]) Returns: [[3, 4], [1, 2]]
Mathematical functions
Function | Parameters | Description |
---|---|---|
Ceiling (Integer) |
|
Returns the smallest integer that is greater than or equal to the specified number. Example: Ceiling(1.3) Returns: 2 |
Floor (Integer) |
|
Returns the largest integer that is less than or equal to the specified number. Example: Floor(1.9) Returns: 1 |
Round (Float) |
|
For numbers, rounds the number to the specified number of decimal. Number of decimals can also be negative, and then the number is rounded to the nearest tens, hundreds, thousands, etc. For DateTimes, rounds given date time by given time span or given number of seconds. Note that the number/DateTime to be rounded needs to be provided as a context object (not as a parameter). Examples: (1.254).Round(1) Returns: 1.3 (162.111111).Round(-2) Returns: 200 DateTime(2017, 1, 2, 3, 4, 5).Round(10) Returns: DateTime(2017, 1, 2, 3, 4, 10) DateTime(2017, 1, 2, 3, 4, 5).Round(TimeSpan(1)) Returns: DateTime(2017, 1, 2) |
Set functions
Function | Parameters | Description |
---|---|---|
Distinct |
|
Modify given array by filtering out all duplicate values leaving only distinct values in the input array into the result. If given a hierarchical object, applies the function at the level that is one level up from the leaf level. Examples: Distinct([1]) Returns: [1] Distinct([1, 1]) Returns: [1] Distinct([1, 1, 2, 2]) Returns: [1, 2] Distinct([1, 1, 2, 2, "a", DateTime(2017), DateTime(2017), "b", DateTime(2016), "a"]) Returns: [1, 2, "a", DateTime(2017), "b", DateTime(2016)] |
Intersect |
|
Creates an intersection of multiple arrays. Returns a single array which contains an intersection of all the items in all the arrays given as parameter. If a parameter is not an array, it will be converted into an array having only the given element. Examples: Intersect([1, 2, "a", DateTime(2017), 5], ["a", 2, 3, DateTime(2017), 5], [DateTime(2017), "a", 2]) Returns: [2, "a", DateTime(2017)] |
Except |
|
Creates an substract given items from an array. Returns a single array which contains all the elements that were in the first array that were not in any of the subsequent arrays. If a parameter is not an array, it will be converted into an array having only the given element. Examples: Except([1, 2, "a", DateTime(2017), 5, "b", 6], ["a", 2, 3, DateTime(2017), 5], [DateTime(2017), "a", 2, 6]) Returns: [1, "b"] |
Union |
|
Creates an union of multiple arrays. Returns a single array which contains an union of all the items in all the arrays given as parameter. If a parameter is not an array, it will be converted into an array having only the given element. Examples: Union([1, 2, "a", DateTime(2017), 5], ["a", 2, 3, DateTime(2017), 5], [DateTime(2017), "a", 2, "b"]) Returns: [1, 2, "a", DateTime(2017), 5, 3, "b"] |
Ordering functions
Function | Parameters | Description |
---|---|---|
OrderBy (array) |
|
Orders the given array using values from the given order expression. The order expression is evaluated once for each item in the array. The order expression supports all atomic (=not collection) primitive value types. Examples: OrderBy(["a", "x", "b", "z", "n", "l", "a"], _) Return: ["a", "a", "b", "l", "n", "x", "z"] OrderBy([9,8,7,6,5,4,3,2,1], _%3) Returns: [9,6,3,7,4,1,8,5,2] OrderBy([9,8,7,6,5,4,3,2,1], _%3 + _/30) Returns: [3,6,9,1,4,7,2,5,8] |
OrderByDescending (array) |
|
Result is same as in the OrderBy function, except the order is reverse. |
OrderByTop (array) |
|
Orders given top-level array by the value of given expression using ascending order. Supports all value types, including multi-dimensional arrays. Order expression is evaluated in the context of each array item whose value determines the order of that item. Examples: OrderByTop([[1, 2, 3], [2, 2, 2], [3, 2, 1]], _[2]) Returns: [[3, 2, 1], [2, 2, 2], [1, 2, 3]] |
OrderByValue (array) |
|
Orders the given array using the natural order of items, for example numbers it's the increasing order, and for strings it's text ordering. OrderByValue(["a", "x", "b", "z", "n", "l", "a"]) Return: ["a", "a", "b", "l", "n", "x", "z"] |
OrderByValueDescending (array) |
|
Result is same as in the OrderByValue function, except the order is reverse. |
Looping functions
Function | Parameters | Description |
---|---|---|
For |
|
Iterates the given expression until the given condition is met, and returns the results of the iterated expressions for every iteration as an array. Examples: For("i", 0, i < 4, i + 1, i) Returns: [0, 1, 2, 3] For("x", 0, x < 3, x + 1, For("y", 0, y < 3, y + 1, StringJoin(",", [x, y])) Returns: [["0,0", "0,1", "0,2"], ["1,0", "1,1", "1,2"], ["2,0", "2,1", "2,2"]] For("i", 0, i < 4, i + 1, DateTime(2010 + i)) Returns: [DateTime(2010), DateTime(2011), DateTime(2012), DateTime(2013)] For("str", "a", str != "aaaaa", str + "a", str) Returns: ["a", "aa", "aaa", "aaaa"] |
ForEach |
|
Repeats the given expression as many times there are items in the given array. Item in the array is available as the given variable in the expression. Examples: ForEach("i", [1,2,3], "Value is: " + i) Returns: Value is: 1 Value is: 2 Value is: 3 ForEach("item", EventLogById(1).Cases, Let("c" + item.Name, item)) Results: Creates expression variable variables like "c<casename>" for every case in the model. ForEach("myVariable", ["a", "b", "c"], myVariable + myVariable) Returns: aa bb cc |
NumberRange |
|
Creates an array of numbers within given range with the given interval. Interval parameter is optional, and by default it is one. Examples: NumberRange(1, 3) Returns: [1, 2, 3] NumberRange(1, 3, 0.5) Returns: [1, 1.5, 2, 2.5, 3] NumberRange(1, 3, 0.8) Returns: [1, 1.8, 2.6] |
Repeat |
|
Repeats the defined expression the defined number of times. Examples: Repeat(3, "Repeat me!") Returns: "Repeat me!" "Repeat me!" "Repeat me!" Repeat(1, 5) Returns 5 |
TimeRange |
|
Generates a timestamp array starting from the start timestamp with the defined interval, and ending when the end timestamp is reached. Note that this function only creates timestamps with equal durations, so it's not possible to e.g. create timestamps for each month (to do that, you can use the loops). Generate datetimes starting from Monday 2017-01-01 and ending to Monday 2017-12-31 including all Mondays between them: Timerange(Datetime(2018,1,1), Datetime(2018,1,1), Timespan(7)) |
Recursion functions
Function | Parameters | Description |
---|---|---|
Recurse |
|
Evaluates the given expression recursively until given condition or recursion depth is met. The function returns all the traversed objects in a single array. When the stop condition expression evaluates to false, it will stop the current recursion without including the false evaluated object into the result. Default stop condition is !IsNull(_). The default maximum depth is 1000. Examples: (1).Recurse(_ + 1, _ < 5) Returns: [1, 2, 3, 4] event.Recurse(NextInCase) Returns: An array of all the events following given event inside the same case. event.Recurse(NextInCase, Type.Name != "Invoice") Returns: An array of all the events following given event inside the same case until event whose type name is "Invoice", which will itself not be included into the result. event.Recurse(NextInCase, Type.Name != "Invoice", 2) Returns: An array of all the events following given event inside the same case until event whose type name is "Invoice" or until the recursion depth of 2 has been reached, which will itself not be included into the result. |
RecurseWithHierarchy |
|
Evaluates the given expression recursively until given condition or recursion depth is met. The function returns the traversed object hierarchy. When the stop condition expression evaluates to false, it will stop the current recursion without including the false evaluated object into the result. Default stop condition is !IsNull(_). The default maximum depth is 1000. Examples: [1,2].RecurseWithHierarchy([1,2], false, 2) Returns: [1:[1:[1,2],2:[1,2]],2:[1:[1,2], 2:[1,2]]] (1).RecurseWithHierarchy(_ + 1, _ < 5) Returns: 1:[2:[3:[4]]] RemoveLeaves(eventLog.Flows:From.Where(IsNull(_))).To.RecurseWithHierarchy(OutgoingFlows.To, !IsNull(_), 2) Returns: A hierarchy consisting of all the starter events of given event log and recursively all the event types reachable from them via flows until depth of 2 is reached. |
RecursiveFind |
|
Evaluates given expression recursively until given condition or recursion depth is met. The function collects all the traversed objects that match the given find expression along the way. When the find condition expression evaluates to true for the current object, it causes the following:
When the stop condition expression evaluates to false, it will stop the current recursion without including the false evaluated object into the result. Default stop condition is !IsNull(_). The default maximum depth is 1000. Continue after finding tells should the recursion be continued after a match has been found in the current branch. Examples: (1).RecursiveFind(_ + 1, _ == 100) Returns: 100 eventLog.Cases:GetAt(0, Events).RecursiveFind(NextInCase, Organization=="Finance", !IsNull(_)) Returns: For each case, returns the first (by time) event whose organization equals to "Finance". eventLog.Cases:Events.Where(Organization=="Finance") eventLog.Cases:GetAt(0, Events).RecursiveFind(NextInCase, Organization=="Finance", true, true) Returns: Both return for each case all events whose organization equals to "Finance". |
Variable handling functions
Function | Parameters | Description |
---|---|---|
Def |
|
Creates a new user defined function. Parameters starting from the second, are the parameters that user gives when calling the function. The last parameter is the expression to evaluate when the function is called. In that definition expression the named parameters are used. Instead of the Def function, a recommended way to define functions is the lambda syntax. Examples: Def("Inc", "a", a + 1); Inc(2); Returns: 3 Def("Add", "a", "b", a + b); [1, 2, 3].Add(_, 2); Returns: [3, 4, 5] Def("AddSelf", "b", _ + b); [1, 2, 3].AddSelf(2); Returns: [3, 4, 5] Def("Fib", "a", If(a < 2, 1, Fib(a - 1) + Fib(a - 2))); Fib(10); Returns: 89 |
Let |
|
Defines a user defined variable to the scope where the Let function is located. Note that the function name needs to starts with a capital letter, because otherwise it's interpreted as a let operator. Examples: Let("var1", "Orange"); "Value is " + var1; Returns: Value is Orange |
Set |
|
Sets a value for an existing user defined variable. The variable to set must have been created previously in some visible scope. Instead of the Set function, a recommended way to set variables, is the assignment operator. |
Variable |
|
Function to get a variable value. The function is needed when there are spaces in a variable name, because that variable cannot be referenced otherwise in the expressions. |
JSON functions
Function | Parameters | Description |
---|---|---|
ParseJson | jsonData (String) |
1. Converts given JSON string into an object. 1.1. Uses https://docs.microsoft.com/en-us/dotnet/api/system.web.script.serialization.javascriptserializer.deserialize?view=netframework-4.7.2 for de-serialization of the object. JSON objects will be represented as StringDictionary objects in the expression language. Examples: ParseJson("{\"a\": 1, \"b\": 2}").Get("b") Returns: 2 Sum(ParseJson("[1, 2, 3, 4]")) Returns: 10 ToJson(ParseJson("{\"a\": 1, \"b\": 2}")) Returns: {"a":1,"b":2} |
ToJson | Object |
Converts given object into JSON. Uses https://docs.microsoft.com/en-us/dotnet/api/system.web.script.serialization.javascriptserializer.serialize?view=netframework-4.7.2 for serialization of the object. It is recommended that hierarchical arrays (#29290#) and objects (#29286#) are first converted to dictionaries (#48320#) before converting to JSON since JSON does not have exactly identical construct and thus converting JSON back to expression object will not result object similar to the original. Examples: ToJson(ParseJson("{\"a\": 1, \"b\": 2}")) Returns: {"a":1,"b":2} ToJson(ToDictionary().Set("a", 1, "b", 2)) Returns: {"a":1,"b":2} ToJson([1,[[2,ToDictionary().Set("a", 1)],4]]) Returns: [1,[[2,{"a":1}],4]] ToJson(null) Returns: null ToJson(_empty) Returns: {} ToJson(["a": 1, "b": 2]) Returns: [{"Root":"a","Array":[1]},{"Root":"b","Array":[2]}] |
Hierachical object functions
Function | Parameters | Description |
---|---|---|
FindRepeats |
|
Searches for repeating patterns in given array. Parameters:
Returns an array of arrays indicating the repeating patterns and their positions in the array formatted as follows:
Examples: FindRepeats([0, 1, 2, 0, 1, 2]) Returns: [ [[0, 1, 2], [0, 3]], [[0, 1], [0, 3]], [[1, 2], [1, 4]], [[0], [0, 3]], [[1], [1, 4]], [[2], [2, 5]] ] FindRepeats([0, 1, 2, 0, 1, 2], 0, true) Returns: [[[0, 1, 2], [0, 3]]] FindRepeats([1, "b", DateTime(2017), 1, "b", DateTime(2017)], 3) Returns: [[1, "b", DateTime(2017)], [0, 3]] |
Flatten |
|
Collects all the actual leaf values from given array, array of arrays or hierarchical object and returns them in a single array. If given a hierarchical object, this function collects actual leaf values instead of leaf level values. Elements in the returned array are in the same order they were found when traversing the input object using depth first search. When context object is included, should context objects in the internal nodes of a hierarchical object be also included into the result. Default is false. Examples: Flatten(1) Returns: 1 Flatten([1, 2]) Returns: [1,2] Flatten([[[1, 2],[3, 4]],[[5, 6]]]) Returns: [1, 2, 3, 4, 5, 6] Flatten([[1, 2], 3]) Returns: [1, 2, 3] Flatten([[1,2,3,4], null, [5], [1, null]]) Returns: [1, 2, 3, 4, null, 5, 1, null] Flatten(["a":1, "b":2]) Flatten(["a":1, "b":2], false) Returns: [1, 2] Flatten(["a":1, "b":2], true) Returns: ["a", 1, "b", 2] |
RemoveLeaves |
|
Remove one level of hierarchy from a hierarchical object replacing all the bottom level hierarchical arrays with the context objects of the hierarchical arrays. Returns the given object with all the bottom level hierarchical arrays with the context objects of the hierarchical arrays. Examples: RemoveLeaves(["foo":1, "bar":2]) Returns: ["foo", "bar"] RemoveLeaves(eventLog.Flows:From.Where(IsNull(_))) Results: All the flows starting the cases in the event log. |
ReplaceLeafValues |
|
Replace all leaf values of given array or hierarchical object at given levels up from the leaf level with results of given expression. Examples: ReplaceLeafValues([1,2, null], "x", If(IsNull(x), null, x+1), 0) Result: [2, 4, null] ReplaceLeafValues([[[1,2],[2,3]],[[3,4],[4,5]]], "x", Flatten(x), 0) Result: [[[[1],[2]],[[2],[3]]],[[[3],[4]],[[4],[5]]]] ReplaceLeafValues([[[1,2],[2,3]],[[3,4],[4,5]]], "x", Flatten(x), 1) Result: [[[1,2],[2,3]],[[3,4],[4,5]]] ReplaceLeafValues([[[1,2],[2,3]],[[3,4],[4,5]]], "x", Flatten(x), 2) Result: [[1,2,2,3],[3,4,4,5]] ReplaceLeafValues([[[1,2],[2,3]],[[3,4],[4,5]]], "x", Flatten(x), 3) Result: [1,2,2,3,3,4,4,5] |
SliceMiddle |
|
Extracts a continuous range of an array or hierarchical object. If given a hierarchical object, applies the function at the level that is specified levels level up from the leaf level. Start index: Negative value means that the index is counting from the end of the array. If array does not have element at this given index, empty array is returned. End index: not included into the extracted range. Negative value means that the index is counting from the end of the array. If array does not have element at this given index, all the elements to the end from the start index will be extracted. Levels up: At which level of the hierarchical object are we operating (number of levels up from the leaf level). Should be at least 1 (since 0 level does not contain arrays). Examples: SliceMiddle(1, 2, 1, [[0, 1, 2, 3], [4, 5, 6, 7]]) Returns: [[1], [5]] SliceMiddle(2, 4, 1, [[0, 1, 2, 3], [4, 5, 6, 7]]) Returns: [[2, 3], [6, 7]] SliceMiddle(0, 1, 2, [[0, 1, 2, 3], [4, 5, 6, 7]]) Returns: [0, 1, 2, 3] SliceMiddle(3, 5, 1, [0, 1, 2, 3, 4, 5, 6, 7]) Returns: [3, 4] SliceMiddle(-3, -1, 1, [0, 1, 2, 3, 4, 5, 6, 7]) Returns: [5, 6] SliceMiddle(3, -1, 1, [0, 1, 2, 3, 4, 5, 6, 7]) Returns: [3, 4, 5, 6] |
Other functions
Function | Parameters | Description |
---|---|---|
Analysis (DataFrame) |
|
Runs the given type of analysis and returns the results as a DataFrame. If an EventLog is available in the current context, the analysis is run for that EventLog. The analysis type can be given as a string (e.g. "Cases") or numeric (e.g. 5). Additional parameters are defined as a key-value pair collection. Examples: Analysis("OperationLog") Returns: Filter report analysis EventLogById(1).Analysis(5) Returns: Analysis 5 (Cases) for event log having id 1. EventLogById(1).Analysis("Cases") Returns: Analysis 5 (Cases) for event log having id 1. Analysis(25, ["ScriptId": 123, "SelectedAnalysisResult": "MyResult", "parameter1": "value1", "parameter2": "value2"]) Returns: Run a script which id is 123 using the provided parameters. (Remember to use "SheetName"="MyResult" parameter for the shown result query.) EventLogById(1).Analysis(14, ["MaximumCount": 30, "SelectedAttributeType": "Region"]) Returns: Analysis 14 (Root causes) for event log having id 1. |
AsParallel |
|
Performs the next chaining operation in parallel to improve performance. Items are divided into parts which size is determined by the ParallelTaskSize parameter, and each part is executed as an independent task in parallel. Parallel execution has a certain cost, so it might not be optimal to run each item as a separate task (increase ParallelTaskSize to decrease number of tasks). On the other hand, to large ParallelTaskSize leads to too few parallel tasks, and then all processing capacity is not used. As a parameter, takes a dictionary that accepts optional property ParallelTaskSize, which is the size of the segments the root array will be split into. If the length of the input array is not divisible by ParallelTaskSize, the last segment will have less items than this configured value. The default size is 1. Returns the original root object. Examples: Sum(Sum(([NumberRange(1, 100)].AsParallel(["ParallelTaskSize": 1]).For("i", 0, i < 100000, i + 1, i))[0])) Returns: 499995000000 The same expression without parallel processing: Sum(Sum(NumberRange(1, 100).For("i", 0, i < 100000, i + 1, i))) Returns: 499995000000 Sum([NumberRange(1, 100)].AsParallel(["ParallelTaskSize": 1]).WriteLog(_)) Returns: 5050 In addition, outputs all the numbers from 1 to 100 into log file in the order in which the tasks were executed. Count((([el.Cases].AsParallel(["ParallelTaskSize": 1000]):AnalyzeConformance(cm))[0]).Where(_==null)) Returns the number of cases conforming to a design/conformance model cm. The same expression without parallel processing: Count((el.Cases:AnalyzeConformance(cm)).Where(_==null)) |
Catch |
|
Calculates the given expression and if any exceptions are thrown during the calculation, catches that exception and returns the given result. Note that this function does not catch any syntactical errors. Examples: Catch(1, 1234) Returns: 1 Catch(undefined, 1234) Returns: 1234 Catch([1,2].undefined, 1234) Returns: 1234 Catch(EventLogById(-1), 1234) Returns: 1234 |
Coalesce |
|
Returns the second parameter if the first parameter evaluates to null or empty. If given a hierarchical object, applies the function at the leaf level. If the the given object is a hierarchical object, all its leaf level values are coalesced separately. Examples: Coalesce(0, 1) Returns: 0 Coalesce(null, 1) Coalesce(_empty, 1) Coalesce(_remove, 1) All return: 1 Coalesce([[null, 1], [null, null]], 3) Returns: [[3, 1], [3, 3]] Coalesce([[null, 1], 2], 3) Returns: [[3, 1], null] Coalesce([1, [null, 2], null], 3) Returns: [1, [null, 2], 3] |
DataTableById |
|
Gets a DataTable by the given Datatable id. An exception is given if a DataTable with the given id is not found. Examples: DataTableById(27) Returns: DataTable for the data table having id 27. |
DesignModelFromXml |
|
Creates new (DesignModel object) from BPMN 2.0 XML document provided as a string. (BPMN 2.0 specification: https://www.omg.org/spec/BPMN/). In the BPMN 2.0 XML file, the http://www.omg.org/spec/BPMN/20100524/DI section is not used by the function, and thus it can be omitted to reduce transferred data. Note that the quotation marks need to be escaped if the BPMN 2.0 XML is provided as a literal in the expression. Example: Let("myConformanceModel", DesignModelFromXml(" <?xml version=\"1.0\" encoding=\"UTF-8\"?> <bpmn:definitions xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:bpmn=\"http://www.omg.org/spec/BPMN/20100524/MODEL\" xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\"> <bpmn:process id=\"Process_1\" isExecutable=\"false\"> <bpmn:startEvent id=\"StartEvent_1\" /> <bpmn:task id=\"Task_0y5w837\" name=\"abc\"> <bpmn:outgoing>SequenceFlow_10mpkws</bpmn:outgoing> </bpmn:task> <bpmn:task id=\"Task_0c16r07\" name=\"def\"> <bpmn:incoming>SequenceFlow_10mpkws</bpmn:incoming> </bpmn:task> <bpmn:sequenceFlow id=\"SequenceFlow_10mpkws\" sourceRef=\"Task_0y5w837\" targetRef=\"Task_0c16r07\" /> </bpmn:process> <bpmndi:BPMNDiagram id=\"BPMNDiagram_1\"> ... </bpmndi:BPMNDiagram> </bpmn:definitions> ")) |
EventLogById |
|
Returns EventLog object corresponding to the provided filter Id. |
GarbageCollection | Calling this function performs a garbage collection in the QPR ProcessAnalyzer Server. The function returns the maximum generation before the garbage collection was run. This function is an experimental functionality, which purpose is to investigate the memory consumption and memory handling behavior of the QPR ProcessAnalyzer Server. | |
GetContext |
|
Returns the context of given hierarchical array, i.e. list of keys in the object. If the given object is not an hierarchical array, returns null. Examples: GetContext("a":1) Returns: "a" ["a":1, "b":2, 2:3].GetContext(_) Returns: ["a", "b", 2] ([1,2,3]:(_*2)).GetContext(_) Returns: [1, 2, 3] ["a":1, 2, 3].GetContext(_) Returns: ["a", null, null] |
GetValueOfContext |
|
Returns the value of specified context object in given hierarchical array, i.e. the value behind the key. If the key if found multiple times, the first occurrence is returned. Returns _empty if the given key was not found. Examples: GetValueOfContext("bar", ["foo":1, "bar":2]) Returns: [2] GetValueOfContext("bar", ["foo":1, "bar":2, "bar":"second"]) Returns: [2] GetValueOfContext("test", ["foo":1, "bar":2]) Returns: _empty |
ImportOdbc (DataFrame) |
|
Runs the given query to the given ODCB datasource, and returns data as a DataFrame. AllowExternalDatasources setting needs to be True to be able to use the ImportODBC function. Note also that the ODBC connection requires an ODBC driver specific to the datasource to be installed in the QPR ProcessAnalyzer Server computer. Examples: ImportOdbc("Driver={SQL Server};Server=localhost;DataBase=QPR_PA1;Trusted_Connection=yes", "SELECT * FROM OdbcTest") Returns: The contents of OdbcTest table in given ODBC data source inside a DataFrame. |
ImportOdbcSecure (DataFrame) |
|
Similar command as the ImportODBC, except instead of a plaintext connection string, a secure string key is provided. Also a project id, from where to fetch the connection string key, needs to be provided. Examples: ImportOdbcSecure(12, "MySecureConnectionString", "SELECT * FROM OdbcTest") Returns: The contents of OdbcTest table in given ODBC data source inside a DataFrame. |
ModelById |
|
Returns Model object corresponding to the provided model Id. |
GroupBy |
|
Groups given array by given expressions. Returns the given array or hierarchical object parameter split into groups in a way that each specified group expression creates one level of hierarchical arrays having the root object the same as the result of the evaluation of the grouping expression. Examples: GroupBy([1,2,2,3,3,4,5,5,4,4,4], _) Returns: [[1:[1], 2:[2, 2], 3:[3, 3], 4:[4, 4, 4, 4], 5:[5,5]] |
GroupByValue | * Array or hierarchical object to group |
Groups all unique values in given array or hierarchical object. Returns the given array or hierarchical object in a format which has all the values in the original array only once as root objects and the root objects in the original array as contents of the arrays inside contexts. In a way, this just switches root objects of hierarchical arrays to be the actual values and actual values to be root objects (without duplicates). For every item in the array, the behavior is as follows:
Examples: GroupByValue([1,2,2,3,3,4,5,5,4,4,4]) Returns: (The same as GroupBy([1,2,2,3,3,4,5,5,4,4,4], _)) [1:[1], 2:[2, 2], 3:[3, 3], 4:[4, 4, 4, 4], 5:[5,5]] GroupByValue([1:["a","b"],2:["b","c"],3:["c"],4:["d","e"],5:["d","d","d"]]) Returns: ["a":[1], "b":[1, 2], "c":[2, 3], "d":[4, 5, 5, 5], "e":[4]] Get count of item "2" in the array: Let(\"groupped\", GroupByValue([1,2,4,1,4,2,3,3,2,4])); Count(GetValueOfContext(2, groupped)) Returns: 3 |
If |
|
Evaluates the condition expression (the first parameter) and if true, returns the value of the second parameter. Otherwise returns the value of the third parameter. Always evaluates only either the second or the third parameter, but never both. Note that the If function needs to starts with a capital letter, because otherwise it's interpreted as an if operator. Examples: If(Now.Second % 2 == 0, "Even second", "Odd second") Returns: "Event second" or "Odd second" depending on the time of the evaluation. For("i", 0, i < 10, i + 1, i).If(_ % 2 == 0, _, _remove) Returns: [0, 2, 4, 6, 8] |
IsNull (Boolean) |
|
Tests whether given object is null, _empty or _remove. Returns true if it is any of those. If given a hierarchical object, applies the function as described in at the leaf level. Examples: ForEach("item", [1, "a", null, _empty, _remove], IsNull(item)) Returns: [false, false, true, true, true] IsNull(["foo":[null,"a"], "bar":[2,null]]) Returns: [ HierarchicalArray("foo", [true, false]), HierarchicalArray("bar", [false, true]) ] |
IsNullTop (Boolean) |
|
Tests whether given object is null, _empty or _remove. Returns true if it is any of those. The function does not aggregate values in hierarchical objects. Examples: ForEach("item", [1, "a", null, _empty, _remove], IsNullTop(item)) Returns: [false, false, true, true, true] IsNullTop(["foo":[null,"a"], "bar":[2,null]]) Returns: false |
ToFloat (Number) |
|
Converts given object to a number (of Double type). |
ToInteger (Integer) |
|
Converts given object to an integer. Internally uses .NET Convert.ToInt64 -function with invariant culture. See https://msdn.microsoft.com/en-us/library/system.convert.toint64(v=vs.110).aspx for more information. If the object can not be converted into an integer, an exception will be thrown. Examples: ToInteger(1.234) Returns: 1 ToInteger(-1.5) Returns: -2 ToInteger(1313.6) Returns: 1314 ToInteger(123456789012345678) Returns: 123456789012345678 ToInteger("5") Returns: 5 ToInteger("-5") Returns: -5 |
ToString (String) |
|
Converts given object to a string object representation optimized for debugging purposes. Internally uses .NET Convert.ToString -function with invariant culture for non-array objects. See https://msdn.microsoft.com/en-us/library/system.convert.tostring(v=vs.110).aspx for more information. Examples: ToString(1) + " < " + ToString(2) Returns: "1 < 2". "Case=\'" + ToString(a) + "\'" Returns: "Case='<string representation of object a>'" ToString(DateTime(2017,1,2,3,4,5,6)) Returns: "2017-01-02T03:04:05" |
Transpose |
|
Transposes the given matrix. Examples: Transpose([[1,2], [3,4], [1,4]]) Returns: [[1, 3, 1], [2, 4, 4]] |
Where |
|
Returns the context object if the given expression evaluates to true. Otherwise returns the second parameter. The second parameter is optional and it's by default EMPTY. Examples: [1,2,3,4].Where(_>2) Returns: [3,4] [1,2,3,4].Where(_>2, _+100) Returns: [101, 102, 3,4] [1,2,3].[_,_+1] Returns: [[1, 2], [2, 3], [3, 4]] [1,2,3].[_,_+1].Where(_>=3) Returns: [[], [3], [3, 4]] [1,2,3].[_,_+1].Where(_>=3, _remove) Returns: [[3], [3, 4]] |
WriteLog |
|
Writes given text into QPR ProcessAnalyzer log file. The return value of the function is the provided message parameter. Examples: WriteLog("Calculation executed.") Writes to log: Calculation executed. Sum(WriteLog([1, 2, 3, 4])) Returns: 10 Also writes an entry into the log showing the [1, 2, 3, 4] -array in the pretty printed fashion. NumberRange(0, 4).(WriteLog("Iteration #" + (_ + 1)), _) Returns: [0, 1, 2, 3, 4] Also writes the following entries into log: Iteration #1 Iteration #2 Iteration #3 Iteration #4 Iteration #5 |