I have a workflow that creates two different flowfiles. I want to filter one specific flowfile based on a condition and send it to the next processor.
My work so far
def ff=session.get()
if(!ff)return
def flowFiles=session.get(2)
if(!flowFiles || flowFiles.size() < 2) return
def ff = flowFiles.find{ it.getAttribute("receive_date_filter") != null }
def original = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z")
def target = new SimpleDateFormat("yyyy-MM-dd")
def received_date = ff."received_date"
def received_date_filter = ff."receive_date_filter"
def original_parsed = original.parse(received_date)
def received_date_filter_parsed = target.parse(received_date_filter)
def subject = ff."email.headers.subject"
def subject_regex = ff."subject"
def pattern = subject =~ subject_regex
ff_old = flowFiles.find{ it.getAttribute("receive_date_filter") == null }
if (received_date_filter.isEmpty() && subject.isEmpty()){
REL_SUCCESS << ff_old
}
if (subject.isEmpty()){
if (original_parsed.after(received_date_filter_parsed)){
REL_SUCCESS << ff_old
} else {
REL_FAILURE << ff
}
} else {
if (pattern && original_parsed.after(received_date_filter_parsed)){
REL_SUCCESS << ff_old
} else {
REL_FAILURE << ff
}
}
But it is throwing transfer relationship not specified error