Minor changes to Recent Activity Model

This commit is contained in:
George Kalampokis 2020-07-03 10:43:54 +03:00
parent b57f6fb73c
commit 71279a716e
3 changed files with 26 additions and 20 deletions

View File

@ -1,6 +1,9 @@
package eu.eudat.models.data.dashboard.recent.model; package eu.eudat.models.data.dashboard.recent.model;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import java.util.Date; import java.util.Date;
import java.util.List;
public abstract class RecentActivityModel<T> { public abstract class RecentActivityModel<T> {
private String id; private String id;
@ -17,6 +20,8 @@ public abstract class RecentActivityModel<T> {
private Date publishedAt; private Date publishedAt;
private String profile; private String profile;
private RecentActivityType type; private RecentActivityType type;
private List<UserInfoListingModel> users;
private Boolean isPublic;
public String getId() { public String getId() {
return id; return id;
@ -130,6 +135,22 @@ public abstract class RecentActivityModel<T> {
this.type = type; this.type = type;
} }
public List<UserInfoListingModel> getUsers() {
return users;
}
public void setUsers(List<UserInfoListingModel> users) {
this.users = users;
}
public Boolean getPublic() {
return isPublic;
}
public void setPublic(Boolean aPublic) {
isPublic = aPublic;
}
public abstract RecentActivityModel fromEntity(T entity); public abstract RecentActivityModel fromEntity(T entity);
public enum RecentActivityType { public enum RecentActivityType {

View File

@ -4,6 +4,7 @@ import eu.eudat.data.entities.Dataset;
import eu.eudat.logic.utilities.helpers.LabelBuilder; import eu.eudat.logic.utilities.helpers.LabelBuilder;
import eu.eudat.models.data.dataset.DataRepository; import eu.eudat.models.data.dataset.DataRepository;
import eu.eudat.models.data.dataset.Service; import eu.eudat.models.data.dataset.Service;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import java.util.Date; import java.util.Date;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -75,6 +76,8 @@ public class RecentDatasetModel extends RecentActivityModel<Dataset> {
this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : ""); this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : "");
this.setRegistries(LabelBuilder.getLabel(entity.getRegistries().stream().map(item -> new eu.eudat.models.data.dataset.Registry().fromDataModel(item)).collect(Collectors.toList()))); this.setRegistries(LabelBuilder.getLabel(entity.getRegistries().stream().map(item -> new eu.eudat.models.data.dataset.Registry().fromDataModel(item)).collect(Collectors.toList())));
this.setServices(LabelBuilder.getLabel(entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList()))); this.setServices(LabelBuilder.getLabel(entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList())));
this.setPublic(entity.getDmp().isPublic());
this.setUsers(entity.getDmp().getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()));
return this; return this;
} }

View File

@ -19,8 +19,6 @@ public class RecentDmpModel extends RecentActivityModel<DMP> {
private List<AssociatedProfile> associatedProfiles; private List<AssociatedProfile> associatedProfiles;
private String organisations; private String organisations;
private UUID groupId; private UUID groupId;
private List<UserInfoListingModel> users;
private Boolean isPublic;
public String getDoi() { public String getDoi() {
@ -71,22 +69,6 @@ public class RecentDmpModel extends RecentActivityModel<DMP> {
this.groupId = groupId; this.groupId = groupId;
} }
public List<UserInfoListingModel> getUsers() {
return users;
}
public void setUsers(List<UserInfoListingModel> users) {
this.users = users;
}
public Boolean getPublic() {
return isPublic;
}
public void setPublic(Boolean aPublic) {
isPublic = aPublic;
}
@Override @Override
@Transactional @Transactional
public RecentActivityModel fromEntity(DMP entity) { public RecentActivityModel fromEntity(DMP entity) {
@ -105,11 +87,11 @@ public class RecentDmpModel extends RecentActivityModel<DMP> {
this.setGrantAbbreviation(entity.getGrant().getAbbreviation()); this.setGrantAbbreviation(entity.getGrant().getAbbreviation());
this.setGrantId(entity.getGrant().getId().toString()); this.setGrantId(entity.getGrant().getId().toString());
this.groupId = entity.getGroupId(); this.groupId = entity.getGroupId();
this.isPublic = entity.isPublic(); this.setPublic(entity.isPublic());
this.organisations = LabelBuilder.getLabel(entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList())); this.organisations = LabelBuilder.getLabel(entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()));
if (entity.getProfile() != null) this.setProfile(entity.getProfile().getLabel()); if (entity.getProfile() != null) this.setProfile(entity.getProfile().getLabel());
this.setPublishedAt(entity.getPublishedAt()); this.setPublishedAt(entity.getPublishedAt());
this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()); this.setUsers(entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()));
return this; return this;
} }
} }