Skip to content

Commit 5ba8994

Browse files
committed
PR feedback
1 parent 6fa7a5c commit 5ba8994

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

contentgrid-appserver-application-model/src/main/java/com/contentgrid/appserver/application/model/Application.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.contentgrid.appserver.application.model.searchfilters.AttributeSearchFilter;
1111
import com.contentgrid.appserver.application.model.values.ApplicationName;
1212
import com.contentgrid.appserver.application.model.values.AttributeName;
13+
import com.contentgrid.appserver.application.model.values.AttributePath;
1314
import com.contentgrid.appserver.application.model.values.EntityName;
1415
import com.contentgrid.appserver.application.model.values.LinkName;
1516
import com.contentgrid.appserver.application.model.values.PathSegmentName;
@@ -238,7 +239,7 @@ private void validateEntitySearchFilters(Entity entity) {
238239
entity.getSearchFilters().forEach(searchFilter -> {
239240
if (searchFilter instanceof AttributeSearchFilter attributeSearchFilter) {
240241
try {
241-
var resolvedAttribute = resolveAttributePath(entity, attributeSearchFilter.getAttributePath());
242+
var resolvedAttribute = resolvePropertyPath(entity, attributeSearchFilter.getAttributePath());
242243
if (resolvedAttribute.getType() != attributeSearchFilter.getAttributeType()) {
243244
throw new InvalidArgumentModelException(
244245
"SearchFilter %s does not match the type of attribute %s (%s != %s)".formatted(
@@ -253,7 +254,7 @@ private void validateEntitySearchFilters(Entity entity) {
253254
});
254255
}
255256

256-
private SimpleAttribute resolveAttributePath(Entity entity, PropertyPath path) {
257+
private SimpleAttribute resolvePropertyPath(Entity entity, PropertyPath path) {
257258
Entity currentEntity = entity;
258259
PropertyPath currentPath = path;
259260

@@ -263,7 +264,7 @@ private SimpleAttribute resolveAttributePath(Entity entity, PropertyPath path) {
263264
switch (name) {
264265
case AttributeName ignored -> {
265266
// When we hit an attribute, validate the remaining path via the current entity
266-
return currentEntity.resolveAttributePath(currentPath);
267+
return currentEntity.resolveAttributePath((AttributePath) currentPath);
267268
}
268269
case RelationName relationName -> {
269270
final String entityName = currentEntity.getName().getValue(); // Make final for lambda

contentgrid-appserver-application-model/src/main/java/com/contentgrid/appserver/application/model/Entity.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,8 @@ private static List<ContentAttribute> getContentAttributes(List<Attribute> attri
254254
return result;
255255
}
256256

257-
public SimpleAttribute resolveAttributePath(@NonNull PropertyPath attributePath) {
258-
return switch (attributePath) {
259-
case AttributePath attrPath -> resolveAttributePath(this, attrPath);
260-
case RelationPath ignored -> throw new UnsupportedOperationException("Can't resolve paths across relations"
261-
+ " from the Entity, try via Application instead.");
262-
};
257+
public SimpleAttribute resolveAttributePath(@NonNull AttributePath attributePath) {
258+
return resolveAttributePath(this, attributePath);
263259
}
264260

265261
private static SimpleAttribute resolveAttributePath(@NonNull HasAttributes container, @NonNull AttributePath attributePath) {

contentgrid-appserver-domain/src/main/java/com/contentgrid/appserver/domain/ThunkExpressionGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.contentgrid.appserver.application.model.searchfilters.ExactSearchFilter;
99
import com.contentgrid.appserver.application.model.searchfilters.SearchFilter;
1010
import com.contentgrid.appserver.application.model.values.AttributeName;
11+
import com.contentgrid.appserver.application.model.values.AttributePath;
1112
import com.contentgrid.appserver.application.model.values.FilterName;
1213
import com.contentgrid.appserver.application.model.values.PropertyName;
1314
import com.contentgrid.appserver.application.model.values.PropertyPath;
@@ -109,7 +110,7 @@ private static Stream<PathElement> convertPath(Application application, Entity e
109110
case AttributeName ignored -> {
110111
// If the remaining path is just (composite) attributes, validate the path via the current entity
111112
// This throws if there is an invalid link
112-
currentEntity.resolveAttributePath(currentPath);
113+
currentEntity.resolveAttributePath((AttributePath) currentPath);
113114

114115
// Convert the rest of the path using toList()
115116
return Stream.concat(

0 commit comments

Comments
 (0)