-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(editor): add additional sample scripts
- Loading branch information
Showing
10 changed files
with
461 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"logLevel": "info", | ||
"hops": [ | ||
{ | ||
"type": "declare", | ||
"declarations": { | ||
"nodeName": "\"nName\"", | ||
"jcrPrimaryType": "\"cq:PageContent\"", | ||
"slingResourceType": "\"swisscom/components/structure/page\"" | ||
} | ||
}, | ||
{ | ||
"type": "each", | ||
"expression": "['de', 'fr', 'it', 'en']", | ||
"hops": [ | ||
{ | ||
"type": "nodeQuery", | ||
"query": "/* The search query has to return the parent nodes we want to act on */\nSELECT * FROM [nt:unstructured] AS s WHERE ISDESCENDANTNODE([/content/swisscom/${lang}])", | ||
"queryType": "JCR-SQL2", | ||
"hops": [ | ||
{ | ||
"type": "createChildNode", | ||
"conflict": "force", | ||
"name": "${nodeName}", | ||
"runOnExistingNode": false, | ||
"hops": [ | ||
{ | ||
"type": "setProperty", | ||
"conflict": "force", | ||
"propertyName": "sling:resourceType", | ||
"value": "slingResourceType" | ||
} | ||
], | ||
"primaryType": "${jcrPrimaryType}" | ||
} | ||
] | ||
} | ||
], | ||
"iterator": "lang" | ||
} | ||
], | ||
"parameters": [] | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/frontend/model/samples/add-or-replace-property.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"logLevel": "info", | ||
"hops": [ | ||
{ | ||
"type": "declare", | ||
"declarations": { | ||
"propertyName": "\"pName\"", | ||
"propertyValue": "\"pValue\"" | ||
} | ||
}, | ||
{ | ||
"type": "each", | ||
"expression": "['de', 'fr', 'it', 'en']", | ||
"hops": [ | ||
{ | ||
"type": "nodeQuery", | ||
"query": "SELECT * FROM [nt:unstructured] AS s WHERE ISDESCENDANTNODE([/content/swisscom/${lang}])", | ||
"queryType": "JCR-SQL2", | ||
"hops": [ | ||
{ | ||
"type": "setProperty", | ||
"conflict": "force", | ||
"propertyName": "${propertyName}", | ||
"value": "propertyValue" | ||
} | ||
] | ||
} | ||
], | ||
"iterator": "lang" | ||
} | ||
], | ||
"parameters": [] | ||
} |
77 changes: 77 additions & 0 deletions
77
src/main/frontend/model/samples/batch-search-and-replace.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"logLevel": "info", | ||
"hops": [ | ||
{ | ||
"type": "nodeQuery", | ||
"query": "SELECT * FROM [nt:unstructured] WHERE ISDESCENDANTNODE([/content/example]) AND [sling:resourceType] = 'granite/ui/components/coral/foundation/form/textfield'", | ||
"queryType": "JCR-SQL2", | ||
"hops": [ | ||
{ | ||
"type": "each", | ||
"expression": "args.inputPropertyValues", | ||
"hops": [ | ||
{ | ||
"type": "runScript", | ||
"code": "/*\n The inputPropertyValues file should be in the format <propertyName>,<oldValue>,<newValue> ex.:\n propertyName,oldVal,newVal\n propertyName1,oldVal1,newVal1\n*/\n\nsplitted = str:split(vals, ',');\n\nif(arr:getLength(splitted) == 3) {\n propertyName = splitted[0];\n oldValue = splitted[1];\n newValue = splitted[2];\n} else {\n propertyName = \"\";\n oldValue = \"\";\n newValue = \"\";\n}\n", | ||
"extension": "jexl", | ||
"putLocalsBackIntoScope": true | ||
}, | ||
{ | ||
"type": "filterNode", | ||
"expression": "jcr:val(node, propertyName) == oldValue", | ||
"hops": [ | ||
{ | ||
"type": "setProperty", | ||
"conflict": "force", | ||
"propertyName": "${propertyName}", | ||
"value": "newValue" | ||
} | ||
] | ||
} | ||
], | ||
"iterator": "vals" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "each", | ||
"expression": "args.inputXPath", | ||
"hops": [ | ||
{ | ||
"type": "runScript", | ||
"code": "/*\n The inputXPath file should be in the form <propertyName>;<xPathQuery>;<propertyValue> ex.:\n propertyName;/jcr:root/content/swisscom/de//*[@sling:resourceType='foundation/components/parsys']/*[not(@sling:resourceType)];newVal\n propertyName1;/jcr:root/content/swisscom/de//*[(jcr:like(@sling:resourceType, 'swisscom/components/content/text'))];newVal1\n*/\n\nsplitted = str:split(vals, ';');\n\nif(arr:getLength(splitted) == 3) {\n propertyName = splitted[0];\n xPathQuery = splitted[1];\n newValue = splitted[2];\n} else {\n propertyName = \"\";\n xPathQuery = \"\";\n newValue = \"\";\n}\n", | ||
"extension": "jexl", | ||
"putLocalsBackIntoScope": true | ||
}, | ||
{ | ||
"type": "nodeQuery", | ||
"query": "${xPathQuery}", | ||
"queryType": "xpath", | ||
"hops": [ | ||
{ | ||
"type": "setProperty", | ||
"conflict": "force", | ||
"propertyName": "${propertyName}", | ||
"value": "newValue" | ||
} | ||
] | ||
} | ||
], | ||
"iterator": "vals" | ||
} | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "inputPropertyValues", | ||
"defaultValue": "", | ||
"type": "file", | ||
"evaluation": "LINES" | ||
}, | ||
{ | ||
"name": "inputXPath", | ||
"defaultValue": "", | ||
"type": "file", | ||
"evaluation": "LINES" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
"logLevel": "info", | ||
"hops": [ | ||
{ | ||
"type": "declare", | ||
"declarations": { | ||
"path": "\"/content/swisscom/de\"", | ||
"phrase": "\"https://www.swisscom.ch/content/de\"", | ||
"extension": "\".html\"" | ||
} | ||
}, | ||
{ | ||
"type": "runScript", | ||
"code": "xPathQuery = str:join([\"/jcr:root\", path, \"//*[jcr:contains(., '\", phrase, \"') and jcr:contains(., '\", extension, \"') ]\"]);\n\n", | ||
"extension": "jexl", | ||
"putLocalsBackIntoScope": true | ||
}, | ||
{ | ||
"type": "nodeQuery", | ||
"query": "${xPathQuery}", | ||
"queryType": "xpath", | ||
"hops": [ | ||
{ | ||
"type": "each", | ||
"expression": "node.properties", | ||
"hops": [ | ||
{ | ||
"type": "filterNode", | ||
"expression": "property.type == 1 && !property.multiple && str:contains(jcr:val(node, property.name), phrase ) && str:contains(jcr:val(node, property.name), extension) ", | ||
"hops": [ | ||
{ | ||
"type": "runScript", | ||
"code": "log.info(property.path)", | ||
"extension": "js", | ||
"putLocalsBackIntoScope": true | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "filterNode", | ||
"expression": "property.type == 1 && property.multiple", | ||
"hops": [ | ||
{ | ||
"type": "declare", | ||
"declarations": { | ||
"joinedProperty": "str:join(jcr:vals(node, property.name))" | ||
} | ||
}, | ||
{ | ||
"type": "filterNode", | ||
"expression": "str:contains(joinedProperty, phrase) && str:contains(joinedProperty, extension)", | ||
"hops": [ | ||
{ | ||
"type": "runScript", | ||
"code": "log.info(property.path)", | ||
"extension": "js", | ||
"putLocalsBackIntoScope": true | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"iterator": "property" | ||
} | ||
] | ||
} | ||
], | ||
"parameters": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"logLevel": "info", | ||
"hops": [ | ||
{ | ||
"type": "each", | ||
"expression": "['de', 'fr', 'it', 'en']", | ||
"hops": [ | ||
{ | ||
"type": "nodeQuery", | ||
"query": "SELECT * FROM [nt:unstructured] AS s WHERE ISDESCENDANTNODE([/content/swisscom/${lang}]) AND [cq:template] = '/conf/swisscom/settings/wcm/templates/swisscom-content-page'", | ||
"queryType": "JCR-SQL2", | ||
"hops": [ | ||
{ | ||
"type": "moveNode", | ||
"conflict": "ignore", | ||
"newName": "/dev/null" | ||
} | ||
] | ||
} | ||
], | ||
"iterator": "lang", | ||
"assumeNodes": false | ||
} | ||
], | ||
"parameters": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/frontend/model/samples/migrate-resource-type.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"logLevel": "info", | ||
"hops": [ | ||
{ | ||
"type": "declare", | ||
"declarations": { | ||
"sourceResourceType": "\"swisscom/components/content/accordion\"", | ||
"destinationResourceType": "\"swisscom/components/content/accordion-new\"" | ||
} | ||
}, | ||
{ | ||
"type": "nodeQuery", | ||
"query": "SELECT * FROM [nt:unstructured] as component WHERE component.[sling:resourceType] = \"${sourceResourceType}\"", | ||
"queryType": "JCR-SQL2", | ||
"hops": [ | ||
{ | ||
"type": "setProperty", | ||
"conflict": "force", | ||
"propertyName": "sling:resourceType", | ||
"value": "destinationResourceType" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "declare", | ||
"declarations": { | ||
"sourceTemplate": "\"/conf/swisscom/settings/wcm/templates/swisscom-content-page\"", | ||
"destinationTemplate": "\"/conf/swisscom/settings/wcm/templates/swisscom-content-page-new\"" | ||
} | ||
}, | ||
{ | ||
"type": "nodeQuery", | ||
"query": "SELECT * FROM [nt:unstructured] AS page WHERE [cq:template] = \"${sourceTemplate}\"", | ||
"queryType": "JCR-SQL2", | ||
"hops": [ | ||
{ | ||
"type": "setProperty", | ||
"conflict": "force", | ||
"propertyName": "cq:template", | ||
"value": "destinationTemplate" | ||
} | ||
] | ||
} | ||
], | ||
"parameters": [] | ||
} |
Oops, something went wrong.