101 lines
3.9 KiB
Java
101 lines
3.9 KiB
Java
package eu.eudat.models.data.dashboard.recent.model;
|
|
|
|
import eu.eudat.data.entities.Dataset;
|
|
import eu.eudat.logic.utilities.helpers.LabelBuilder;
|
|
import eu.eudat.models.data.dataset.DataRepository;
|
|
import eu.eudat.models.data.dataset.Service;
|
|
|
|
import java.util.Date;
|
|
import java.util.stream.Collectors;
|
|
|
|
public class RecentDatasetModel extends RecentActivityModel<Dataset> {
|
|
private String dmp;
|
|
private String dmpId;
|
|
private String dataRepositories;
|
|
private String registries;
|
|
private String services;
|
|
|
|
public String getDmp() {
|
|
return dmp;
|
|
}
|
|
|
|
public void setDmp(String dmp) {
|
|
this.dmp = dmp;
|
|
}
|
|
|
|
public String getDmpId() {
|
|
return dmpId;
|
|
}
|
|
|
|
public void setDmpId(String dmpId) {
|
|
this.dmpId = dmpId;
|
|
}
|
|
|
|
public String getDataRepositories() {
|
|
return dataRepositories;
|
|
}
|
|
|
|
public void setDataRepositories(String dataRepositories) {
|
|
this.dataRepositories = dataRepositories;
|
|
}
|
|
|
|
public String getRegistries() {
|
|
return registries;
|
|
}
|
|
|
|
public void setRegistries(String registries) {
|
|
this.registries = registries;
|
|
}
|
|
|
|
public String getServices() {
|
|
return services;
|
|
}
|
|
|
|
public void setServices(String services) {
|
|
this.services = services;
|
|
}
|
|
|
|
@Override
|
|
public RecentActivityModel fromEntity(Dataset 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.getDmp() != null ? entity.getDmp().getVersion(): 0);
|
|
this.setFinalizedAt(entity.getFinalizedAt());
|
|
this.setGrantAbbreviation(entity.getDmp() != null ? entity.getDmp().getGrant().getAbbreviation() : "");
|
|
this.setPublishedAt(entity.getDmp() != null ? entity.getDmp().getPublishedAt() : new Date());
|
|
this.setGrantId(entity.getDmp() != null ? entity.getDmp().getGrant().getId().toString() : "");
|
|
this.setProfile(entity.getProfile() != null ? entity.getProfile().getLabel() : "");
|
|
this.setGrant(entity.getDmp() != null ? entity.getDmp().getGrant().getLabel() : "");
|
|
this.setDataRepositories(entity.getDatasetDataRepositories() != null && !entity.getDatasetDataRepositories().isEmpty()? LabelBuilder.getLabel(entity.getDatasetDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item.getDataRepository())).collect(Collectors.toList())) : "");
|
|
this.setDmp( entity.getDmp() != null ? entity.getDmp().getLabel() : "");
|
|
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.setServices(LabelBuilder.getLabel(entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList())));
|
|
return this;
|
|
}
|
|
|
|
public RecentDatasetModel fromDmpEntity(Dataset entity) {
|
|
this.setType(RecentActivityType.DATASET);
|
|
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.getDmp() != null ? entity.getDmp().getVersion(): 0);
|
|
this.setFinalizedAt(entity.getFinalizedAt());
|
|
this.setGrantAbbreviation(entity.getDmp() != null ? entity.getDmp().getGrant().getAbbreviation() : "");
|
|
this.setPublishedAt(entity.getDmp() != null ? entity.getDmp().getPublishedAt() : new Date());
|
|
this.setGrantId(entity.getDmp() != null ? entity.getDmp().getGrant().getId().toString() : "");
|
|
this.setProfile(entity.getProfile() != null ? entity.getProfile().getLabel() : "");
|
|
this.setGrant(entity.getDmp() != null ? entity.getDmp().getGrant().getLabel() : "");
|
|
this.setDmp( entity.getDmp() != null ? entity.getDmp().getLabel() : "");
|
|
this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : "");
|
|
return this;
|
|
}
|
|
}
|