Java Code Examples for org.apache.nifi.expression.ExpressionLanguageScope#VARIABLE_REGISTRY

The following examples show how to use org.apache.nifi.expression.ExpressionLanguageScope#VARIABLE_REGISTRY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockPropertyValue.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public PropertyValue evaluateAttributeExpressions(final FlowFile flowFile) throws ProcessException {
    /*
     * The reason for this null check is that somewhere in the test API, it automatically assumes that a null FlowFile
     * should be treated as though it were evaluated with the VARIABLE_REGISTRY scope instead of the flowfile scope. When NiFi
     * is running, it doesn't care when it's evaluating EL against a null flowfile. However, the testing framework currently
     * raises an error which makes it not mimick real world behavior.
     */
    if (flowFile == null && expressionLanguageScope == ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) {
        return evaluateAttributeExpressions(new HashMap<>());
    } else if (flowFile == null && expressionLanguageScope == ExpressionLanguageScope.VARIABLE_REGISTRY) {
        return evaluateAttributeExpressions(); //Added this to get around a similar edge case where the a null flowfile is passed
                                                //and the scope is to the registry
    }

    return evaluateAttributeExpressions(flowFile, null, null);
}
 
Example 2
Source File: StatelessPropertyValue.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public PropertyValue evaluateAttributeExpressions(final FlowFile flowFile) throws ProcessException {
    /*
     * The reason for this null check is that somewhere in the test API, it automatically assumes that a null FlowFile
     * should be treated as though it were evaluated with the VARIABLE_REGISTRY scope instead of the flowfile scope. When NiFi
     * is running, it doesn't care when it's evaluating EL against a null flowfile. However, the testing framework currently
     * raises an error which makes it not mimick real world behavior.
     */
    if (flowFile == null && expressionLanguageScope == ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) {
        return evaluateAttributeExpressions(new HashMap<>());
    } else if (flowFile == null && expressionLanguageScope == ExpressionLanguageScope.VARIABLE_REGISTRY) {
        return evaluateAttributeExpressions(); //Added this to get around a similar edge case where the a null flowfile is passed
        //and the scope is to the registry
    }

    return evaluateAttributeExpressions(flowFile, null, null);
}