Added a filtering step on __addBindings.jq__

This commit is contained in:
Javier Quinones
2026-08-17 12:23:51 -05:00
parent f2e0d00d03
commit 24f5e143dd

View File

@@ -1,23 +1,30 @@
# Filter first
.
| debug("Filtering...")
| .tags[]
|= select(.typeId == "Cooling/PLC_AB/PLC_AB_Auto_v3")
# Sort first
| walk(
if type == "object" and has("tags") then
.tags |= sort_by(.name)
end
)
| debug("Sorting...")
| walk( if type == "object" and has("tags") then .tags |= sort_by(.name) end )
# so object positions are predictable
| .tags[3].tags[1].tags as $baseData
| walk(
# Removes .Tags.Controller Tags from the plcName parameter
if type == "object" and has("plcName") then
.plcName.value |= rtrimstr(".Tags.Controller Tags")
elif type == "object" and has("plcname") then
.plcname.value |= rtrimstr(".Tags.Controller Tags")
| 2 as $pos
| .tags[0].tags[$pos].tags as $baseData
| debug("Modifying tags...")
| .tags
|= map(
.
| if .parameters.plcName.value then
.parameters.plcName.value |= rtrimstr(".Tags.Controller Tags")
elif .parameters.plcname.value then
.parameters.plcname.value |= rtrimstr(".Tags.Controller Tags")
end
)
# and can be used as the base line to setup the other objects
| walk(
if type == "object" and .name? == "Data" then
.tags = $baseData
| if .tags
and .tags[$pos].name == "Data"
and .tags[$pos].tagType == "Folder"
then
.tags[$pos].tags |= $baseData
else
.
| debug("Data folder not found")
end
)