DATACMNS-1609, DATACMNS-1438 - Skip collection path segments for auditing properties.
We now skip PersistentPropertyPath instances pointing to auditing properties for which the path contains a collection or map path segment as the PersistentPropertyAccessor currently cannot handle those. A more extensive fix for that will be put in place for Moore but requires more extensive API changes which we don't want to ship in a Lovelace maintenance release. Related tickets: DATACMNS-1461.
This commit is contained in:
committed by
Christoph Strobl
parent
e28a78ee8e
commit
ced3dde2a4
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.mapping;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.springframework.data.util.Streamable;
|
||||
|
||||
@@ -51,4 +52,14 @@ public interface PersistentPropertyPaths<T, P extends PersistentProperty<P>>
|
||||
* @return
|
||||
*/
|
||||
boolean contains(PropertyPath path);
|
||||
|
||||
/**
|
||||
* Drops {@link PersistentPropertyPath}s that contain a path segment matching the given predicate.
|
||||
*
|
||||
* @param predicate must not be {@literal null}.
|
||||
* @return a {@link PersistentPropertyPaths} instance with all {@link PersistentPropertyPath} instances removed that
|
||||
* contain path segments matching the given predicate.
|
||||
* @since 2.1.4 / 2.2.2
|
||||
*/
|
||||
PersistentPropertyPaths<T, P> dropPathIfSegmentMatches(Predicate<? super P> predicate);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.data.mapping.AssociationHandler;
|
||||
@@ -356,6 +357,22 @@ class PersistentPropertyPathFactory<E extends PersistentEntity<?, P>, P extends
|
||||
return paths.iterator();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mapping.PersistentPropertyPaths#dropPathIfSegmentMatches(java.util.function.Predicate)
|
||||
*/
|
||||
@Override
|
||||
public PersistentPropertyPaths<T, P> dropPathIfSegmentMatches(Predicate<? super P> predicate) {
|
||||
|
||||
Assert.notNull(predicate, "Predicate must not be null!");
|
||||
|
||||
List<PersistentPropertyPath<P>> paths = this.stream() //
|
||||
.filter(it -> !it.stream().anyMatch(predicate)) //
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return paths.equals(this.paths) ? this : new DefaultPersistentPropertyPaths<>(type, paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple {@link Comparator} to sort {@link PersistentPropertyPath} instances by their property segment's name
|
||||
* length.
|
||||
|
||||
Reference in New Issue
Block a user