@EventDriven @SideEffectFree @SupportsBatching @Tags(value={"JSON","evaluate","JsonPath"}) @InputRequirement(value=INPUT_REQUIRED) @CapabilityDescription(value="Evaluates one or more JsonPath expressions against the content of a FlowFile. The results of those expressions are assigned to FlowFile Attributes or are written to the content of the FlowFile itself, depending on configuration of the Processor. JsonPaths are entered by adding user-defined properties; the name of the property maps to the Attribute Name into which the result will be placed (if the Destination is flowfile-attribute; otherwise, the property name is ignored). The value of the property must be a valid JsonPath expression. A Return Type of \'auto-detect\' will make a determination based off the configured destination. When \'Destination\' is set to \'flowfile-attribute,\' a return type of \'scalar\' will be used. When \'Destination\' is set to \'flowfile-content,\' a return type of \'JSON\' will be used.If the JsonPath evaluates to a JSON array or JSON object and the Return Type is set to \'scalar\' the FlowFile will be unmodified and will be routed to failure. A Return Type of JSON can return scalar values if the provided JsonPath evaluates to the specified value and will be routed as a match.If Destination is \'flowfile-content\' and the JsonPath does not evaluate to a defined path, the FlowFile will be routed to \'unmatched\' without having its contents modified. If Destination is flowfile-attribute and the expression matches nothing, attributes will be created with empty strings as the value, and the FlowFile will always be routed to \'matched.\'") @DynamicProperty(name="A FlowFile attribute(if <Destination> is set to \'flowfile-attribute\')", value="A JsonPath expression", description="If <Destination>=\'flowfile-attribute\' then that FlowFile attribute will be set to any JSON objects that match the JsonPath. If <Destination>=\'flowfile-content\' then the FlowFile content will be updated to any JSON objects that match the JsonPath.") public class EvaluateJsonPath extends AbstractJsonPathProcessor
AbstractJsonPathProcessor.JsonPathValidator
Modifier and Type | Field and Description |
---|---|
private Queue<Set<Map.Entry<String,com.jayway.jsonpath.JsonPath>>> |
attributeToJsonPathEntrySetQueue |
private ConcurrentMap<String,com.jayway.jsonpath.JsonPath> |
cachedJsonPathMap |
static PropertyDescriptor |
DESTINATION |
static String |
DESTINATION_ATTRIBUTE |
static String |
DESTINATION_CONTENT |
private boolean |
destinationIsAttribute |
private String |
nullDefaultValue |
static PropertyDescriptor |
PATH_NOT_FOUND |
static String |
PATH_NOT_FOUND_IGNORE |
static String |
PATH_NOT_FOUND_WARN |
private String |
pathNotFound |
private List<PropertyDescriptor> |
properties |
static Relationship |
REL_FAILURE |
static Relationship |
REL_MATCH |
static Relationship |
REL_NO_MATCH |
private Set<Relationship> |
relationships |
private String |
representationOption |
static PropertyDescriptor |
RETURN_TYPE |
static String |
RETURN_TYPE_AUTO |
static String |
RETURN_TYPE_JSON |
static String |
RETURN_TYPE_SCALAR |
private String |
returnType |
EMPTY_STRING_OPTION, NULL_REPRESENTATION_MAP, NULL_STRING_OPTION, NULL_VALUE_DEFAULT_REPRESENTATION
Constructor and Description |
---|
EvaluateJsonPath() |
Modifier and Type | Method and Description |
---|---|
protected Collection<ValidationResult> |
customValidate(ValidationContext context) |
Set<Relationship> |
getRelationships() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ProcessorInitializationContext context) |
void |
onPropertyModified(PropertyDescriptor descriptor,
String oldValue,
String newValue) |
void |
onRemoved(ProcessContext processContext)
Provides cleanup of the map for any JsonPath values that may have been created.
|
void |
onScheduled(ProcessContext processContext) |
void |
onTrigger(ProcessContext processContext,
ProcessSession processSession) |
void |
onUnscheduled() |
getResultRepresentation, isJsonScalar, validateAndEstablishJsonContext
onTrigger
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue
equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getPropertyDescriptor, getPropertyDescriptors, validate
public static final String DESTINATION_ATTRIBUTE
public static final String DESTINATION_CONTENT
public static final String RETURN_TYPE_AUTO
public static final String RETURN_TYPE_JSON
public static final String RETURN_TYPE_SCALAR
public static final String PATH_NOT_FOUND_IGNORE
public static final String PATH_NOT_FOUND_WARN
public static final PropertyDescriptor DESTINATION
public static final PropertyDescriptor RETURN_TYPE
public static final PropertyDescriptor PATH_NOT_FOUND
public static final Relationship REL_MATCH
public static final Relationship REL_NO_MATCH
public static final Relationship REL_FAILURE
private Set<Relationship> relationships
private List<PropertyDescriptor> properties
private final ConcurrentMap<String,com.jayway.jsonpath.JsonPath> cachedJsonPathMap
private final Queue<Set<Map.Entry<String,com.jayway.jsonpath.JsonPath>>> attributeToJsonPathEntrySetQueue
private volatile String representationOption
private volatile boolean destinationIsAttribute
private volatile String returnType
private volatile String pathNotFound
private volatile String nullDefaultValue
protected void init(ProcessorInitializationContext context)
init
in class AbstractSessionFactoryProcessor
protected Collection<ValidationResult> customValidate(ValidationContext context)
customValidate
in class AbstractConfigurableComponent
public Set<Relationship> getRelationships()
getRelationships
in interface Processor
getRelationships
in class AbstractSessionFactoryProcessor
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors
in class AbstractConfigurableComponent
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor
in class AbstractConfigurableComponent
public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
onPropertyModified
in interface ConfigurableComponent
onPropertyModified
in class AbstractConfigurableComponent
@OnRemoved public void onRemoved(ProcessContext processContext)
processContext
- context@OnScheduled public void onScheduled(ProcessContext processContext)
@OnUnscheduled public void onUnscheduled()
public void onTrigger(ProcessContext processContext, ProcessSession processSession) throws ProcessException
onTrigger
in class AbstractProcessor
ProcessException
Copyright © 2018 Apache NiFi Project. All rights reserved.