argos/dmp-backend/web/src/main/java/eu/eudat/models/data/dashboard/recent/model/RecentDmpModel.java

115 lines
3.3 KiB
Java

package eu.eudat.models.data.dashboard.recent.model;
import eu.eudat.data.entities.DMP;
import eu.eudat.logic.utilities.helpers.LabelBuilder;
import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.dmp.Organisation;
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
public class RecentDmpModel extends RecentActivityModel<DMP> {
private String doi;
private Map<String, Object> extraProperties;
private List<RecentDatasetModel> datasets;
private List<AssociatedProfile> associatedProfiles;
private String organisations;
private UUID groupId;
private List<UserInfoListingModel> users;
private Boolean isPublic;
public String getDoi() {
return doi;
}
public void setDoi(String doi) {
this.doi = doi;
}
public Map<String, Object> getExtraProperties() {
return extraProperties;
}
public void setExtraProperties(Map<String, Object> extraProperties) {
this.extraProperties = extraProperties;
}
public List<RecentDatasetModel> getDatasets() {
return datasets;
}
public void setDatasets(List<RecentDatasetModel> datasets) {
this.datasets = datasets;
}
public List<AssociatedProfile> getAssociatedProfiles() {
return associatedProfiles;
}
public void setAssociatedProfiles(List<AssociatedProfile> associatedProfiles) {
this.associatedProfiles = associatedProfiles;
}
public String getOrganisations() {
return organisations;
}
public void setOrganisations(String organisations) {
this.organisations = organisations;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID 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
@Transactional
public RecentActivityModel fromEntity(DMP entity) {
this.setId(entity.getId().toString());
this.setTitle(entity.getLabel());
this.setDescription(entity.getDescription());
this.setCreated(entity.getCreated());
this.setModified(entity.getModified());
this.setStatus(entity.getStatus());
this.setVersion(entity.getVersion());
this.datasets = entity.getDataset().stream().map(dataset -> new RecentDatasetModel().fromDmpEntity(dataset)).collect(Collectors.toList());
this.associatedProfiles = entity.getAssociatedDmps().stream().map(item -> new AssociatedProfile().fromData(item)).collect(Collectors.toList());
this.setFinalizedAt(entity.getFinalizedAt());
this.setGrant(entity.getGrant().getLabel());
this.setGrantAbbreviation(entity.getGrant().getAbbreviation());
this.setGrantId(entity.getGrant().getId().toString());
this.groupId = entity.getGroupId();
this.isPublic = entity.isPublic();
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());
this.setPublishedAt(entity.getPublishedAt());
this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
return this;
}
}