fix issue with users returned as empty array, add researchers in response

This commit is contained in:
Bernaldo Mihasi 2023-03-07 09:44:16 +02:00
parent 34176bcb70
commit 519cb260c6
3 changed files with 21 additions and 6 deletions

View File

@ -25,7 +25,12 @@ import java.util.stream.Collectors;
name = "fullyDetailed", name = "fullyDetailed",
attributeNodes = { attributeNodes = {
@NamedAttributeNode("grant"), @NamedAttributeNode("profile"), @NamedAttributeNode("grant"), @NamedAttributeNode("profile"),
@NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}), @NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")
},
subgraphs = {
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")})
}
),
@NamedEntityGraph( @NamedEntityGraph(
name = "dmpRecentActivity", name = "dmpRecentActivity",
attributeNodes = { attributeNodes = {

View File

@ -47,6 +47,7 @@ public class PublicDmpsDocumentation extends BaseController {
"4.6. version: integer, version of dmp\n" + "4.6. version: integer, version of dmp\n" +
"4.7. groupId: uuid, group id in which dmp belongs\n" + "4.7. groupId: uuid, group id in which dmp belongs\n" +
"4.8. users: list of UserInfoPublicModel, user who collaborated on the dmp\n" + "4.8. users: list of UserInfoPublicModel, user who collaborated on the dmp\n" +
"4.9. researchers: list of ResearcherPublicModel, researchers involved in the dmp\n" +
"4.9. finalizedAt: date, finalization date\n" + "4.9. finalizedAt: date, finalization date\n" +
"4.10. publishedAt: date, publication date\n"; "4.10. publishedAt: date, publication date\n";
private static final String getPagedResponseExample = "{\n" + private static final String getPagedResponseExample = "{\n" +

View File

@ -3,12 +3,10 @@ package eu.eudat.publicapi.models.listingmodels;
import eu.eudat.data.entities.DMP; import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Grant; import eu.eudat.data.entities.Grant;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.publicapi.models.researcher.ResearcherPublicModel;
import eu.eudat.publicapi.models.user.UserInfoPublicModel; import eu.eudat.publicapi.models.user.UserInfoPublicModel;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class DataManagementPlanPublicListingModel implements DataModel<DMP, DataManagementPlanPublicListingModel> { public class DataManagementPlanPublicListingModel implements DataModel<DMP, DataManagementPlanPublicListingModel> {
@ -20,6 +18,7 @@ public class DataManagementPlanPublicListingModel implements DataModel<DMP, Data
private int version; private int version;
private UUID groupId; private UUID groupId;
private List<UserInfoPublicModel> users; private List<UserInfoPublicModel> users;
private List<ResearcherPublicModel> researchers;
private Date finalizedAt; private Date finalizedAt;
private Date publishedAt; private Date publishedAt;
@ -79,6 +78,13 @@ public class DataManagementPlanPublicListingModel implements DataModel<DMP, Data
this.users = users; this.users = users;
} }
public List<ResearcherPublicModel> getResearchers() {
return researchers;
}
public void setResearchers(List<ResearcherPublicModel> researchers) {
this.researchers = researchers;
}
public Date getFinalizedAt() { public Date getFinalizedAt() {
return finalizedAt; return finalizedAt;
} }
@ -125,9 +131,11 @@ public class DataManagementPlanPublicListingModel implements DataModel<DMP, Data
this.modifiedAt = entity.getModified(); this.modifiedAt = entity.getModified();
try { try {
this.users = entity.getUsers() != null ? entity.getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>(); this.users = entity.getUsers() != null ? entity.getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().map(x -> new ResearcherPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
} }
catch(Exception ex){ catch(Exception ex){
this.users = new ArrayList<>(); this.users = new ArrayList<>();
this.researchers = new ArrayList<>();
} }
this.finalizedAt = entity.getFinalizedAt(); this.finalizedAt = entity.getFinalizedAt();
this.publishedAt = entity.getPublishedAt(); this.publishedAt = entity.getPublishedAt();
@ -151,11 +159,12 @@ public class DataManagementPlanPublicListingModel implements DataModel<DMP, Data
grant.setLabel(this.getGrant()); grant.setLabel(this.getGrant());
entity.setGrant(grant); entity.setGrant(grant);
entity.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet())); entity.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet()));
entity.setResearchers(this.getResearchers().stream().map(ResearcherPublicModel::toDataModel).collect(Collectors.toSet()));
return entity; return entity;
} }
@Override @Override
public String getHint() { public String getHint() {
return "dataManagementPlanListingModel"; return "fullyDetailed";
} }
} }