Replies: 2 comments 1 reply
-
Yeah, it's pretty simple to do that with array expressions like this: @EntityView(Example.class)
interface ExampleView {
String getName();
@Mapping("statusUpdates[status = fully.qualified.name.Status.STATUS_A]")
StatusUpdate getStatusA();
@Mapping("statusUpdates[status = fully.qualified.name.Status.STATUS_X]")
StatusUpdate getStatusX();
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply, that helped a lot. Got a bit further.
But I couldn't use a direct reference to the actual enum-reference. Although our Model is a bit more complex, as we are not using simple enums but actual database entries reflecting the different status. There is a enum with references to the matching key, but I cant use this in the expression. So follwing did not work, even if I used the full qualifier:
One more question: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to build an entity view with fields that reference dedicated/filtered entries of a mapped collection?
Say we have an entity with some simple fields and a list of status updates. Over time that list gets filled with more and more status updates.
We now want an overview of the entities with a subset of fields and dedicated fields for some specific status updates that we are interested in.
If an entities status list contains these status updates already, the respective field will be set, otherwise it is null.
See this example and the EntityView we would like to have:
Is that somehow possible with blaze persistance to setup fields that reference items of a collection (if existing) based in specified criteria?
We played around with filtering, but did not get it to work to map specific status updates to single fields.
What we did get to work is a ViewFilterProvider where we select all the status updates we are interested in and map it to a whole list of Status updates.
So we end up with one list again, but at least it contains only the desired status updates which we can process manually later.
and applying:
setting.addViewFilter("statusFilter");
However that has (at least) one issue: Entities that dont have any of the desired status updates at all will be left out of the result. Not good.
As a workaround we added a (initial) status that all entities have anyway to the filter, although we wont need it later.
Are there any other ways to do it?
Thanks and regards,
Christian
Beta Was this translation helpful? Give feedback.
All reactions