-
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.
Merge pull request #28 from swisscom/feature/OCERED-7939-lima-check-f…
…or-sample-script-need feat(editor): add additional sample scripts
- Loading branch information
Showing
11 changed files
with
495 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,45 @@ | ||
{ | ||
"logLevel": "info", | ||
"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/project])", | ||
"queryType": "JCR-SQL2", | ||
"hops": [ | ||
{ | ||
"type": "createChildNode", | ||
"conflict": "force", | ||
"name": "${args.nName}", | ||
"runOnExistingNode": false, | ||
"hops": [ | ||
{ | ||
"type": "setProperty", | ||
"conflict": "force", | ||
"propertyName": "sling:resourceType", | ||
"value": "args.slingResourceType" | ||
} | ||
], | ||
"primaryType": "${args.jcrPrimaryType}" | ||
} | ||
] | ||
} | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "nName", | ||
"defaultValue": "nName", | ||
"evaluation": "STRING" | ||
}, | ||
{ | ||
"name": "jcrPrimaryType", | ||
"defaultValue": "cq:PageContent", | ||
"evaluation": "STRING", | ||
"type": "text" | ||
}, | ||
{ | ||
"name": "slingResourceType", | ||
"defaultValue": "project/components/page", | ||
"evaluation": "STRING" | ||
} | ||
] | ||
} |
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
{ | ||
"logLevel": "info", | ||
"hops": [ | ||
{ | ||
"type": "nodeQuery", | ||
"query": "SELECT * FROM [nt:unstructured] AS s WHERE ISDESCENDANTNODE([/content/project/language])", | ||
"queryType": "JCR-SQL2", | ||
"hops": [ | ||
{ | ||
"type": "setProperty", | ||
"conflict": "force", | ||
"propertyName": "${args.propertyName}", | ||
"value": "args.propertyValue" | ||
} | ||
] | ||
} | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "propertyName", | ||
"defaultValue": "pName", | ||
"type": "text", | ||
"evaluation": "STRING" | ||
}, | ||
{ | ||
"name": "propertyValue", | ||
"defaultValue": "pValue", | ||
"type": "text", | ||
"evaluation": "STRING" | ||
} | ||
] | ||
} |
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\nsplit = str:split(vals, ',');\n\nif(arr:getLength(split) == 3) {\n propertyName = split[0];\n oldValue = split[1];\n newValue = split[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\nsplit = str:split(vals, ';');\n\nif(arr:getLength(split) == 3) {\n propertyName = split[0];\n xPathQuery = split[1];\n newValue = split[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,63 @@ | ||
{ | ||
"logLevel": "info", | ||
"hops": [ | ||
{ | ||
"type": "runScript", | ||
"code": "xPathQuery = str:join([\"/jcr:root\", args.path, \"//*[jcr:contains(., '\", args.phrase, \"') and jcr:contains(., '\", args.extension, \"') ]\"]);\noutput = utils.file.txt(\"properties_containing_hardcoded_urls\");\n\n", | ||
"extension": "jexl", | ||
"putLocalsBackIntoScope": true | ||
}, | ||
{ | ||
"type": "nodeQuery", | ||
"query": "${xPathQuery}", | ||
"queryType": "xpath", | ||
"hops": [ | ||
{ | ||
"type": "each", | ||
"expression": "node.properties", | ||
"hops": [ | ||
{ | ||
"type": "declare", | ||
"declarations": { | ||
"joinedProperty": "str:join(jcr:vals(node, property.name))" | ||
} | ||
}, | ||
{ | ||
"type": "filterNode", | ||
"expression": "str:contains(joinedProperty, args.phrase) && str:contains(joinedProperty, args.extension)", | ||
"hops": [ | ||
{ | ||
"type": "runScript", | ||
"code": "output.append(property.path);\noutput.append(\"\\n\");", | ||
"extension": "jexl", | ||
"putLocalsBackIntoScope": true | ||
} | ||
] | ||
} | ||
], | ||
"iterator": "property" | ||
} | ||
] | ||
} | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "phrase", | ||
"defaultValue": "https://www.project.ch/content/de", | ||
"type": "text", | ||
"evaluation": "STRING" | ||
}, | ||
{ | ||
"name": "extension", | ||
"defaultValue": ".html", | ||
"type": "text", | ||
"evaluation": "STRING" | ||
}, | ||
{ | ||
"name": "path", | ||
"defaultValue": "/content/project/de", | ||
"type": "text", | ||
"evaluation": "STRING" | ||
} | ||
] | ||
} |
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
32 changes: 32 additions & 0 deletions
32
src/main/frontend/model/samples/migrate-page-template.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,32 @@ | ||
{ | ||
"logLevel": "info", | ||
"hops": [ | ||
{ | ||
"type": "nodeQuery", | ||
"query": "SELECT * FROM [cq:PageContent] AS page WHERE [cq:template] = \"${args.sourceTemplate}\"", | ||
"queryType": "JCR-SQL2", | ||
"hops": [ | ||
{ | ||
"type": "setProperty", | ||
"conflict": "force", | ||
"propertyName": "cq:template", | ||
"value": "args.destinationTemplate" | ||
} | ||
] | ||
} | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "sourceTemplate", | ||
"defaultValue": "/conf/project/settings/wcm/templates/page", | ||
"type": "text", | ||
"evaluation": "STRING" | ||
}, | ||
{ | ||
"name": "destinationTemplate", | ||
"defaultValue": "/conf/project/settings/wcm/templates/page-new", | ||
"type": "text", | ||
"evaluation": "STRING" | ||
} | ||
] | ||
} |
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
{ | ||
"logLevel": "info", | ||
"hops": [ | ||
{ | ||
"type": "nodeQuery", | ||
"query": "SELECT * FROM [nt:unstructured] as component WHERE component.[sling:resourceType] = \"${args.sourceResourceType}\"", | ||
"queryType": "JCR-SQL2", | ||
"hops": [ | ||
{ | ||
"type": "setProperty", | ||
"conflict": "force", | ||
"propertyName": "sling:resourceType", | ||
"value": "args.destinationResourceType" | ||
} | ||
] | ||
} | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "destinationResourceType", | ||
"defaultValue": "project/components/content/accordion-new", | ||
"type": "text", | ||
"evaluation": "STRING" | ||
}, | ||
{ | ||
"name": "sourceResourceType", | ||
"defaultValue": "project/components/content/accordion", | ||
"type": "text", | ||
"evaluation": "STRING" | ||
} | ||
] | ||
} |
Oops, something went wrong.