Member since
08-10-2022
27
Posts
1
Kudos Received
2
Solutions
My Accepted Solutions
Title | Views | Posted |
---|---|---|
1519 | 03-16-2023 02:57 AM | |
9585 | 08-29-2022 04:50 AM |
06-20-2023
06:29 AM
Some progress: I've modified the transformation like this: [{
"operation": "shift",
"spec": {
"Orders": {
"*": {
"Headers": {
"*": "header.&"
},
"Locations": {
"Shipper": {
"*": "sender.&"
},
"Consignee": {
"*": "consignee.&"
},
"Unload": {
"*": "unload.&"
}
},
"Goods": {
"*": {
"GoodsDetails": {
"*": {
"@(2,GoodsTypeName)": "rows.GoodsTypeName",
"@(4,Locations.Consignee.ConsigneeName)": "rows.ConsigneeName",
"@(4,Locations.Consignee.IdPlanToLocCUS)": "rows.IdPlanToLocCUS",
"@(4,Locations.Consignee.ConsigneeAddress)": "rows.ConsigneeAddress",
"@(4,Locations.Consignee.ConsigneeCountry)": "rows.ConsigneeCountry",
"@(4,Locations.Consignee.ConsigneeEmail)": "rows.ConsigneeEmail",
"@(4,Locations.Consignee.ConsigneeNotes)": "rows.ConsigneeNotes",
"@(4,Locations.Consignee.ConsigneeReference)": "rows.ConsigneeReference",
"@(4,Locations.Consignee.ConsigneeRegion)": "rows.ConsigneeRegion",
"@(4,Locations.Consignee.ConsigneeTel)": "rows.ConsigneeTel",
"@(4,Locations.Consignee.ConsigneeTown)": "rows.ConsigneeTown",
"@(4,Locations.Consignee.ConsigneeZipCode)": "rows.ConsigneeZipCode",
"Packs": "rows.Packs",
"NetWeight": "rows.NetWeight",
"GrossWeight": "rows.GrossWeight",
"Cube": "rows.Cube",
"Meters": "rows.Meters",
"CodiceUnivocoCollo_1": "rows.CodiceUnivocoCollo_1",
"CodiceMaster": "rows.CodiceMaster",
"ItemCode": "rows.ItemCode",
"Seats": "rows.Seats",
"Height": "rows.Height",
"Width": "rows.Width",
"Depth": "rows.Depth",
"Note": "rows.Note",
"@(4,Locations.Unload.UnloadName)": "rows.UnloadName",
"@(4,Locations.Unload.IdShipToLocCUS)": "rows.IdShipToLocCUS",
"@(4,Locations.Unload.UnloadAddress)": "rows.UnloadAddress",
"@(4,Locations.Unload.UnloadCalendarNote)": "rows.UnloadCalendarNote",
"@(4,Locations.Unload.UnloadCountry)": "rows.UnloadCountry",
"@(4,Locations.Unload.UnloadDate)": "rows.UnloadDate",
"@(4,Locations.Unload.UnloadEmail)": "rows.UnloadEmail",
"@(4,Locations.Unload.UnloadNotes)": "rows.UnloadNotes",
"@(4,Locations.Unload.UnloadReference)": "rows.UnloadReference",
"@(4,Locations.Unload.UnloadRegion)": "rows.UnloadRegion",
"@(4,Locations.Unload.UnloadTel)": "rows.UnloadTel",
"@(4,Locations.Unload.UnloadTime)": "rows.UnloadTime",
"@(4,Locations.Unload.UnloadTown)": "rows.UnloadTown",
"@(4,Locations.Unload.UnloadZipCode)": "rows.UnloadZipCode",
"@(4,Locations.Unload.ObbligatoryUnloadDate)": "rows.ObbligatoryUnloadDate",
"@(4,References)": {
"*": {
"TypeReference": {
"OC": {
"@(2,ValueReference)": "rows.info1[]"
},
"CM": {
"@(2,ValueReference)": "rows.info7[]"
}
}
}
}
}
}
}
}
}
}
}
}, {
"operation": "cardinality",
"spec": {
"header": {
"*": "ONE"
},
"sender": {
"*": "ONE"
},
"consignee": {
"*": "ONE"
},
"unload": {
"*": "ONE"
}
}
}, {
"operation": "shift",
"spec": {
"header": {
"*": "header.&"
},
"sender": {
"*": "sender.&"
},
"consignee": {
"*": "consignee.&"
},
"unload": {
"*": "unload.&"
},
"rows": {
"*" : {
"*" : {
"@": "rows[&1].&2"
}
}
}
}
}] Everything works as expected when i have multiple elements in GoodDetails like this: "GoodsDetails": [
{
"Packs": 1,
"NetWeight": 3.800000,
"GrossWeight": 4.800000,
"Cube": 0.693000,
"Meters": 0.000000,
"Note": "good note"
},
{
"Packs": 1,
"NetWeight": 3.800000,
"GrossWeight": 4.800000,
"Cube": 0.693000,
"Meters": 0.000000,
"Note": "good note"
}
] However, when the element is only one like this: {
"Packs": 1,
"NetWeight": 3.800000,
"GrossWeight": 4.800000,
"Cube": 0.693000,
"Meters": 0.000000,
"Note": "good note"
} The result is really bad: rows": [{
"ConsigneeZipCode": null,
"UnloadZipCode": null,
"info7": "230500003530",
"info1": "V6157-0360",
"Seats": null
}, {
"Packs": null
}] It seems that when the element is only one, the first shift transformation does not consider resulting rows[ {}, {} ] as an array.... but something like: row{ name1: value1 name1: value2 ... } Any suggestion really appreciate.
... View more
06-20-2023
04:01 AM
Sometimes you may think you understand well about JOLT....then you stuck with another new transformation... 😉 My data: {
"Orders": [
{
"Headers": {
"UniqShipment": "0",
"OCCustomer": "V2472-0100",
"erpcode": "C001728"
},
"Locations": {
"Shipper": {
"SenderAddress": "address 1"
},
"Load": {
"LoadAddress": "address 2",
},
"Consignee": {
"ConsigneeName": "consignee name"
},
"Unload": {
"UnloadAddress": "address 4"
}
},
"Goods": [
{
"GoodsTypeID": 3,
"GoodsTypeName": "good name",
"GoodsDetails": [
{
"Packs": 1,
"NetWeight": 3.800000,
"GrossWeight": 4.800000,
"Cube": 0.693000,
"Meters": 0.000000,
"Note": "good note"
}
]
}
],
"References": [
{
"TypeReference": "DT",
"ValueReference": "010130",
"DateReference": "2023-06-20"
},
{
"TypeReference": "CM",
"ValueReference": "30492 STOCK-SP"
},
{
"TypeReference": "OC",
"ValueReference": "V2472-0100"
},
{
"TypeReference": "RG",
"ValueReference": "reference value"
}
]
},
{
"Headers": {
"UniqShipment": "0",
"OCCustomer": "V2472-0100",
"erpcode": "C001728"
},
"Locations": {
"Shipper": {
"SenderAddress": "address 1"
},
"Load": {
"LoadAddress": "address 2",
},
"Consignee": {
"ConsigneeName": "consignee name"
},
"Unload": {
"UnloadAddress": "address 4"
}
},
"Goods": [
{
"GoodsTypeID": 3,
"GoodsTypeName": "good name",
"GoodsDetails": [
{
"Packs": 1,
"NetWeight": 3.800000,
"GrossWeight": 4.800000,
"Cube": 0.693000,
"Meters": 0.000000,
"Note": "good note"
}
]
}
],
"References": [
{
"TypeReference": "DT",
"ValueReference": "010130",
"DateReference": "2023-06-20"
},
{
"TypeReference": "CM",
"ValueReference": "30492 STOCK-SP"
},
{
"TypeReference": "OC",
"ValueReference": "V2472-0100"
},
{
"TypeReference": "RG",
"ValueReference": "reference value"
}
]
}
]
} My Transform: [{
"operation": "shift",
"spec": {
"Orders": {
"*": {
"Headers": {
"*": "header.&"
},
"Locations": {
"Shipper": {
"*": "sender.&"
},
"Consignee": {
"*": "consignee.&"
},
"Unload": {
"*": "unload.&"
}
},
"Goods": {
"*": {
"GoodsDetails": {
"*": {
"@(2,GoodsTypeName)": "rows[].GoodsTypeName",
"@(4,Locations.Consignee.ConsigneeName)": "rows[].ConsigneeName"
}
}
}
}
}
}
}
}, {
"operation": "cardinality",
"spec": {
"header": {
"*": "ONE"
},
"sender": {
"*": "ONE"
},
"consignee": {
"*": "ONE"
},
"unload": {
"*": "ONE"
}
}
}] My Output: {
"header": {
"UniqShipment": "0",
"OCCustomer": "V2472-0100",
"erpcode": "C001728"
},
"sender": {
"SenderAddress": "address 1"
},
"consignee": {
"ConsigneeName": "consignee name"
},
"unload": {
"UnloadAddress": "address 2",
},
"rows": [{
"GoodsTypeName": "good name"
}, {
"ConsigneeName": "consignee name"
}, {
"GoodsTypeName": "good name"
}, {
"ConsigneeName": "consignee name"
}, {
"GoodsTypeName": "good name"
}, {
"ConsigneeName": "consignee name 2"
}, {
"GoodsTypeName": "good name"
}, {
"ConsigneeName": "consignee name 2"
}]
} My Expected Result: {
"header": {
"UniqShipment": "0",
"OCCustomer": "V2472-0100",
"erpcode": "C001728"
},
"sender": {
"SenderAddress": "address 1"
},
"consignee": {
"ConsigneeName": "consignee name"
},
"unload": {
"UnloadAddress": "address 2",
},
"rows": [{
"GoodsTypeName": "good name",
"ConsigneeName": "consignee name"
},{
"GoodsTypeName": "good name",
"ConsigneeName": "consignee name"
},{
"GoodsTypeName": "good name",
"ConsigneeName": "consignee name"
},{
"GoodsTypeName": "good name",
"ConsigneeName": "consignee name"
},{
"GoodsTypeName": "good name",
"ConsigneeName": "consignee name"
},{
"GoodsTypeName": "good name",
"ConsigneeName": "consignee name"
}
]
} What i've missing? Help appreciate!
... View more
Labels:
- Labels:
-
Apache NiFi
06-20-2023
12:56 AM
Yes correct....the file is read in the first fragment, updated and then saved into a local folder....and so on for every fragment. I want to be sure that every updare is saved without loosing data.
... View more
06-16-2023
10:07 AM
Moreover, how to assign multiple values when the case matches? EX: select *,
case when F3BARC_BarcodeSegnacollo = '${barcode}' then '${Shipment_Number},${Shipment_Date},${Document_Date}'
else
F3SPNU_NumSpedizione end as F3SPNU_NumSpedizione
F3SPNU_DataSpedizione end as F3SPNU_DataSpedizione
F3SPNU_NumDocumento end as F3SPNU_NumDocumento
from flowfile Many Thanks!
... View more
06-16-2023
09:41 AM
OK , i've found the problem. My query was: select *,
case when F3BARC_BarcodeSegnacollo = '${barcode}' then '${Shipment_Number}'
else F3SPNU_NumSpedizione end as F3SPNU_NumSpedizione
from flowfile But fields selection won't have field in else statement like this: select F3BARC_BarcodeSegnacollo,
case when F3BARC_BarcodeSegnacollo = '${barcode}' then '${Shipment_Number}'
else F3SPNU_NumSpedizione end as F3SPNU_NumSpedizione
from flowfile Is there any way to make a select *? I have lots of fields to select. Many Thanks
... View more
06-16-2023
06:44 AM
Well, i'm not sure this query is exactly what i'm searching for. Speaking in a human way this is what i need to do: Search the element with barcode=${barcode_attribute} and if found update corresponding "shipment_number" value with ${shipment_number_attribute}, otherwise leave it as it is. So this: [ {
"reference" : "PB",
"date" : "20230613",
"barcode" : "C337287V28490010",
"shipment_number" : ""
}, {
"reference" : "PB",
"date" : "20230613",
"barcode" : "C337287V28490011",
"shipment_number" : ""
}, {
"reference" : "PB",
"date" : "20230613",
"barcode" : "C337287V28490012",
"shipment_number" : ""
} ] would becomes as below: [ {
"reference" : "PB",
"date" : "20230613",
"barcode" : "C337287V28490010",
"shipment_number" : "0000023/SH"
}, {
"reference" : "PB",
"date" : "20230613",
"barcode" : "C337287V28490011",
"shipment_number" : ""
}, {
"reference" : "PB",
"date" : "20230613",
"barcode" : "C337287V28490012",
"shipment_number" : ""
} ] Trying your query seems that does not update shipment_number field. Hope this can explain better the need. Many Thanks
... View more
06-15-2023
01:31 PM
Sure I Kwon this....the question is how to add a where clause in Updare Record or QueryRecord . In QueryRecord I ve tried an Update statement with no luck. Will giving me always an error.
... View more
06-15-2023
01:29 PM
Barcode is an attribute coming from each fragment...different on any fragment.
... View more
06-14-2023
02:27 PM
Hello, hope someone can help me with this point. I have a json wich has been splitted into 4 fragments. For every fragment an EvaluateJsonPath is grabbing some attributes from it. Next, for every fragment, i need to fetch a file from local folder and do an UpdateRecord or QueryRecord(Update Statement) with attribute values contained in every fragment and retrieved by EvaluateJsonPath. So based on my understanding, and sequentially for every fragment, i should: 1 - fetch the local file 2 - UpdateRecord or QueryRecord by updating fields values with fragment attribue 3 - Save file into disk and repeat(loop) each step for every fragment. However i think this is wrong cause the next fragment could fetch the local file before the previous one is finished(saved to disk updated) How can i achieve this? Which is the best way to sequentially loop over every fragments and do some stuff? Many thanks for your help. appreciate
... View more
Labels:
- Labels:
-
Apache NiFi
06-14-2023
02:17 PM
Hi to all, hope someone can point me on the right direction. I have something like that: [ {
"reference" : "PB",
"date" : "20230613",
"barcode" : "C337287V28490010",
"shipment_number" : ""
}, {
"reference" : "PB",
"date" : "20230613",
"barcode" : "C337287V28490011",
"shipment_number" : ""
}, {
"reference" : "PB",
"date" : "20230613",
"barcode" : "C337287V28490012",
"shipment_number" : ""
} ] I need to update only a specific record with a met condition. Speaking on a SQL language it should be something like that: UPDATE FLOWFILE SET shipment_number = '${Shipment_Number_Attribute} ' WHERE barcode = '${Barcode_Attribute}' Unfortunately this statement in QueryRecord doesn't work, maybe UPDATE not supported? Moreover is there any way to achieve the same with UpdateRecord? Many thanks for any help. Appreciate.
... View more
Labels:
- Labels:
-
Apache NiFi