191 lines
5.7 KiB
Java
191 lines
5.7 KiB
Java
package eu.eudat.models.data.listingmodels;
|
|
|
|
import eu.eudat.data.DmpEntity;
|
|
import eu.eudat.model.DmpUser;
|
|
import eu.eudat.models.DataModel;
|
|
import eu.eudat.models.data.urls.DatasetUrlListing;
|
|
|
|
import java.util.Date;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
public class DataManagementPlanListingModel implements DataModel<DmpEntity, DataManagementPlanListingModel> {
|
|
private String id;
|
|
private String label;
|
|
private String grant;
|
|
private Date creationTime;
|
|
private Date modifiedTime;
|
|
private int version;
|
|
private int status;
|
|
private UUID groupId;
|
|
private List<DatasetUrlListing> datasets;
|
|
private List<DmpUser> users;
|
|
private Date finalizedAt;
|
|
private Boolean isPublic;
|
|
private Date publishedAt;
|
|
|
|
|
|
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 Date getCreationTime() {
|
|
return creationTime;
|
|
}
|
|
public void setCreationTime(Date creationTime) {
|
|
this.creationTime = creationTime;
|
|
}
|
|
|
|
public Date getModifiedTime() {
|
|
return modifiedTime;
|
|
}
|
|
public void setModifiedTime(Date modifiedTime) {
|
|
this.modifiedTime = modifiedTime;
|
|
}
|
|
|
|
public int getVersion() {
|
|
return version;
|
|
}
|
|
public void setVersion(int version) {
|
|
this.version = version;
|
|
}
|
|
|
|
public UUID getGroupId() {
|
|
return groupId;
|
|
}
|
|
public void setGroupId(UUID groupId) {
|
|
this.groupId = groupId;
|
|
}
|
|
|
|
public List<DatasetUrlListing> getDatasets() {
|
|
return datasets;
|
|
}
|
|
public void setDatasets(List<DatasetUrlListing> datasets) {
|
|
this.datasets = datasets;
|
|
}
|
|
|
|
public int getStatus() {
|
|
return status;
|
|
}
|
|
public void setStatus(int status) {
|
|
this.status = status;
|
|
}
|
|
|
|
public List<DmpUser> getUsers() {
|
|
return users;
|
|
}
|
|
public void setUsers(List<DmpUser> users) {
|
|
this.users = users;
|
|
}
|
|
|
|
public Date getFinalizedAt() {
|
|
return finalizedAt;
|
|
}
|
|
public void setFinalizedAt(Date finalizedAt) {
|
|
this.finalizedAt = finalizedAt;
|
|
}
|
|
|
|
public Boolean getPublic() {
|
|
return isPublic;
|
|
}
|
|
public void setPublic(Boolean aPublic) {
|
|
isPublic = aPublic;
|
|
}
|
|
|
|
public Date getPublishedAt() {
|
|
return publishedAt;
|
|
}
|
|
public void setPublishedAt(Date publishedAt) {
|
|
this.publishedAt = publishedAt;
|
|
}
|
|
|
|
@Override
|
|
public DataManagementPlanListingModel fromDataModel(DmpEntity entity) {
|
|
this.id = entity.getId().toString();
|
|
this.label = entity.getLabel();
|
|
this.groupId = entity.getGroupId();
|
|
return this;
|
|
}
|
|
|
|
public DataManagementPlanListingModel fromDataModelAssociatedProfiles(DmpEntity entity) {
|
|
this.id = entity.getId().toString();
|
|
this.label = entity.getLabel();
|
|
this.groupId = entity.getGroupId();
|
|
this.creationTime = Date.from(entity.getCreatedAt());
|
|
return this;
|
|
}
|
|
|
|
public DataManagementPlanListingModel fromDataModelAutoComplete(DmpEntity entity) {
|
|
this.id = entity.getId().toString();
|
|
this.label = entity.getLabel();
|
|
this.groupId = entity.getGroupId();
|
|
this.creationTime = Date.from(entity.getCreatedAt());
|
|
return this;
|
|
}
|
|
|
|
public DataManagementPlanListingModel fromDataModelDatasets(DmpEntity entity) {
|
|
this.fromDataModel(entity);
|
|
this.status = entity.getStatus().getValue();
|
|
this.version = entity.getVersion();
|
|
this.creationTime = Date.from(entity.getCreatedAt());
|
|
this.modifiedTime = Date.from(entity.getUpdatedAt());
|
|
this.finalizedAt = Date.from(entity.getFinalizedAt());
|
|
// this.grant = (entity.getGrant() != null) ? entity.getGrant().getLabel() : null; //TODO
|
|
// this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());
|
|
// this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
|
// this.isPublic = entity.isPublic();
|
|
// this.publishedAt = entity.getPublishedAt();
|
|
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public DmpEntity toDataModel() {
|
|
DmpEntity entity = new DmpEntity();
|
|
entity.setId(UUID.fromString(this.getId()));
|
|
entity.setLabel(this.getLabel());
|
|
entity.setGroupId(this.getGroupId());
|
|
// entity.setStatus(Integer.valueOf(this.getStatus()).shortValue()); //TODO
|
|
// entity.setCreated(this.getCreationTime());
|
|
// entity.setFinalizedAt(this.getFinalizedAt());
|
|
// entity.setModified(this.getModifiedTime());
|
|
// entity.setPublic(this.getPublic());
|
|
// entity.setPublishedAt(this.getPublishedAt());
|
|
// entity.setVersion(this.getVersion());
|
|
//
|
|
// entity.setDataset(this.getDatasets().stream().map(DatasetUrlListing::toDataModel).collect(Collectors.toCollection(LinkedHashSet::new)));
|
|
// if (this.getGrant() != null && !this.getGrant().isEmpty()) {
|
|
// Grant grant = new Grant();
|
|
// grant.setLabel(this.getGrant());
|
|
// entity.setGrant(grant);
|
|
// }
|
|
// entity.setUsers(this.getUsers().stream().map(UserInfoListingModel::toDataModel).collect(Collectors.toSet()));
|
|
return entity;
|
|
}
|
|
|
|
@Override
|
|
public String getHint() {
|
|
return "dataManagementPlanListingModel";
|
|
}
|
|
}
|