-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't throw exception when encountering invalid query terms (#1541)
* Don't throw exception when encountering invalid query terms * Order map entries * Factor out PropertyLike (#1543) --------- Co-authored-by: Olov Ylinenpää <[email protected]>
- Loading branch information
Showing
8 changed files
with
62 additions
and
29 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
whelk-core/src/main/groovy/whelk/search2/querytree/InvalidKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package whelk.search2.querytree; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import static whelk.JsonLd.TYPE_KEY; | ||
|
||
public sealed interface InvalidKey extends PropertyLike { | ||
record UnrecognizedKey(String name) implements InvalidKey {} | ||
record AmbiguousKey(String name) implements InvalidKey {} | ||
|
||
default Map<String, Object> definition() { | ||
var m = new LinkedHashMap<String, Object>(); | ||
m.put(TYPE_KEY, "_Invalid"); | ||
m.put("label", name()); | ||
return m; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
whelk-core/src/main/groovy/whelk/search2/querytree/InvalidValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package whelk.search2.querytree; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import static whelk.JsonLd.TYPE_KEY; | ||
|
||
sealed interface InvalidValue extends Value { | ||
record ForbiddenValue(String string) implements InvalidValue {} | ||
record AmbiguousValue(String string) implements InvalidValue {} | ||
|
||
@Override | ||
String string(); | ||
|
||
@Override | ||
default Object description() { | ||
var m = new LinkedHashMap<String, Object>(); | ||
m.put(TYPE_KEY, "_Invalid"); | ||
m.put("label", string()); | ||
return m; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
whelk-core/src/main/groovy/whelk/search2/querytree/PropertyLike.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package whelk.search2.querytree; | ||
|
||
import java.util.Map; | ||
|
||
public interface PropertyLike { | ||
String name(); | ||
Map<String, Object> definition(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters