From 46c64bc6ca60575649934687ba4d1357c23103d6 Mon Sep 17 00:00:00 2001 From: Andrus Adamchik Date: Sat, 27 Nov 2021 12:49:45 +0200 Subject: [PATCH] Replace EntityEncoderFilter with per-entity object read filter #501 refactoring --- .../compiler/CayenneAgEntityBuilder.java | 4 ++-- ...lectFilterIT.java => GET_ReadFilterIT.java} | 14 +++++++------- ... GET_ReadFilter_EntityEncoderFilterIT.java} | 6 +++--- .../main/java/io/agrest/ResourceEntity.java | 6 +++--- .../src/main/java/io/agrest/SelectBuilder.java | 8 ++++---- .../compiler/AnnotationsAgEntityBuilder.java | 4 ++-- .../encoder/CompositeEntityEncoderFilter.java | 4 ++-- .../agrest/encoder/EncoderEntityCondition.java | 4 ++-- .../java/io/agrest/encoder/EncoderMethod.java | 4 ++-- .../agrest/encoder/EncoderObjectCondition.java | 4 ++-- .../io/agrest/encoder/EntityEncoderFilter.java | 4 ++-- .../encoder/EntityEncoderFilterBuilder.java | 4 ++-- .../io/agrest/encoder/FilterChainEncoder.java | 4 ++-- ...lectFilter.java => AllowAllReadFilter.java} | 8 ++++---- .../{SelectFilter.java => ReadFilter.java} | 10 +++++----- .../src/main/java/io/agrest/meta/AgEntity.java | 4 ++-- .../java/io/agrest/meta/AgEntityOverlay.java | 18 ++++++++++-------- .../java/io/agrest/meta/DefaultAgEntity.java | 12 ++++++------ .../main/java/io/agrest/meta/LazyAgEntity.java | 6 +++--- .../processor/select/FilterDataStage.java | 12 ++++++------ 20 files changed, 71 insertions(+), 69 deletions(-) rename agrest-cayenne/src/test/java/io/agrest/cayenne/{GET_SelectFilterIT.java => GET_ReadFilterIT.java} (93%) rename agrest-cayenne/src/test/java/io/agrest/cayenne/{GET_SelectFilter_EntityEncoderFilterIT.java => GET_ReadFilter_EntityEncoderFilterIT.java} (96%) rename agrest-engine/src/main/java/io/agrest/filter/{AllowAllSelectFilter.java => AllowAllReadFilter.java} (51%) rename agrest-engine/src/main/java/io/agrest/filter/{SelectFilter.java => ReadFilter.java} (63%) diff --git a/agrest-cayenne/src/main/java/io/agrest/cayenne/compiler/CayenneAgEntityBuilder.java b/agrest-cayenne/src/main/java/io/agrest/cayenne/compiler/CayenneAgEntityBuilder.java index 8ffee8881..c8468c9fd 100644 --- a/agrest-cayenne/src/main/java/io/agrest/cayenne/compiler/CayenneAgEntityBuilder.java +++ b/agrest-cayenne/src/main/java/io/agrest/cayenne/compiler/CayenneAgEntityBuilder.java @@ -1,7 +1,7 @@ package io.agrest.cayenne.compiler; import io.agrest.compiler.AnnotationsAgEntityBuilder; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import io.agrest.meta.AgAttribute; import io.agrest.meta.AgDataMap; import io.agrest.meta.AgEntity; @@ -205,7 +205,7 @@ protected AgEntity buildEntity() { rootDataResolver != null ? rootDataResolver : ThrowingRootDataResolver.getInstance(), // TODO: support Exp filters via annotations? - SelectFilter.allowsAllFilter()); + ReadFilter.allowsAllFilter()); } /** diff --git a/agrest-cayenne/src/test/java/io/agrest/cayenne/GET_SelectFilterIT.java b/agrest-cayenne/src/test/java/io/agrest/cayenne/GET_ReadFilterIT.java similarity index 93% rename from agrest-cayenne/src/test/java/io/agrest/cayenne/GET_SelectFilterIT.java rename to agrest-cayenne/src/test/java/io/agrest/cayenne/GET_ReadFilterIT.java index 881fd0e95..cb4e2f180 100644 --- a/agrest-cayenne/src/test/java/io/agrest/cayenne/GET_SelectFilterIT.java +++ b/agrest-cayenne/src/test/java/io/agrest/cayenne/GET_ReadFilterIT.java @@ -7,7 +7,7 @@ import io.agrest.cayenne.cayenne.main.E4; import io.agrest.cayenne.unit.AgCayenneTester; import io.agrest.cayenne.unit.DbTest; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import io.agrest.meta.AgEntity; import io.bootique.junit5.BQTestTool; import org.apache.cayenne.Cayenne; @@ -21,23 +21,23 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.UriInfo; -public class GET_SelectFilterIT extends DbTest { +public class GET_ReadFilterIT extends DbTest { @BQTestTool static final AgCayenneTester tester = tester(Resource.class) .entities(E2.class, E3.class, E4.class) .agCustomizer(ab -> ab - .entityOverlay(AgEntity.overlay(E2.class).selectFilter(evenFilter())) - .entityOverlay(AgEntity.overlay(E3.class).selectFilter(oddFilter())) - .entityOverlay(AgEntity.overlay(E4.class).selectFilter(evenFilter())) + .entityOverlay(AgEntity.overlay(E2.class).readFilter(evenFilter())) + .entityOverlay(AgEntity.overlay(E3.class).readFilter(oddFilter())) + .entityOverlay(AgEntity.overlay(E4.class).readFilter(evenFilter())) ) .build(); - static SelectFilter evenFilter() { + static ReadFilter evenFilter() { return o -> Cayenne.intPKForObject(o) % 2 == 0; } - static SelectFilter oddFilter() { + static ReadFilter oddFilter() { return o -> Cayenne.intPKForObject(o) % 2 != 0; } diff --git a/agrest-cayenne/src/test/java/io/agrest/cayenne/GET_SelectFilter_EntityEncoderFilterIT.java b/agrest-cayenne/src/test/java/io/agrest/cayenne/GET_ReadFilter_EntityEncoderFilterIT.java similarity index 96% rename from agrest-cayenne/src/test/java/io/agrest/cayenne/GET_SelectFilter_EntityEncoderFilterIT.java rename to agrest-cayenne/src/test/java/io/agrest/cayenne/GET_ReadFilter_EntityEncoderFilterIT.java index 00933faff..d9227dca3 100644 --- a/agrest-cayenne/src/test/java/io/agrest/cayenne/GET_SelectFilter_EntityEncoderFilterIT.java +++ b/agrest-cayenne/src/test/java/io/agrest/cayenne/GET_ReadFilter_EntityEncoderFilterIT.java @@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -public class GET_SelectFilter_EntityEncoderFilterIT extends DbTest { +public class GET_ReadFilter_EntityEncoderFilterIT extends DbTest { @BQTestTool static final AgCayenneTester tester = tester(Resource.class) @@ -36,8 +36,8 @@ public class GET_SelectFilter_EntityEncoderFilterIT extends DbTest { static EntityEncoderFilter evenFilter() { return EntityEncoderFilter .forEntity(E4.class) - .objectCondition(GET_SelectFilter_EntityEncoderFilterIT::willEncodeEven) - .encoder(GET_SelectFilter_EntityEncoderFilterIT::encodeEven) + .objectCondition(GET_ReadFilter_EntityEncoderFilterIT::willEncodeEven) + .encoder(GET_ReadFilter_EntityEncoderFilterIT::encodeEven) .build(); } diff --git a/agrest-engine/src/main/java/io/agrest/ResourceEntity.java b/agrest-engine/src/main/java/io/agrest/ResourceEntity.java index b12b05a74..f49a41980 100644 --- a/agrest-engine/src/main/java/io/agrest/ResourceEntity.java +++ b/agrest-engine/src/main/java/io/agrest/ResourceEntity.java @@ -3,7 +3,7 @@ import io.agrest.base.protocol.Exp; import io.agrest.base.protocol.Sort; import io.agrest.encoder.EntityEncoderFilter; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import io.agrest.meta.AgAttribute; import io.agrest.meta.AgEntity; @@ -229,12 +229,12 @@ public void setFetchLimit(int fetchLimit) { * @since 1.23 */ public boolean isFiltered() { - return !(entityEncoderFilters.isEmpty() && agEntity.getSelectFilter().allowsAll()); + return !(entityEncoderFilters.isEmpty() && agEntity.getReadFilter().allowsAll()); } /** * @since 3.4 - * @deprecated since 4.8 in favor of {@link SelectFilter}. + * @deprecated since 4.8 in favor of {@link ReadFilter}. */ @Deprecated public List getEntityEncoderFilters() { diff --git a/agrest-engine/src/main/java/io/agrest/SelectBuilder.java b/agrest-engine/src/main/java/io/agrest/SelectBuilder.java index b72a422c0..90eb1b7fa 100644 --- a/agrest-engine/src/main/java/io/agrest/SelectBuilder.java +++ b/agrest-engine/src/main/java/io/agrest/SelectBuilder.java @@ -3,7 +3,7 @@ import io.agrest.constraints.Constraint; import io.agrest.encoder.Encoder; import io.agrest.encoder.EntityEncoderFilter; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import io.agrest.filter.PropertyFilter; import io.agrest.meta.AgEntity; import io.agrest.meta.AgEntityOverlay; @@ -46,7 +46,7 @@ public interface SelectBuilder { * @return this builder instance * @see AgBuilder#entityEncoderFilter(EntityEncoderFilter) * @since 3.4 - * @deprecated since 4.8 in favor of {@link #filter(Class, SelectFilter)}. + * @deprecated since 4.8 in favor of {@link #filter(Class, ReadFilter)}. */ @Deprecated SelectBuilder entityEncoderFilter(EntityEncoderFilter filter); @@ -117,8 +117,8 @@ default SelectBuilder propFilter(Class entityType, PropertyFilter filt * @return this builder instance * @since 4.8 */ - default SelectBuilder filter(Class entityType, SelectFilter filter) { - return entityOverlay(AgEntity.overlay(entityType).selectFilter(filter)); + default SelectBuilder filter(Class entityType, ReadFilter filter) { + return entityOverlay(AgEntity.overlay(entityType).readFilter(filter)); } /** diff --git a/agrest-engine/src/main/java/io/agrest/compiler/AnnotationsAgEntityBuilder.java b/agrest-engine/src/main/java/io/agrest/compiler/AnnotationsAgEntityBuilder.java index 8467862ca..4f3b420ce 100644 --- a/agrest-engine/src/main/java/io/agrest/compiler/AnnotationsAgEntityBuilder.java +++ b/agrest-engine/src/main/java/io/agrest/compiler/AnnotationsAgEntityBuilder.java @@ -5,7 +5,7 @@ import io.agrest.annotation.AgRelationship; import io.agrest.base.reflect.BeanAnalyzer; import io.agrest.base.reflect.PropertyGetter; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import io.agrest.meta.*; import io.agrest.resolver.ReaderBasedResolver; import io.agrest.resolver.RootDataResolver; @@ -209,7 +209,7 @@ protected AgEntity buildEntity() { rootDataResolver != null ? rootDataResolver : ThrowingRootDataResolver.getInstance(), // TODO: support Exp filters via annotations? - SelectFilter.allowsAllFilter()); + ReadFilter.allowsAllFilter()); } /** diff --git a/agrest-engine/src/main/java/io/agrest/encoder/CompositeEntityEncoderFilter.java b/agrest-engine/src/main/java/io/agrest/encoder/CompositeEntityEncoderFilter.java index 3288a2b57..8b9deface 100644 --- a/agrest-engine/src/main/java/io/agrest/encoder/CompositeEntityEncoderFilter.java +++ b/agrest-engine/src/main/java/io/agrest/encoder/CompositeEntityEncoderFilter.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import io.agrest.ResourceEntity; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import java.io.IOException; @@ -10,7 +10,7 @@ * Encoder filter that delegates individual encoder methods to custom functions. * * @since 3.4 - * @deprecated since 4.8 in favor of {@link SelectFilter}. + * @deprecated since 4.8 in favor of {@link ReadFilter}. */ @Deprecated class CompositeEntityEncoderFilter implements EntityEncoderFilter { diff --git a/agrest-engine/src/main/java/io/agrest/encoder/EncoderEntityCondition.java b/agrest-engine/src/main/java/io/agrest/encoder/EncoderEntityCondition.java index 2b829f40c..9fda9417f 100644 --- a/agrest-engine/src/main/java/io/agrest/encoder/EncoderEntityCondition.java +++ b/agrest-engine/src/main/java/io/agrest/encoder/EncoderEntityCondition.java @@ -1,11 +1,11 @@ package io.agrest.encoder; import io.agrest.ResourceEntity; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; /** * @since 3.4 - * @deprecated since 4.8 in favor of {@link SelectFilter}. + * @deprecated since 4.8 in favor of {@link ReadFilter}. */ @Deprecated @FunctionalInterface diff --git a/agrest-engine/src/main/java/io/agrest/encoder/EncoderMethod.java b/agrest-engine/src/main/java/io/agrest/encoder/EncoderMethod.java index 30e1a75fb..9332f8035 100644 --- a/agrest-engine/src/main/java/io/agrest/encoder/EncoderMethod.java +++ b/agrest-engine/src/main/java/io/agrest/encoder/EncoderMethod.java @@ -1,14 +1,14 @@ package io.agrest.encoder; import com.fasterxml.jackson.core.JsonGenerator; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import java.io.IOException; /** * @param * @since 3.4 - * @deprecated since 4.8 in favor of {@link SelectFilter}. + * @deprecated since 4.8 in favor of {@link ReadFilter}. */ @Deprecated @FunctionalInterface diff --git a/agrest-engine/src/main/java/io/agrest/encoder/EncoderObjectCondition.java b/agrest-engine/src/main/java/io/agrest/encoder/EncoderObjectCondition.java index 9ba951767..d624a1a86 100644 --- a/agrest-engine/src/main/java/io/agrest/encoder/EncoderObjectCondition.java +++ b/agrest-engine/src/main/java/io/agrest/encoder/EncoderObjectCondition.java @@ -1,11 +1,11 @@ package io.agrest.encoder; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; /** * @param * @since 3.4 - * @deprecated since 4.8 in favor of {@link SelectFilter}. + * @deprecated since 4.8 in favor of {@link ReadFilter}. */ @Deprecated @FunctionalInterface diff --git a/agrest-engine/src/main/java/io/agrest/encoder/EntityEncoderFilter.java b/agrest-engine/src/main/java/io/agrest/encoder/EntityEncoderFilter.java index a34cb9691..805e5ca08 100644 --- a/agrest-engine/src/main/java/io/agrest/encoder/EntityEncoderFilter.java +++ b/agrest-engine/src/main/java/io/agrest/encoder/EntityEncoderFilter.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import io.agrest.ResourceEntity; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import java.io.IOException; @@ -10,7 +10,7 @@ * An interceptor for custom encoding of specific entities. An application may define a filter that suppresses * certain objects based on security constraints, or may provide a custom encoder for a given object, etc. * - * @deprecated since 4.8 in favor of {@link SelectFilter}. + * @deprecated since 4.8 in favor of {@link ReadFilter}. */ @Deprecated public interface EntityEncoderFilter { diff --git a/agrest-engine/src/main/java/io/agrest/encoder/EntityEncoderFilterBuilder.java b/agrest-engine/src/main/java/io/agrest/encoder/EntityEncoderFilterBuilder.java index 71668a9f0..999b174c5 100644 --- a/agrest-engine/src/main/java/io/agrest/encoder/EntityEncoderFilterBuilder.java +++ b/agrest-engine/src/main/java/io/agrest/encoder/EntityEncoderFilterBuilder.java @@ -1,6 +1,6 @@ package io.agrest.encoder; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import java.util.Objects; @@ -8,7 +8,7 @@ * A helper class to build EntityEncoderFilters. Usually created via static methods on {@link EntityEncoderFilter}. * * @since 3.4 - * @deprecated since 4.8 in favor of {@link SelectFilter}. + * @deprecated since 4.8 in favor of {@link ReadFilter}. */ @Deprecated public class EntityEncoderFilterBuilder { diff --git a/agrest-engine/src/main/java/io/agrest/encoder/FilterChainEncoder.java b/agrest-engine/src/main/java/io/agrest/encoder/FilterChainEncoder.java index da7bb4895..ba4ed4984 100644 --- a/agrest-engine/src/main/java/io/agrest/encoder/FilterChainEncoder.java +++ b/agrest-engine/src/main/java/io/agrest/encoder/FilterChainEncoder.java @@ -1,7 +1,7 @@ package io.agrest.encoder; import com.fasterxml.jackson.core.JsonGenerator; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import java.io.IOException; import java.util.List; @@ -10,7 +10,7 @@ * An encoder that passes encoding request through a chain of {@link EntityEncoderFilter} filters before it gets to the real * Encoder. * - * @deprecated since 4.8 in favor of {@link SelectFilter}. + * @deprecated since 4.8 in favor of {@link ReadFilter}. */ @Deprecated public class FilterChainEncoder implements Encoder { diff --git a/agrest-engine/src/main/java/io/agrest/filter/AllowAllSelectFilter.java b/agrest-engine/src/main/java/io/agrest/filter/AllowAllReadFilter.java similarity index 51% rename from agrest-engine/src/main/java/io/agrest/filter/AllowAllSelectFilter.java rename to agrest-engine/src/main/java/io/agrest/filter/AllowAllReadFilter.java index 2101d5ad3..857a288c1 100644 --- a/agrest-engine/src/main/java/io/agrest/filter/AllowAllSelectFilter.java +++ b/agrest-engine/src/main/java/io/agrest/filter/AllowAllReadFilter.java @@ -3,11 +3,11 @@ /** * @since 4.8 */ -final class AllowAllSelectFilter implements SelectFilter { +final class AllowAllReadFilter implements ReadFilter { - static final AllowAllSelectFilter instance = new AllowAllSelectFilter<>(); + static final AllowAllReadFilter instance = new AllowAllReadFilter<>(); - private AllowAllSelectFilter() { + private AllowAllReadFilter() { } @Override @@ -21,7 +21,7 @@ public boolean allowsAll() { } @Override - public SelectFilter andThen(SelectFilter another) { + public ReadFilter andThen(ReadFilter another) { return another; } } diff --git a/agrest-engine/src/main/java/io/agrest/filter/SelectFilter.java b/agrest-engine/src/main/java/io/agrest/filter/ReadFilter.java similarity index 63% rename from agrest-engine/src/main/java/io/agrest/filter/SelectFilter.java rename to agrest-engine/src/main/java/io/agrest/filter/ReadFilter.java index c4be3c3c9..9ff875dc3 100644 --- a/agrest-engine/src/main/java/io/agrest/filter/SelectFilter.java +++ b/agrest-engine/src/main/java/io/agrest/filter/ReadFilter.java @@ -1,15 +1,15 @@ package io.agrest.filter; /** - * A filter of objects that defines an access policy for a given entity. + * Per-entity filter used to implement object READ access policies. * * @since 4.8 */ @FunctionalInterface -public interface SelectFilter { +public interface ReadFilter { - static SelectFilter allowsAllFilter() { - return AllowAllSelectFilter.instance; + static ReadFilter allowsAllFilter() { + return AllowAllReadFilter.instance; } boolean isAllowed(T object); @@ -21,7 +21,7 @@ default boolean allowsAll() { return false; } - default SelectFilter andThen(SelectFilter another) { + default ReadFilter andThen(ReadFilter another) { if (another.allowsAll()) { return this; } diff --git a/agrest-engine/src/main/java/io/agrest/meta/AgEntity.java b/agrest-engine/src/main/java/io/agrest/meta/AgEntity.java index 31f308c7f..7b17d6974 100644 --- a/agrest-engine/src/main/java/io/agrest/meta/AgEntity.java +++ b/agrest-engine/src/main/java/io/agrest/meta/AgEntity.java @@ -1,6 +1,6 @@ package io.agrest.meta; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import io.agrest.property.PropertyReader; import io.agrest.resolver.RootDataResolver; @@ -80,5 +80,5 @@ default PropertyReader getIdReader() { * * @since 4.8 */ - SelectFilter getSelectFilter(); + ReadFilter getReadFilter(); } diff --git a/agrest-engine/src/main/java/io/agrest/meta/AgEntityOverlay.java b/agrest-engine/src/main/java/io/agrest/meta/AgEntityOverlay.java index 25d2737c4..2bab761e5 100644 --- a/agrest-engine/src/main/java/io/agrest/meta/AgEntityOverlay.java +++ b/agrest-engine/src/main/java/io/agrest/meta/AgEntityOverlay.java @@ -1,6 +1,6 @@ package io.agrest.meta; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import io.agrest.filter.PropertyFilteringRulesBuilder; import io.agrest.filter.PropertyFilter; import io.agrest.property.PropertyReader; @@ -34,13 +34,13 @@ public class AgEntityOverlay { private PropertyFilter readablePropFilter; private PropertyFilter writablePropFilter; - private SelectFilter selectFilter; + private ReadFilter readFilter; public AgEntityOverlay(Class type) { this.type = type; this.attributes = new HashMap<>(); this.relationships = new HashMap<>(); - this.selectFilter = SelectFilter.allowsAllFilter(); + this.readFilter = ReadFilter.allowsAllFilter(); } private static PropertyReader fromFunction(Function f) { @@ -95,7 +95,7 @@ public AgEntity resolve(AgDataMap agDataMap, AgEntity maybeOverlaid) { resolver.attributes, resolver.relationships, rootDataResolver != null ? rootDataResolver : maybeOverlaid.getDataResolver(), - maybeOverlaid.getSelectFilter().andThen(selectFilter) + maybeOverlaid.getReadFilter().andThen(readFilter) ); } @@ -104,7 +104,7 @@ private boolean isEmpty() { && relationships.isEmpty() && readablePropFilter == null && writablePropFilter == null - && selectFilter == null; + && readFilter == null; } /** @@ -130,7 +130,7 @@ public AgEntityOverlay merge(AgEntityOverlay anotherOverlay) { this.rootDataResolver = anotherOverlay.getRootDataResolver(); } - this.selectFilter = this.selectFilter.andThen(anotherOverlay.selectFilter); + this.readFilter = this.readFilter.andThen(anotherOverlay.readFilter); return this; } @@ -195,10 +195,12 @@ public AgEntityOverlay writablePropFilter(PropertyFilter filter) { } /** + * Adds an object READ filter to the existing filters. + * * @since 4.8 */ - public AgEntityOverlay selectFilter(SelectFilter filter) { - this.selectFilter = this.selectFilter.andThen(filter); + public AgEntityOverlay readFilter(ReadFilter filter) { + this.readFilter = this.readFilter.andThen(filter); return this; } diff --git a/agrest-engine/src/main/java/io/agrest/meta/DefaultAgEntity.java b/agrest-engine/src/main/java/io/agrest/meta/DefaultAgEntity.java index 79b15ec5b..321abf262 100644 --- a/agrest-engine/src/main/java/io/agrest/meta/DefaultAgEntity.java +++ b/agrest-engine/src/main/java/io/agrest/meta/DefaultAgEntity.java @@ -1,6 +1,6 @@ package io.agrest.meta; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import io.agrest.resolver.RootDataResolver; import java.util.Collection; @@ -14,7 +14,7 @@ public class DefaultAgEntity implements AgEntity { private final String name; private final Class type; private final RootDataResolver dataResolver; - private final SelectFilter selectFilter; + private final ReadFilter readFilter; // TODO: ensure name uniqueness between all types of properties private final Map ids; @@ -28,7 +28,7 @@ public DefaultAgEntity( Map attributes, Map relationships, RootDataResolver dataResolver, - SelectFilter selectFilter) { + ReadFilter readFilter) { this.name = name; this.type = type; @@ -36,7 +36,7 @@ public DefaultAgEntity( this.attributes = attributes; this.relationships = relationships; this.dataResolver = dataResolver; - this.selectFilter = selectFilter; + this.readFilter = readFilter; } @Override @@ -85,8 +85,8 @@ public RootDataResolver getDataResolver() { } @Override - public SelectFilter getSelectFilter() { - return selectFilter; + public ReadFilter getReadFilter() { + return readFilter; } @Override diff --git a/agrest-engine/src/main/java/io/agrest/meta/LazyAgEntity.java b/agrest-engine/src/main/java/io/agrest/meta/LazyAgEntity.java index acef6e6c4..57ff97175 100644 --- a/agrest-engine/src/main/java/io/agrest/meta/LazyAgEntity.java +++ b/agrest-engine/src/main/java/io/agrest/meta/LazyAgEntity.java @@ -1,6 +1,6 @@ package io.agrest.meta; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import io.agrest.resolver.RootDataResolver; import java.util.Collection; @@ -64,7 +64,7 @@ public RootDataResolver getDataResolver() { } @Override - public SelectFilter getSelectFilter() { - return getDelegate().getSelectFilter(); + public ReadFilter getReadFilter() { + return getDelegate().getReadFilter(); } } diff --git a/agrest-engine/src/main/java/io/agrest/runtime/processor/select/FilterDataStage.java b/agrest-engine/src/main/java/io/agrest/runtime/processor/select/FilterDataStage.java index a2f4a2144..16e9af289 100644 --- a/agrest-engine/src/main/java/io/agrest/runtime/processor/select/FilterDataStage.java +++ b/agrest-engine/src/main/java/io/agrest/runtime/processor/select/FilterDataStage.java @@ -6,7 +6,7 @@ import io.agrest.RootResourceEntity; import io.agrest.ToManyResourceEntity; import io.agrest.ToOneResourceEntity; -import io.agrest.filter.SelectFilter; +import io.agrest.filter.ReadFilter; import io.agrest.processor.Processor; import io.agrest.processor.ProcessorOutcome; @@ -30,7 +30,7 @@ protected void doExecute(SelectContext context) { } protected void filterRoot(RootResourceEntity entity) { - SelectFilter filter = entity.getAgEntity().getSelectFilter(); + ReadFilter filter = entity.getAgEntity().getReadFilter(); if (!filter.allowsAll() && !entity.getResult().isEmpty()) { // replacing the list to avoid messing up possible data source caches, and also @@ -53,7 +53,7 @@ protected void filterChildren(ResourceEntity entity) { protected void filterToOne(ToOneResourceEntity entity) { - SelectFilter filter = entity.getAgEntity().getSelectFilter(); + ReadFilter filter = entity.getAgEntity().getReadFilter(); if (!filter.allowsAll() && !entity.getResultsByParent().isEmpty()) { // filter the map in place - key removal should be fast @@ -65,7 +65,7 @@ protected void filterToOne(ToOneResourceEntity entity) { protected void filterToMany(ToManyResourceEntity entity) { - SelectFilter filter = entity.getAgEntity().getSelectFilter(); + ReadFilter filter = entity.getAgEntity().getReadFilter(); if (!filter.allowsAll() && !entity.getResultsByParent().isEmpty()) { // Filter the map in place; @@ -79,7 +79,7 @@ protected void filterToMany(ToManyResourceEntity entity) { filterChildren(entity); } - static List filterList(List unfiltered, SelectFilter filter) { + static List filterList(List unfiltered, ReadFilter filter) { int len = unfiltered.size(); for (int i = 0; i < len; i++) { @@ -94,7 +94,7 @@ static List filterList(List unfiltered, SelectFilter filter) { return unfiltered; } - static List filterListByCopy(List unfiltered, SelectFilter filter, int firstExcluded) { + static List filterListByCopy(List unfiltered, ReadFilter filter, int firstExcluded) { int len = unfiltered.size(); List filtered = new ArrayList<>(len - 1);