-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathupdate_attribute.py
More file actions
28 lines (24 loc) · 868 Bytes
/
update_attribute.py
File metadata and controls
28 lines (24 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
###############################################################################
# Setting flowfile attributes in ExecuteScript
#
# Variables provided in scope by script engine:
#
# session - ProcessSession
# context - ProcessContext
# log - ComponentLog
# REL_SUCCESS - Success Relationship
# REL_FAILURE - Failure Relationship
###############################################################################
flowFile = session.get()
if flowFile != None:
# Get attributes
attribute1 = flowFile.getAttribute("attribute1")
message = attribute1 + " update!"
# Set single attribute
flowFile = session.putAttribute(flowFile, "message", message)
# Set multiple attributes
flowFile = session.putAllAttributes(flowFile, {
"attribute.one": "true",
"attribute.two": "2"
})
session.transfer(flowFile, REL_SUCCESS)