Member since
05-10-2019
22
Posts
0
Kudos Received
0
Solutions
09-30-2020
12:32 PM
Hi @justenji ! Please take a look at the below code and tell me if it is working or if you need any further upgradations. As of now, I have converted the timestamps and added dnr_group. import java.nio.charset.StandardCharsets import org.apache.nifi.components.PropertyValue import groovy.json.JsonSlurper import groovy.json.JsonOutput flowFile = session.get() if (!flowFile) return try { def jsonSlurper = new JsonSlurper(); def jsonOutput = new JsonOutput(); def input = flowFile.read().withStream { data -> jsonSlurper.parse(data) } def pattern1 = 'yyyyMMddHHmmss'; def tz1 = 'GMT+0200'; def pattern2 = 'yyyy-MM-dd HH:mm:ss'; def tz2 = 'GMT'; input.stand = convertDatePattern(input.stand,pattern1,TimeZone.getTimeZone(tz1),pattern2,TimeZone.getTimeZone(tz2)); for(int i=0;i<input.table.size();i++){ input.table[i].elem_stand = convertDatePattern(input.table[i].elem_stand,pattern1,TimeZone.getTimeZone(tz1),pattern2,TimeZone.getTimeZone(tz2)); def dnr = input.table[i].dnr.replaceAll('\\(|\\)',''); def group = input.table[i].group.replaceAll('\\(|\\)',''); if(dnr.toInteger() < 10){ dnr = '0'+dnr; } if(group.toInteger() < 10){ group = '0'+group; } input.table[i].dnr_group = "V-"+dnr+"-"+group; input.table[i].remove('dnr'); input.table[i].remove('group'); } flowFile = session.write(flowFile, { outputStream -> outputStream.write(jsonOutput.toJson(input).toString().getBytes(StandardCharsets.UTF_8)) }as OutputStreamCallback); session.transfer(flowFile, REL_SUCCESS); } catch (e) { log.error('Error Occured,{}', e) session.transfer(flowFile, REL_FAILURE) } def convertDatePattern(String input, String pattern1, TimeZone tz1, String pattern2, TimeZone tz2){ return new Date().parse(pattern1,input,tz1).format(pattern2,tz2).toString(); }
... View more
08-17-2020
12:10 AM
To check null in JavaScript, use triple equals operator(===) or Object is() method. If you want to use Object.is() method then you two arguments. 1) Pass your variable value with a null value. 2) The null value itself. To find the difference between null and undefined, use the triple equality operator or Object is() method. To loosely check if the variable is null, use a double equality operator(==). The double equality operator can not tell the difference between null and undefined, so it counts as same. So if you want to strict check, then don't use a double equality operator. It will lead to misconclusion.
... View more
08-22-2019
04:31 AM
@puneetn HI, I'm having the same scenario. I wonder, have you ever come up with a solution? Thanks, Rosa
... View more
07-14-2019
04:12 PM
@Rosa Negra OK, processor EvaluateJsonPath extracted the content to attribute FF_CONTENT. To do the string manipulation within the attribute I suppose I have to use jsonPath function. But now I'm facing the same problem as before with RecordPath-syntax. I can't find the right syntax now to make the string manipulation within the attribute. I feel like going around in circles...
... View more