I have a problem customizing the reperesentation of ListChanges in javers:
Given two structures:
@Entity
public class User {
private Long id;
....
@OneToMany
private List<Authorisation> authorisations;
}
and
@Entity
public class Authorisation {
@Id
private Long id;
...
private String name;
private String scope;
private String asset;
@Override
public String toString() {
return name + " " + scope + ": " + asset;
}
}
i want to display ListChanges of Authorisation
s in a more human readable form when querying for a user who's authorisations changed. When im querying now:
QueryBuilder jqlQuery = QueryBuilder.byInstance(repo.findByUserId(userId));
List<Change> changes = javers.findChanges(jqlQuery.withChildValueObjects().build());
....
javers.getJsonConverter().toJson(changes.get(0))
// or
changes.get(0).toString()
i get results like this for the ListChanges:
{
"changeType": "ListChange",
...
"property": "authorisations",
"propertyChangeType": "PROPERTY_VALUE_CHANGED",
"elementChanges": [
{
"elementChangeType": "ValueAdded",
"index": 0,
"value": {
"entity": "....Authorisation",
"cdoId": 1
}
}
]
}
or
ListChange{ 'authorisations' collection changes :
0. '...Authorisation/1' added }
i now want to render the Authorisation
in a more human readable form like using the toString()
method from Authorisation
so that the output looks like
ListChange{ 'authorisations' collection changes :
0. '...Authorisation/abc def ghi' added }
I hope anyone has an idea, so thanks in advance.