From 2397f9826f6982cd5c07c24506ad8b02e96d0654 Mon Sep 17 00:00:00 2001 From: ncautotest Date: Mon, 23 Oct 2023 13:08:55 +0200 Subject: [PATCH 1/3] add example of filterWith(FilterBy) example of applying custom filtering logic that does not fit into the existing filtering presets --- Readme.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Readme.md b/Readme.md index a105fba1..23e596f6 100644 --- a/Readme.md +++ b/Readme.md @@ -472,6 +472,26 @@ aecu.contentUpgradeBuilder() .run() ``` +#### Filter by custom filter + +To filter by complex conditions that are not covered by existing filters you can use `filterWith()` that takes your own `FilterBy` implementation as shown in the example below: + +```java +aecu.contentUpgradeBuilder() + .forDescendantResourcesOf("/content/we-retail/ca/en", false) + .filterWith(new FilterBy(){ + public boolean filter(Resource resource, StringBuilder output) { + ValueMap properties = resource.getValueMap(); + Calendar lastModified = properties.get("cq:lastModified", Calendar.class); + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.YEAR, -5); + return (lastModified.getTime().before(cal.getTime())); + } + }) + .doSetProperty("old", true) // mark pages that weren't modified in the past 5 years + .run() +``` + ### Execute Options From f43e38e39f9ab83fa5d33b3603c8f7b7a67f08aa Mon Sep 17 00:00:00 2001 From: ncautotest Date: Tue, 24 Oct 2023 12:03:32 +0200 Subject: [PATCH 2/3] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 23e596f6..ceca839a 100644 --- a/Readme.md +++ b/Readme.md @@ -472,9 +472,9 @@ aecu.contentUpgradeBuilder() .run() ``` -#### Filter by custom filter +#### Filter with custom FilterBy implementation -To filter by complex conditions that are not covered by existing filters you can use `filterWith()` that takes your own `FilterBy` implementation as shown in the example below: +To filter by complex conditions that are not covered by existing `filterBy...()` presets you can use `filterWith()` that takes a custom `FilterBy` implementation as shown in the example below: ```java aecu.contentUpgradeBuilder() From 615e260adf1968d41510b7cfce864d206ea97e45 Mon Sep 17 00:00:00 2001 From: ncautotest Date: Tue, 24 Oct 2023 15:03:12 +0200 Subject: [PATCH 3/3] groovified example code --- Readme.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Readme.md b/Readme.md index ceca839a..fde911b0 100644 --- a/Readme.md +++ b/Readme.md @@ -481,11 +481,11 @@ aecu.contentUpgradeBuilder() .forDescendantResourcesOf("/content/we-retail/ca/en", false) .filterWith(new FilterBy(){ public boolean filter(Resource resource, StringBuilder output) { - ValueMap properties = resource.getValueMap(); - Calendar lastModified = properties.get("cq:lastModified", Calendar.class); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.YEAR, -5); - return (lastModified.getTime().before(cal.getTime())); + ValueMap properties = resource.valueMap + Calendar lastModified = properties.get("cq:lastModified", Calendar.class) + Calendar cal = Calendar.instance + cal.add(Calendar.YEAR, -5) + return lastModified.time.before(cal.time) } }) .doSetProperty("old", true) // mark pages that weren't modified in the past 5 years