2020-06-30 15:59:06 +02:00
|
|
|
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;
|
2020-07-03 12:55:25 +02:00
|
|
|
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
2020-06-30 15:59:06 +02:00
|
|
|
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
2020-07-03 12:55:25 +02:00
|
|
|
import eu.eudat.models.data.urls.DatasetUrlListing;
|
2020-06-30 15:59:06 +02:00
|
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
2020-07-03 12:55:25 +02:00
|
|
|
public class RecentDmpModel extends RecentActivityModel<DMP, RecentDmpModel> {
|
2020-06-30 15:59:06 +02:00
|
|
|
private String doi;
|
|
|
|
private Map<String, Object> extraProperties;
|
2020-07-03 12:55:25 +02:00
|
|
|
private List<DatasetUrlListing> datasets;
|
2020-06-30 15:59:06 +02:00
|
|
|
private List<AssociatedProfile> associatedProfiles;
|
|
|
|
private String organisations;
|
|
|
|
private UUID groupId;
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-07-03 12:55:25 +02:00
|
|
|
public List<DatasetUrlListing> getDatasets() {
|
2020-06-30 15:59:06 +02:00
|
|
|
return datasets;
|
|
|
|
}
|
|
|
|
|
2020-07-03 12:55:25 +02:00
|
|
|
public void setDatasets(List<DatasetUrlListing> datasets) {
|
2020-06-30 15:59:06 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Transactional
|
|
|
|
public RecentActivityModel fromEntity(DMP entity) {
|
2020-07-03 10:23:13 +02:00
|
|
|
this.setType(RecentActivityType.DMP.getIndex());
|
2020-06-30 15:59:06 +02:00
|
|
|
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());
|
2020-07-03 12:55:25 +02:00
|
|
|
//this.datasets = entity.getDataset().stream().map(dataset -> new RecentDatasetModel().fromDmpEntity(dataset)).collect(Collectors.toList());
|
|
|
|
this.datasets = entity.getDataset().stream().map(dataset -> new DatasetUrlListing().fromDataModel(dataset)).collect(Collectors.toList());
|
2020-06-30 15:59:06 +02:00
|
|
|
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();
|
2020-07-03 09:43:54 +02:00
|
|
|
this.setPublic(entity.isPublic());
|
2020-06-30 15:59:06 +02:00
|
|
|
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());
|
2020-07-03 09:43:54 +02:00
|
|
|
this.setUsers(entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()));
|
2020-06-30 15:59:06 +02:00
|
|
|
return this;
|
|
|
|
}
|
2020-07-03 12:55:25 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public RecentDmpModel fromDataModel(DMP entity) {
|
|
|
|
return (RecentDmpModel) this.fromEntity(entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public DMP toDataModel() throws Exception {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getHint() {
|
|
|
|
return "recentDmpModel";
|
|
|
|
}
|
2020-06-30 15:59:06 +02:00
|
|
|
}
|