package eu.eudat.models.data.listingmodels; import eu.eudat.data.entities.Dataset; import eu.eudat.models.DataModel; import eu.eudat.models.data.dataset.DataRepository; import eu.eudat.models.data.dataset.Service; import eu.eudat.logic.utilities.helpers.LabelBuilder; import java.util.Date; import java.util.stream.Collectors; public class DatasetListingModel implements DataModel { private String id; private String label; private String grant; private String dmp; private String dmpId; private String profile; private String dataRepositories; private String registries; private String services; private int status; private Date created; private Date modified; private String description; private String grantAbbreviation; private String grantId; private Date finalizedAt; private Date dmpPublishedAt; private int version; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getLabel() { return label; } public void setLabel(String label) { this.label = label; } public String getGrant() { return grant; } public void setGrant(String grant) { this.grant = grant; } 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 getProfile() { return profile; } public void setProfile(String profile) { this.profile = profile; } 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; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public Date getCreated() { return created; } public void setCreated(Date created) { this.created = created; } public Date getModified() { return modified; } public void setModified(Date modified) { this.modified = modified; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getGrantAbbreviation() { return grantAbbreviation; } public void setGrantAbbreviation(String grantAbbreviation) { this.grantAbbreviation = grantAbbreviation; } public String getGrantId() { return grantId; } public void setGrantId(String grantId) { this.grantId = grantId; } public Date getFinalizedAt() { return finalizedAt; } public void setFinalizedAt(Date finalizedAt) { this.finalizedAt = finalizedAt; } public Date getDmpPublishedAt() { return dmpPublishedAt; } public void setDmpPublishedAt(Date dmpPublishedAt) { this.dmpPublishedAt = dmpPublishedAt; } public int getVersion() { return version; } public void setVersion(int version) { this.version = version; } @Override public DatasetListingModel fromDataModel(Dataset entity) { this.id = entity.getId() != null ? entity.getId().toString() : ""; this.label = entity.getLabel(); this.created = entity.getCreated(); this.modified = entity.getModified(); this.grant = entity.getDmp() != null ? entity.getDmp().getGrant().getLabel() : ""; this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : ""; this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : ""; this.profile = entity.getProfile() != null ? entity.getProfile().getLabel() : ""; this.description = entity.getDescription(); this.status = entity.getStatus(); this.grantAbbreviation = entity.getDmp() != null ? entity.getDmp().getGrant().getAbbreviation() : ""; this.grantId = entity.getDmp() != null ? entity.getDmp().getGrant().getId().toString() : ""; this.registries = LabelBuilder.getLabel(entity.getRegistries().stream().map(item -> new eu.eudat.models.data.dataset.Registry().fromDataModel(item)).collect(Collectors.toList())); this.dataRepositories = LabelBuilder.getLabel(entity.getDatasetDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item.getDataRepository())).collect(Collectors.toList())); this.services = LabelBuilder.getLabel(entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList())); this.finalizedAt = entity.getFinalizedAt(); this.dmpPublishedAt = entity.getDmp().getPublishedAt(); this.version = entity.getDmp().getVersion(); return this; } @Override public Dataset toDataModel() { return null; } @Override public String getHint() { return "datasetListingModel"; } }