Member since
08-18-2019
56
Posts
11
Kudos Received
18
Solutions
My Accepted Solutions
| Title | Views | Posted |
|---|---|---|
| 1189 | 11-15-2023 05:38 AM | |
| 4549 | 07-12-2023 05:38 AM | |
| 1086 | 01-10-2023 01:50 AM | |
| 1492 | 12-06-2022 12:08 AM | |
| 5530 | 12-02-2022 12:55 AM |
12-06-2022
12:08 AM
Hello @Manimaran, to help you it would be good if you go a bit more specific into your question with some sample content and what you want to have as expected output. Greetings
... View more
11-28-2022
08:50 PM
Hi @Faerballert , Its working as expected. Thank you so much.
... View more
11-23-2022
02:51 AM
@Faerballert , It's working fine as expected. Thank you so much for the quick response.
... View more
11-09-2022
09:53 PM
@Faerballert , can you please reply if you have the solution for this or can you share the code to resize the attachment from the mailbox
... View more
11-08-2022
07:37 PM
Hi, Thank you for pointing that out. It has certaintly speed up my development. This is a short snippet to my solution: var StreamCallback = Java.type("org.apache.nifi.processor.io.StreamCallback");
var IOUtils = Java.type("org.apache.commons.io.IOUtils");
var StandardCharsets = Java.type("java.nio.charset.StandardCharsets");
var flowFile = session.get();
if(flowFile != null) {
try {
// Create a new StreamCallback, passing in a function to define the interface method
flowFile = session.write(flowFile,
new StreamCallback(function(inputStream, outputStream) {
var text = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
var obj = JSON.parse(text);
obj["gender"] = "Male";
outputStream.write(JSON.stringify(obj).getBytes(StandardCharsets.UTF_8));
}));
session.transfer(flowFile, REL_SUCCESS);
} catch (e) {
log.error(e.message)
session.transfer(flowFile, REL_FAILURE);
}
} Something to point out for those using javascript. If your using GenerateFlowFile processor to generate sample JSON content, the JSON content in Custom Text must use double quotes ( " ), not single quotes ( ' ). I spent an hour debugging why my JSON.parse(text) didn't work. Custom Text {'name':'myName'} It should be {"name":"myName"}
... View more
11-08-2022
11:43 AM
1 Kudo
@Bridewin I two things you may want to try.... 1. GetFile processor was deprecated in favor of the newer ListFile --> FetchFile processors. I'd recommend switching to these processors and see if you have the same observations. 2. I'd suggest enabling debug logging for the GetFile processor class to see what additional logging may show. To do this, you would modify the logback.xml file in NiFi's conf directory. Add the below line down in this file where you see similar lines already. <logger name="org.apache.nifi.processors.standard.GetFile" level="DEBUG"/> If you found that the provided solution(s) assisted you with your query, please take a moment to login and click Accept as Solution below each response that helped. Thank you, Matt
... View more
11-03-2022
07:40 AM
Try that: [
{
"operation": "shift",
"spec": {
"*": {
"Ean": "[&1].gtin",
"ean": "[&1].gtin",
"EAN": "[&1].gtin",
"EanCode": "[&1].gtin",
"EAN-Code": "[&1].gtin",
"EANCode": "[&1].gtin",
"Ausdr1": "[&1].gtin",
"Bestand": "[&1].qty",
"Menge": "[&1].qty",
"Stock": "[&1].qty",
"stock": "[&1].qty",
"Verfügbare Menge (Kennzahl)": "[&1].qty",
"Verfügbare Menge": "[&1].qty"
}
}
}, {
"operation": "modify-default-beta",
"spec": {
"*": {
"update_date": "2022-11-03",
"supplier_name": "demo",
"file_name": "test"
}
}
}
] Greetings
... View more
11-02-2022
05:37 AM
1 Kudo
Agreed, you do not have access to the fields in either the incoming or outgoing JSON objects using Expression Language in the spec.
... View more
10-26-2022
08:13 AM
Hello, can you try it with: [
{
"operation": "shift",
"spec": {
"orderItems": {
"*": {
"id": "orderItems[&1].text01",
"typeId": "orderItems[&1].text02",
"itemVariationId": "orderItems[&1].text03",
"quantity": "orderItems[&1].text04",
"attributeValues": "orderItems[&1].text05",
"vatField": "orderItems[&1].text06",
"amounts": "orderItems[&1].amounts"
}
},
"*": "&"
}
}
] Let me know if there needs something to change. Greetings
... View more
10-08-2022
08:23 AM
1 Kudo
Hey @Fredi , I believe the answer for your problem is the processor UpdateRecord. Update record allows you to directly manipulate the fields in your file content. You add dynamic properties to the processor where the key of the property is /<field> (so in your case, '/api_value'), and in the value of this dynamic property you can write down some logic to determine what value to insert into api_value. In the processor, there is a field called "Replacement Value Strategy", which defines how the value of the property will be read. If you set this to "Record Path Value", it means you can now give a path to a different field in your file (url_value!) - I can't test this right now because I'm not at my office, but I'm not entirely sure whether you can manipulate the result after giving a record path (to extract the api_value from the evaluated url_value). Regardless, I'm just about 100% sure this can be done with two processors - One EvaluateJsonPath to extract the url_value into an attribute, then UpdateRecord that uses the 'Literal Value' replacement strategy - with this strategy, you can just add a property with key '/api_value' and value '${url_value}' (or whatever attribute name you gave to the extracted url_value) and once you can access url_value with the expression language (via ${url_value}) you can use all the available functions to manipulate expression language variables. Here's an article with a couple of examples on UpdateRecord: https://community.cloudera.com/t5/Community-Articles/Update-the-Contents-of-FlowFile-by-using-UpdateRecord/ta-p/248267 (I noticed in the article they used some recordPath related functions like "replaceRegex", so I believe there might be a way to use these and then limit the entire issue to just one UpdateRecord processor! Sadly I'm not too familiar with these myself and this was the first time I've seen them) And here's the expression language documentation: https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html You can see there are lots of useful functions to extract your api_value once you have ${url_value} as an attribute variable, for example "substring", "find"/"replace", "ifElse", etc. all of which you can try and use to ensure only the api_value is left in the end. Hope this helps! I'm sure using ReplaceText and possibly JoltTransform could provide alternate solutions to the issue, however I believe UpdateRecord is the cleanest solution for this and truly makes use of the processor's abilities. If you struggle to use it correctly, you can reply with an example json and expected output and I'll try to write down the flow when I have time.
... View more