-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: IDS catalog request filtering #2015
feat: IDS catalog request filtering #2015
Conversation
3f52c53
to
e9b8161
Compare
Codecov ReportBase: 63.73% // Head: 64.33% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2015 +/- ##
==========================================
+ Coverage 63.73% 64.33% +0.60%
==========================================
Files 772 780 +8
Lines 16370 16537 +167
Branches 1055 1076 +21
==========================================
+ Hits 10433 10639 +206
+ Misses 5494 5448 -46
- Partials 443 450 +7
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
e9b8161
to
5da9a9e
Compare
5da9a9e
to
b4ee3d5
Compare
...ct/src/main/java/org/eclipse/dataspaceconnector/contract/offer/ContractOfferServiceImpl.java
Show resolved
Hide resolved
...s-core/src/main/java/org/eclipse/dataspaceconnector/ids/core/service/CatalogServiceImpl.java
Outdated
Show resolved
Hide resolved
...java/org/eclipse/dataspaceconnector/ids/api/multipart/handler/DescriptionRequestHandler.java
Outdated
Show resolved
Hide resolved
...ector/ids/api/multipart/dispatcher/sender/type/MultipartCatalogDescriptionRequestSender.java
Outdated
Show resolved
Hide resolved
9f4132d
to
650620b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests for this new feature. At the very minimum the ContractOfferServiceImplTest
needs to be extended. New functionality should always be accompanied by additional tests.
Also, please use var
wherever possible, and make use of fluent statements, e.g. with Builders.
.orElse(defaultValue); | ||
|
||
public static QuerySpec getQuerySpec(@NotNull DescriptionRequestMessage message) { | ||
Map specsMap = (Map) ofNullable(message.getProperties()).map(map -> map.get(QuerySpec.QUERY_SPEC)).orElse(Map.of()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PLease use var
and inline the next few lines. We have implemented fluency for a reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
public long getLimit() { | ||
return limit; | ||
public Range getDefinitionsRange() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as stated before, please rename to range
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
b536c23
to
a58cea0
Compare
...rc/test/java/org/eclipse/dataspaceconnector/contract/offer/ContractOfferServiceImplTest.java
Outdated
Show resolved
Hide resolved
...rc/test/java/org/eclipse/dataspaceconnector/contract/offer/ContractOfferServiceImplTest.java
Show resolved
Hide resolved
*/ | ||
public static int getInt(@NotNull DescriptionRequestMessage message, String propertyName, int defaultValue) { | ||
public static QuerySpec getQuerySpec(@NotNull DescriptionRequestMessage message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method needs to be changed. Currently it deserialized the queryspec field into another Map
, only to obtain just the RANGE
and FILTER_EXPRESSION
parameters from it. That is
- incorrect, because it ignores the sort field and -order
- not necessary, because you could've just deserialized the
QuerySpec
.
Let's not waste any more time, so here's the working solution:
return ofNullable(message.getProperties())
.map(map -> map.get(QuerySpec.QUERY_SPEC))
.map(specEntry -> objectMapper.convertValue(specEntry, QuerySpec.class))
.orElse(QuerySpec.none());
The objectMapper
must be obtained from the runtime wide TypeManager
, and QuerySpec#getRange()
must be annotated with @JsonIgnore
as it is computed property.
You clearly have not tested this, or even tried it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ad 1) supporting sort field and order is not in the scope of this change - I wanted to keep it to minimum.
ad 2) you are right, I was just not aware of possibility to use ObjectMapper here - my bad, should've asked/checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no reason why we would on purpose limit the capability and at the same time increase the impact on the code base. That is the reason why I repeatedly asked to use a QuerySpec
and not singular range
and filter
fields. The QuerySpec
was designed for that purpose.
...pi/src/main/java/org/eclipse/dataspaceconnector/spi/types/domain/catalog/CatalogRequest.java
Outdated
Show resolved
Hide resolved
@@ -29,6 +29,12 @@ | |||
* is tunnelled through to the database level. | |||
*/ | |||
public class QuerySpec { | |||
|
|||
public static final String QUERY_SPEC = "querySpec"; | |||
public static final String FILTER_EXPRESSION = "filterExpression"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These constants (except QUERY_SPEC
) are only used in the DescriptionRequestHandlerTest
. Please move them out of the production code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add tests for the RequestUtil#getQuerySpec
, then we should be good to go.
58eb3be
to
4a98a77
Compare
What this PR changes/adds
Extend existing CatalogRequest object with list of criteria used to filter Assets within Catalog response.
Why it does that
In a large scale environment, with multiple EDCs holding the information about hundreds of thousands of Assets, instead of looping thought all of the ContractOffers, there is a need to narrow the results down to even single offer. For example, an Asset might hold the 'special' type of data (like registry or database) and should be searchable by its type.
Linked Issue(s)
Closes #1966
Checklist
no-changelog
)