Gaffer icon indicating copy to clipboard operation
Gaffer copied to clipboard

Allow variables to be used in Operation Chains

Open p013570 opened this issue 5 years ago • 3 comments

For example:

{
    "class": "GetElements",
    "input": "${input}",
    "view": {
        "edge1": {
           "preAggregationFilterFunctions": [{
            "selection": "count",
            "predicate": {
                 "class": "IsMoreThan",
                 "value": "${threshold}"
            }
           }]
         }
    }
}

This is tricky as it cannot deserialise into Java until the variable has been resolved. We may need to use a similar mechanism to how we do it in NamedOperations, where we store the OperationChain in json and resolve the variables before deserialising the operation.

p013570 avatar Sep 12 '18 11:09 p013570

Depends on #1860.

p013570 avatar Sep 12 '18 12:09 p013570

This is currently at a stage where parameters need to be reviewed/reworked for this to work. It will work now in certain cases but not all can be guaranteed. The issue with deserialising unresolved parameters still stands. We have the option of leaving this as is and giving users the ability to use variables within a json opChain, or waiting for a fix for using the variables within the Java.

m55624 avatar Nov 14 '18 16:11 m55624

Another use case for this has been identified for reducing duplication in Operation chains. A simple example is where an different value should be used within the chain based on true or false. At the moment this requires a duplication of the operations across the true and false branches, with the values hardcoded. With variable substitution, there would be no need for duplication in the chain or hardcoding.

GCHQDeveloper314 avatar Jul 20 '23 16:07 GCHQDeveloper314