Skip to content

Commit

Permalink
Merge pull request valtech#179 from valtech/feature/166_not-filters
Browse files Browse the repository at this point in the history
166 added NOT filters
  • Loading branch information
gruberrolandvaltech committed Apr 6, 2022
2 parents b04f373 + 95e6ced commit cfb19b6
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 14 deletions.
1 change: 1 addition & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
5.3.0
- AecuService: added executeWithInstallHookHistory() method (172)
- Binding: added "not" versions of all filters

2022-03-28 5.2.0
- Added forResourcesByPropertyQuery() to binding
Expand Down
21 changes: 20 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,31 @@ These methods can be used to filter the nodes that were collected above. Multipl
Filters the resources by property values.

* filterByHasProperty: matches all nodes that have the given property. The value of the property is not relevant.
* filterByNotHasProperty: matches all nodes that do not have the given property. The value of the property is not relevant.
* filterByProperty: matches all nodes that have the given attribute value. Filter does not match if attribute is not present. By using a value of "null" you can search if an attribute is not present.
* filterByNotProperty: matches all nodes that do not have the given attribute value. Filter matches if attribute is not present.
* filterByProperties: use this to filter by a list of property values (e.g. sling:resourceType). All properties in the map are required to to match. Filter does not match if attribute does not exist.
* filterByNotProperties: use this to filter by a list of property values (e.g. sling:resourceType) is not matching. If any property in the map does not match the filter matches. Filter matches if attribute does not exist.
* filterByMultiValuePropContains: checks if all condition values are contained in the defined attribute. Filter does not match if attribute does not exist.
* filterByPropertyRegex: filters by a single property using a regular expression for the value. This is intended for single value properties. Hint: use "(?s)" at the beginning of the regex to search multiline content.
* filterByNotMultiValuePropContains: checks if not all condition values are contained in the defined attribute. Filter matches if attribute does not exist.
* filterByPropertyRegex: filters by a single property matching a regular expression for the value. This is intended for single value properties. Hint: use "(?s)" at the beginning of the regex to search multiline content.
* filterByNotPropertyRegex: filters by a single property not matching a regular expression for the value. This is intended for single value properties. Hint: use "(?s)" at the beginning of the regex to search multiline content.
* filterByAnyPropertyRegex: filters by any property that matches a given regular expression for the value. This reads all properties as single-valued String properties. Hint: use "(?s)" at the beginning of the regex to search multiline content.
* filterByNoPropertyRegex: filters by no property matching a given regular expression for the value. This reads all properties as single-valued String properties. Hint: use "(?s)" at the beginning of the regex to search multiline content.

```java
filterByHasProperty(String name)
filterByNotHasProperty(String name)
filterByProperty(String name, Object value)
filterByNotProperty(String name, Object value)
filterByProperties(Map<String, String> properties)
filterByNotProperties(Map<String, Object> conditionProperties)
filterByMultiValuePropContains(String name, Object[] conditionValues)
filterByNotMultiValuePropContains(String name, Object[] conditionValues)
filterByPropertyRegex(String name, String regex)
filterByNotPropertyRegex(String name, String regex)
filterByAnyPropertyRegex(String regex)
filterByNoPropertyRegex(String regex)
```

Example:
Expand All @@ -351,13 +363,17 @@ aecu.contentUpgradeBuilder()
You can also filter nodes by their name.

* filterByNodeName(String name): process only nodes which have this exact name
* filterByNotNodeName(String name): process only nodes which do not have this exact name
* filterByNodeNameRegex(String regex): process nodes that have a name that matches the given regular expression
* filterByNotNodeNameRegex(String regex): process nodes that have a name that does not match the given regular expression

```java
aecu.contentUpgradeBuilder()
.forChildResourcesOf("/content/we-retail/ca/en")
.filterByNodeName("jcr:content")
.filterByNotNodeName("jcr:content")
.filterByNodeNameRegex("jcr.*")
.filterByNotNodeNameRegex("jcr.*")
.doSetProperty("name", "value")
.run()
```
Expand All @@ -367,11 +383,13 @@ aecu.contentUpgradeBuilder()
Nodes can also be filtered by their path using a regular expression.

* filterByPathRegex(String regex): process nodes whose path matches the given regular expression
* filterByNotPathRegex(String regex): process nodes whose path does not match the given regular expression

```java
aecu.contentUpgradeBuilder()
.forChildResourcesOf("/content/we-retail/ca/en")
.filterByPathRegex(".*/jcr:content/.*")
.filterByNotPathRegex(".*/jcr:content/.*")
.doSetProperty("name", "value")
.run()
```
Expand Down Expand Up @@ -416,6 +434,7 @@ def complexFilter = new ORFilter(
aecu.contentUpgradeBuilder()
.forDescendantResourcesOf("/content/we-retail/ca/en", false)
.filterWith(complexFilter)
.filterNotWith(complexFilter)
.filterWith(new NOTFilter(new FilterByPathRegex(".*jcr:content.*")))
.doSetProperty("name", "value")
.run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,15 @@ public interface ContentUpgrade {
ContentUpgrade filterByHasProperty(String name);

/**
* Filters by a single property.
* Filters by non-existence of a single property.
*
* @param name property name
* @return upgrade object
*/
ContentUpgrade filterByNotHasProperty(String name);

/**
* Filters by matching a single property.
*
* @param name property name
* @param value property value
Expand All @@ -116,15 +124,34 @@ public interface ContentUpgrade {
ContentUpgrade filterByProperty(String name, Object value);

/**
* Filters by a single property using a regular expression for the value. This is intended for
* single value properties.
* Filters by not matching a single property.
*
* @param name property name
* @param value property value
* @return upgrade object
*/
ContentUpgrade filterByNotProperty(String name, Object value);

/**
* Filters by matching a single property using a regular expression for the value. This is
* intended for single value properties.
*
* @param name property name
* @param regex regular expression to match value
* @return upgrade object
*/
ContentUpgrade filterByPropertyRegex(String name, String regex);

/**
* Filters by not matching a single property using a regular expression for the value. This is
* intended for single value properties.
*
* @param name property name
* @param regex regular expression to match value
* @return upgrade object
*/
ContentUpgrade filterByNotPropertyRegex(String name, String regex);

/**
* Filters by checking if any property matches the given regular expression for the value. This
* is intended for single value properties.
Expand All @@ -135,22 +162,48 @@ public interface ContentUpgrade {
ContentUpgrade filterByAnyPropertyRegex(String regex);

/**
* Filters by properties. Can be used also for Multi-value properties.
* Filters by checking if any property does not match the given regular expression for the
* value. This is intended for single value properties.
*
* @param regex regular expression to match value
* @return upgrade object
*/
ContentUpgrade filterByNoPropertyRegex(String regex);

/**
* Filters by matching multiple properties. Can be used also for Multi-value properties.
*
* @param conditionProperties properties to filter
* @return upgrade object
**/
ContentUpgrade filterByProperties(Map<String, Object> conditionProperties);

/**
* Filters by multi-value with the given name containing the given conditionValues
* Filters by not matching multiple properties. Can be used also for Multi-value properties.
*
* @param conditionProperties properties to filter
* @return upgrade object
**/
ContentUpgrade filterByNotProperties(Map<String, Object> conditionProperties);

/**
* Filters by multi-value with the given name containing the given condition values.
*
* @param name name of the multi-value property
* @param conditionValues values to search for
* @return upgrade object
*/
ContentUpgrade filterByMultiValuePropContains(String name, Object[] conditionValues);

/**
* Filters by multi-value with the given name not containing the given condition values.
*
* @param name name of the multi-value property
* @param conditionValues values to search for
* @return upgrade object
*/
ContentUpgrade filterByNotMultiValuePropContains(String name, Object[] conditionValues);

/**
* Filters by node name exact match.
*
Expand All @@ -159,6 +212,14 @@ public interface ContentUpgrade {
*/
ContentUpgrade filterByNodeName(String nodeName);

/**
* Filters by node name no exact match.
*
* @param nodeName node name
* @return upgrade object
*/
ContentUpgrade filterByNotNodeName(String nodeName);

/**
* Filters by node/subNode exists.
*
Expand All @@ -176,29 +237,53 @@ public interface ContentUpgrade {
ContentUpgrade filterByNodeNotExists(String path);

/**
* Filters by node name using regular expression.
* Filters by matching node name using regular expression.
*
* @param regex regular expression (Java standard pattern)
* @return upgrade object
*/
ContentUpgrade filterByNodeNameRegex(String regex);

/**
* Filters by node path using regular expression.
* Filters by not matching node name using regular expression.
*
* @param regex regular expression (Java standard pattern)
* @return upgrade object
*/
ContentUpgrade filterByNotNodeNameRegex(String regex);

/**
* Filters by matching node path using regular expression.
*
* @param regex regular expression (Java standard pattern)
* @return upgrade object
*/
ContentUpgrade filterByPathRegex(String regex);

/**
* Filters by using the given filter.
* Filters by not matching node path using regular expression.
*
* @param regex regular expression (Java standard pattern)
* @return upgrade object
*/
ContentUpgrade filterByNotPathRegex(String regex);

/**
* Filters by matching the given filter.
*
* @param filter filter
* @return upgrade object
*/
ContentUpgrade filterWith(FilterBy filter);

/**
* Filters by not matching the given filter.
*
* @param filter filter
* @return upgrade object
*/
ContentUpgrade filterNotWith(FilterBy filter);

/**
* Sets a property value.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 - 2021 Valtech GmbH
* Copyright 2018 - 2022 Valtech GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand All @@ -22,7 +22,7 @@
*
* @author Roxana Muresan
*/
@Version("4.7.0")
@Version("4.8.0")
package de.valtech.aecu.api.groovy.console.bindings;

import org.osgi.annotation.versioning.Version;
Loading

0 comments on commit cfb19b6

Please sign in to comment.