Fix listing issues and improve elastic query
(cherry picked from commit dcd7f24cac
)
This commit is contained in:
parent
143a4c0214
commit
72d88d9db4
|
@ -15,11 +15,11 @@ import java.util.stream.Collectors;
|
||||||
@NamedEntityGraphs({
|
@NamedEntityGraphs({
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
name = "dataManagementPlanListingModel",
|
name = "dataManagementPlanListingModel",
|
||||||
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"), @NamedAttributeNode("associatedDmps"),
|
attributeNodes = {
|
||||||
@NamedAttributeNode("grant"), @NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")},
|
@NamedAttributeNode("grant"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile")}/*,*/
|
||||||
subgraphs = {
|
/*subgraphs = {
|
||||||
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")}),
|
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")}),
|
||||||
}
|
}*/
|
||||||
),
|
),
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
name = "fullyDetailed",
|
name = "fullyDetailed",
|
||||||
|
|
|
@ -21,6 +21,9 @@ public class DatasetCriteria extends Criteria {
|
||||||
private List<Tag> tags;
|
private List<Tag> tags;
|
||||||
private boolean isPublic;
|
private boolean isPublic;
|
||||||
private Short grantStatus;
|
private Short grantStatus;
|
||||||
|
private int offset;
|
||||||
|
private int size;
|
||||||
|
private List<SortCriteria> sortCriteria;
|
||||||
|
|
||||||
public String getLike() {
|
public String getLike() {
|
||||||
return like;
|
return like;
|
||||||
|
@ -117,4 +120,28 @@ public class DatasetCriteria extends Criteria {
|
||||||
public void setGrantStatus(Short grantStatus) {
|
public void setGrantStatus(Short grantStatus) {
|
||||||
this.grantStatus = grantStatus;
|
this.grantStatus = grantStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffset(int offset) {
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(int size) {
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SortCriteria> getSortCriteria() {
|
||||||
|
return sortCriteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortCriteria(List<SortCriteria> sortCriteria) {
|
||||||
|
this.sortCriteria = sortCriteria;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,16 @@ public class DmpCriteria extends Criteria {
|
||||||
private List<UUID> templates;
|
private List<UUID> templates;
|
||||||
private List<UUID> grants;
|
private List<UUID> grants;
|
||||||
private List<UUID> collaborators;
|
private List<UUID> collaborators;
|
||||||
|
private List<Integer> roles;
|
||||||
private List<UUID> organizations;
|
private List<UUID> organizations;
|
||||||
private boolean isPublic;
|
private boolean isPublic;
|
||||||
private List<UUID> groupIds;
|
private List<UUID> groupIds;
|
||||||
private boolean allowAllVersions;
|
private boolean allowAllVersions;
|
||||||
private Short grantStatus;
|
private Short grantStatus;
|
||||||
|
private int offset;
|
||||||
|
private int size;
|
||||||
|
private List<SortCriteria> sortCriteria;
|
||||||
|
|
||||||
|
|
||||||
public String getLike() {
|
public String getLike() {
|
||||||
return like;
|
return like;
|
||||||
|
@ -55,6 +60,14 @@ public class DmpCriteria extends Criteria {
|
||||||
this.collaborators = collaborators;
|
this.collaborators = collaborators;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Integer> getRoles() {
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoles(List<Integer> roles) {
|
||||||
|
this.roles = roles;
|
||||||
|
}
|
||||||
|
|
||||||
public List<UUID> getOrganizations() {
|
public List<UUID> getOrganizations() {
|
||||||
return organizations;
|
return organizations;
|
||||||
}
|
}
|
||||||
|
@ -94,4 +107,28 @@ public class DmpCriteria extends Criteria {
|
||||||
public void setGrantStatus(Short grantStatus) {
|
public void setGrantStatus(Short grantStatus) {
|
||||||
this.grantStatus = grantStatus;
|
this.grantStatus = grantStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffset(int offset) {
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(int size) {
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SortCriteria> getSortCriteria() {
|
||||||
|
return sortCriteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortCriteria(List<SortCriteria> sortCriteria) {
|
||||||
|
this.sortCriteria = sortCriteria;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package eu.eudat.elastic.criteria;
|
||||||
|
|
||||||
|
public class SortCriteria {
|
||||||
|
public enum OrderByType {
|
||||||
|
ASC, DESC
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ColumnType {
|
||||||
|
COUNT, COLUMN, JOIN_COLUMN
|
||||||
|
}
|
||||||
|
|
||||||
|
private String fieldName;
|
||||||
|
private OrderByType orderByType;
|
||||||
|
private ColumnType columnType;
|
||||||
|
|
||||||
|
public String getFieldName() {
|
||||||
|
return fieldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldName(String fieldName) {
|
||||||
|
this.fieldName = fieldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderByType getOrderByType() {
|
||||||
|
return orderByType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderByType(OrderByType orderByType) {
|
||||||
|
this.orderByType = orderByType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColumnType getColumnType() {
|
||||||
|
return columnType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColumnType(ColumnType columnType) {
|
||||||
|
this.columnType = columnType;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,11 +4,11 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class Collaborator implements ElasticEntity<Collaborator> {
|
public class Collaborator implements ElasticEntity<Collaborator> {
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
|
private int role;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -26,11 +26,20 @@ public class Collaborator implements ElasticEntity<Collaborator> {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRole() {
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole(int role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field("id", this.id);
|
builder.field("id", this.id);
|
||||||
builder.field("name", this.name);
|
builder.field("name", this.name);
|
||||||
|
builder.field("role", this.role);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +48,7 @@ public class Collaborator implements ElasticEntity<Collaborator> {
|
||||||
public Collaborator fromElasticEntity(Map fields) {
|
public Collaborator fromElasticEntity(Map fields) {
|
||||||
this.id = (String) fields.get("id");
|
this.id = (String) fields.get("id");
|
||||||
this.name = (String) fields.get("name");
|
this.name = (String) fields.get("name");
|
||||||
|
this.role = (int) fields.get("role");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -59,6 +60,9 @@ public class Dataset implements ElasticEntity<Dataset> {
|
||||||
private Boolean isPublic;
|
private Boolean isPublic;
|
||||||
private Short grantStatus;
|
private Short grantStatus;
|
||||||
private String formData;
|
private String formData;
|
||||||
|
private Date created;
|
||||||
|
private Date modified;
|
||||||
|
private Date finalizedAt;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -188,6 +192,30 @@ public class Dataset implements ElasticEntity<Dataset> {
|
||||||
this.formData = formData;
|
this.formData = formData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 Date getFinalizedAt() {
|
||||||
|
return finalizedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinalizedAt(Date finalizedAt) {
|
||||||
|
this.finalizedAt = finalizedAt;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
|
@ -197,6 +225,9 @@ public class Dataset implements ElasticEntity<Dataset> {
|
||||||
builder.field("template", this.template.toString());
|
builder.field("template", this.template.toString());
|
||||||
builder.field("status", this.status.toString());
|
builder.field("status", this.status.toString());
|
||||||
builder.field("dmp", this.dmp.toString());
|
builder.field("dmp", this.dmp.toString());
|
||||||
|
builder.field("created", this.created);
|
||||||
|
builder.field("modified", this.modified);
|
||||||
|
builder.field("finalizedAt", this.finalizedAt);
|
||||||
if (this.group != null) {
|
if (this.group != null) {
|
||||||
builder.field("group", this.group.toString());
|
builder.field("group", this.group.toString());
|
||||||
}
|
}
|
||||||
|
@ -263,6 +294,12 @@ public class Dataset implements ElasticEntity<Dataset> {
|
||||||
this.dmp = UUID.fromString((String) fields.get("dmp"));
|
this.dmp = UUID.fromString((String) fields.get("dmp"));
|
||||||
this.group = UUID.fromString((String) fields.get("group"));
|
this.group = UUID.fromString((String) fields.get("group"));
|
||||||
this.grant = UUID.fromString((String) fields.get("grant"));
|
this.grant = UUID.fromString((String) fields.get("grant"));
|
||||||
|
if (fields.get("created") != null)
|
||||||
|
this.created = Date.from(Instant.parse((String) fields.get("created")));
|
||||||
|
if (fields.get("modified") != null)
|
||||||
|
this.modified = Date.from(Instant.parse((String) fields.get("modified")));
|
||||||
|
if (fields.get("finalizedAt") != null)
|
||||||
|
this.finalizedAt = Date.from(Instant.parse((String) fields.get("finalizedAt")));
|
||||||
if (fields.get("collaborators") != null) {
|
if (fields.get("collaborators") != null) {
|
||||||
this.collaborators = ((List<HashMap>) fields.get("collaborators")).stream().map(hashMap -> new Collaborator().fromElasticEntity(hashMap)).collect(Collectors.toList());
|
this.collaborators = ((List<HashMap>) fields.get("collaborators")).stream().map(hashMap -> new Collaborator().fromElasticEntity(hashMap)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Dmp implements ElasticEntity<Dmp> {
|
public class Dmp implements ElasticEntity<Dmp> {
|
||||||
|
@ -55,6 +52,11 @@ public class Dmp implements ElasticEntity<Dmp> {
|
||||||
private List<Dataset> datasets;
|
private List<Dataset> datasets;
|
||||||
private UUID grant;
|
private UUID grant;
|
||||||
private Short grantStatus;
|
private Short grantStatus;
|
||||||
|
private Date created;
|
||||||
|
private Date modified;
|
||||||
|
private Date finalizedAt;
|
||||||
|
private Date publishedAt;
|
||||||
|
private String doi;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -168,6 +170,46 @@ public class Dmp implements ElasticEntity<Dmp> {
|
||||||
this.grantStatus = grantStatus;
|
this.grantStatus = grantStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 Date getFinalizedAt() {
|
||||||
|
return finalizedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinalizedAt(Date finalizedAt) {
|
||||||
|
this.finalizedAt = finalizedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getPublishedAt() {
|
||||||
|
return publishedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublishedAt(Date publishedAt) {
|
||||||
|
this.publishedAt = publishedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDoi() {
|
||||||
|
return doi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDoi(String doi) {
|
||||||
|
this.doi = doi;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
|
@ -233,6 +275,11 @@ public class Dmp implements ElasticEntity<Dmp> {
|
||||||
builder.field(MapKey.GRANT.getName(), this.grant.toString());
|
builder.field(MapKey.GRANT.getName(), this.grant.toString());
|
||||||
}
|
}
|
||||||
builder.field(MapKey.GRANTSTATUS.getName(), this.grantStatus);
|
builder.field(MapKey.GRANTSTATUS.getName(), this.grantStatus);
|
||||||
|
builder.field(MapKey.CREATED.getName(), this.created);
|
||||||
|
builder.field(MapKey.MODIFIED.getName(), this.modified);
|
||||||
|
builder.field(MapKey.FINALIZEDAT.getName(), this.finalizedAt);
|
||||||
|
builder.field(MapKey.PUBLISHEDAT.getName(), this.publishedAt);
|
||||||
|
builder.field(MapKey.DOI.getName(), this.doi);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +329,12 @@ public class Dmp implements ElasticEntity<Dmp> {
|
||||||
ISPUBLIC ("isPublic"),
|
ISPUBLIC ("isPublic"),
|
||||||
DATASETS ("datasets"),
|
DATASETS ("datasets"),
|
||||||
GRANT ("grant"),
|
GRANT ("grant"),
|
||||||
GRANTSTATUS ("grantStatus");
|
GRANTSTATUS ("grantStatus"),
|
||||||
|
CREATED ("created"),
|
||||||
|
MODIFIED ("modified"),
|
||||||
|
FINALIZEDAT ("finalizedAt"),
|
||||||
|
PUBLISHEDAT ("publishedAt"),
|
||||||
|
DOI ("doi");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,9 @@ import org.elasticsearch.search.aggregations.bucket.filter.ParsedFilters;
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.NestedAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.nested.NestedAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested;
|
import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested;
|
||||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
|
import org.elasticsearch.search.sort.SortBuilder;
|
||||||
|
import org.elasticsearch.search.sort.SortBuilders;
|
||||||
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
@ -120,6 +123,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
searchSourceBuilder.size(count.intValue());
|
searchSourceBuilder.size(count.intValue());
|
||||||
|
|
||||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("datasets.status", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList())));
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("datasets.status", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList())));
|
||||||
|
List<SortBuilder> sortBuilders = new ArrayList<>();
|
||||||
if (criteria.isPublic()) {
|
if (criteria.isPublic()) {
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.public", "true"));
|
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.public", "true"));
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.status", Dataset.Status.FINALISED.getValue()));
|
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.status", Dataset.Status.FINALISED.getValue()));
|
||||||
|
@ -181,8 +185,26 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
boolQuery.minimumShouldMatch(boolQuery.should().size());
|
boolQuery.minimumShouldMatch(boolQuery.should().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (criteria.getSortCriteria() != null && !criteria.getSortCriteria().isEmpty()) {
|
||||||
|
criteria.getSortCriteria().forEach(sortCriteria -> {
|
||||||
|
switch(sortCriteria.getColumnType()) {
|
||||||
|
case COLUMN:
|
||||||
|
sortBuilders.add(SortBuilders.fieldSort(sortCriteria.getFieldName()).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
||||||
|
break;
|
||||||
|
case JOIN_COLUMN:
|
||||||
|
List<String> fields = Arrays.asList(sortCriteria.getFieldName().split(":"));
|
||||||
|
fields.stream().filter(name -> !name.startsWith("dmp")).forEach(field -> {
|
||||||
|
sortBuilders.add(SortBuilders.fieldSort(field).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder());
|
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder());
|
||||||
searchSourceBuilder.query(nestedQueryBuilder);
|
searchSourceBuilder.query(nestedQueryBuilder).from(criteria.getOffset()).size(criteria.getSize());
|
||||||
|
sortBuilders.forEach(searchSourceBuilder::sort);
|
||||||
searchRequest.source(searchSourceBuilder);
|
searchRequest.source(searchSourceBuilder);
|
||||||
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
||||||
return ((Stream<Dataset>)Arrays.stream(response.getHits().getHits())
|
return ((Stream<Dataset>)Arrays.stream(response.getHits().getHits())
|
||||||
|
|
|
@ -23,6 +23,9 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
||||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
|
import org.elasticsearch.search.sort.SortBuilder;
|
||||||
|
import org.elasticsearch.search.sort.SortBuilders;
|
||||||
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -97,6 +100,7 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
||||||
searchSourceBuilder.size(count.intValue());
|
searchSourceBuilder.size(count.intValue());
|
||||||
|
|
||||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery(Dmp.MapKey.STATUS.getName(), Collections.singletonList(Dmp.DMPStatus.DELETED.getValue())));
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery(Dmp.MapKey.STATUS.getName(), Collections.singletonList(Dmp.DMPStatus.DELETED.getValue())));
|
||||||
|
List<SortBuilder> sortBuilders = new ArrayList<>();
|
||||||
if (criteria.isPublic()) {
|
if (criteria.isPublic()) {
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.ISPUBLIC.getName(), true));
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.ISPUBLIC.getName(), true));
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.STATUS.getName(), Dmp.DMPStatus.FINALISED.getValue()));
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.STATUS.getName(), Dmp.DMPStatus.FINALISED.getValue()));
|
||||||
|
@ -125,7 +129,11 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
|
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.COLLABORATORS.getName() + ".keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.COLLABORATORS.getName() + ".id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getRoles() != null && criteria.getRoles().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.COLLABORATORS.getName() + ".role.keyword", criteria.getRoles()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!criteria.isAllowAllVersions()) {
|
if (!criteria.isAllowAllVersions()) {
|
||||||
|
@ -145,7 +153,26 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
||||||
} else {
|
} else {
|
||||||
boolQuery.minimumShouldMatch(boolQuery.should().size());
|
boolQuery.minimumShouldMatch(boolQuery.should().size());
|
||||||
}
|
}
|
||||||
searchSourceBuilder.query(boolQuery);
|
|
||||||
|
if (criteria.getSortCriteria() != null && !criteria.getSortCriteria().isEmpty()) {
|
||||||
|
criteria.getSortCriteria().forEach(sortCriteria -> {
|
||||||
|
switch(sortCriteria.getColumnType()) {
|
||||||
|
case COLUMN:
|
||||||
|
sortBuilders.add(SortBuilders.fieldSort(sortCriteria.getFieldName()).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
||||||
|
break;
|
||||||
|
case JOIN_COLUMN:
|
||||||
|
List<String> fields = Arrays.asList(sortCriteria.getFieldName().split(":"));
|
||||||
|
fields.forEach(field -> {
|
||||||
|
sortBuilders.add(SortBuilders.fieldSort(sortCriteria.getFieldName()).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
searchSourceBuilder.query(boolQuery).from(criteria.getOffset()).size(criteria.getSize());
|
||||||
|
sortBuilders.forEach(searchSourceBuilder::sort);
|
||||||
searchRequest.source(searchSourceBuilder);
|
searchRequest.source(searchSourceBuilder);
|
||||||
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
||||||
return Arrays.stream(response.getHits().getHits()).map(x -> new Dmp().fromElasticEntity((Map<String, Object>) this.transformFromString(x.getSourceAsString(), Map.class))).collect(Collectors.toList());
|
return Arrays.stream(response.getHits().getHits()).map(x -> new Dmp().fromElasticEntity((Map<String, Object>) this.transformFromString(x.getSourceAsString(), Map.class))).collect(Collectors.toList());
|
||||||
|
@ -153,6 +180,67 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long count(DmpCriteria criteria) throws IOException {
|
||||||
|
if (this.getClient() != null) {
|
||||||
|
CountRequest countRequest = new CountRequest(this.environment.getProperty("elasticsearch.index"));
|
||||||
|
|
||||||
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery(Dmp.MapKey.STATUS.getName(), Collections.singletonList(Dmp.DMPStatus.DELETED.getValue())));
|
||||||
|
if (criteria.isPublic()) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.ISPUBLIC.getName(), true));
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.STATUS.getName(), Dmp.DMPStatus.FINALISED.getValue()));
|
||||||
|
}
|
||||||
|
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.queryStringQuery(criteria.getLike()).fields(Stream.of(new Object[][]{
|
||||||
|
{Dmp.MapKey.LABEL.getName(), 1.0f},
|
||||||
|
{Dmp.MapKey.DESCRIPTION.getName(), 1.0f}
|
||||||
|
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Float) data[1]))));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getTemplates() != null && criteria.getTemplates().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.TEMPLATES.getName() + ".id.keyword", criteria.getTemplates().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getStatus() != null) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.STATUS.getName(), criteria.getStatus().intValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getGroupIds() != null && criteria.getGroupIds().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.GROUPID.getName(), criteria.getGroupIds().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getGrants() != null && criteria.getGrants().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.GRANT.getName() + ".keyword", criteria.getGrants().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.COLLABORATORS.getName() + ".id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!criteria.isAllowAllVersions()) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(criteria.isPublic() ? Dmp.MapKey.LASTPUBLICVERSION.getName() : Dmp.MapKey.LASTVERSION.getName(), true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getOrganizations() != null && criteria.getOrganizations().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.ORGANIZATIONS.getName() + ".id.keyword", criteria.getOrganizations().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getGrantStatus() != null) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.GRANTSTATUS.getName(), criteria.getGrantStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (boolQuery.should().isEmpty() && boolQuery.mustNot().isEmpty()) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.matchAllQuery());
|
||||||
|
} else {
|
||||||
|
boolQuery.minimumShouldMatch(boolQuery.should().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
countRequest.query(boolQuery);
|
||||||
|
CountResponse response = this.getClient().count(countRequest, RequestOptions.DEFAULT);
|
||||||
|
return response.getCount();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean createIndex() {
|
public boolean createIndex() {
|
||||||
try {
|
try {
|
||||||
if (!this.exists()) {
|
if (!this.exists()) {
|
||||||
|
|
|
@ -182,14 +182,14 @@ public class DashBoardManager {
|
||||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
||||||
.whenComplete((datasetActivities, throwable) -> activity.setRecentDatasetActivities(datasetActivities));
|
.whenComplete((datasetActivities, throwable) -> activity.setRecentDatasetActivities(datasetActivities));
|
||||||
|
|
||||||
CompletableFuture<List<RecentActivityData>> grants = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user)
|
/*CompletableFuture<List<RecentActivityData>> grants = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user)
|
||||||
.withHint("grantRecentActivity")
|
.withHint("grantRecentActivity")
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||||
.take(numberofactivities)
|
.take(numberofactivities)
|
||||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
||||||
.whenComplete((grantActivities, throwable) -> activity.setRecentGrantActivities(grantActivities));
|
.whenComplete((grantActivities, throwable) -> activity.setRecentGrantActivities(grantActivities));*/
|
||||||
|
|
||||||
CompletableFuture.allOf(grants, dmps, datasets).join();
|
CompletableFuture.allOf(/*grants, */dmps, datasets).join();
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import eu.eudat.data.enumeration.notification.ActiveStatus;
|
||||||
import eu.eudat.data.enumeration.notification.ContactType;
|
import eu.eudat.data.enumeration.notification.ContactType;
|
||||||
import eu.eudat.data.enumeration.notification.NotificationType;
|
import eu.eudat.data.enumeration.notification.NotificationType;
|
||||||
import eu.eudat.data.enumeration.notification.NotifyState;
|
import eu.eudat.data.enumeration.notification.NotifyState;
|
||||||
|
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
||||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
||||||
import eu.eudat.elastic.criteria.DmpCriteria;
|
import eu.eudat.elastic.criteria.DmpCriteria;
|
||||||
|
@ -129,13 +130,19 @@ public class DataManagementPlanManager {
|
||||||
List<Dmp> dmps = null;
|
List<Dmp> dmps = null;
|
||||||
QueryableList<DMP> items = null;
|
QueryableList<DMP> items = null;
|
||||||
QueryableList<DMP> authItems = null;
|
QueryableList<DMP> authItems = null;
|
||||||
|
Long totalData = 0L;
|
||||||
if (apiContext.getOperationsContext().getElasticRepository().getDmpRepository() != null) {
|
if (apiContext.getOperationsContext().getElasticRepository().getDmpRepository() != null) {
|
||||||
try {
|
try {
|
||||||
DmpCriteria criteria = DmpCriteriaMapper.toElasticCriteria(dataManagementPlanTableRequest.getCriteria());
|
DmpCriteria criteria = DmpCriteriaMapper.toElasticCriteria(dataManagementPlanTableRequest.getCriteria(), principalID);
|
||||||
|
criteria.setOffset(dataManagementPlanTableRequest.getOffset());
|
||||||
|
criteria.setSize(dataManagementPlanTableRequest.getLength());
|
||||||
|
criteria.setSortCriteria(DmpCriteriaMapper.toElasticSorting(dataManagementPlanTableRequest.getOrderings()));
|
||||||
dmps = apiContext.getOperationsContext().getElasticRepository().getDmpRepository().query(criteria);
|
dmps = apiContext.getOperationsContext().getElasticRepository().getDmpRepository().query(criteria);
|
||||||
if (dmps != null && !dmps.isEmpty()) {
|
if (dmps != null && !dmps.isEmpty()) {
|
||||||
List<Dmp> finalDmps = dmps;
|
List<Dmp> finalDmps = dmps;
|
||||||
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable().where((builder, root) -> root.get("id").in(finalDmps.stream().map(Dmp::getId).collect(Collectors.toList())));
|
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable().where((builder, root) -> root.get("id").in(finalDmps.stream().map(Dmp::getId).collect(Collectors.toList())));
|
||||||
|
PaginationManager.applyOrder(items, dataManagementPlanTableRequest);
|
||||||
|
totalData = apiContext.getOperationsContext().getElasticRepository().getDmpRepository().count(criteria);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.warn(ex.getMessage(), ex);
|
logger.warn(ex.getMessage(), ex);
|
||||||
|
@ -144,63 +151,116 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
if (items == null) {
|
if (items == null) {
|
||||||
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
||||||
|
List<Integer> roles = new LinkedList<>();
|
||||||
|
if (!dataManagementPlanTableRequest.getCriteria().isOnlyPublic()) {
|
||||||
|
if (dataManagementPlanTableRequest.getCriteria().getRole() != null)
|
||||||
|
roles.add(dataManagementPlanTableRequest.getCriteria().getRole());
|
||||||
|
authItems = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, principalID, roles);
|
||||||
|
} else {
|
||||||
|
authItems = items;
|
||||||
|
}
|
||||||
|
totalData = authItems.count();
|
||||||
|
items = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
||||||
}
|
}
|
||||||
List<Integer> roles = new LinkedList<>();
|
|
||||||
if (!dataManagementPlanTableRequest.getCriteria().isOnlyPublic()) {
|
|
||||||
if (dataManagementPlanTableRequest.getCriteria().getRole() != null)
|
|
||||||
roles.add(dataManagementPlanTableRequest.getCriteria().getRole());
|
|
||||||
authItems = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, principalID, roles);
|
|
||||||
} else {
|
|
||||||
authItems = items;
|
|
||||||
}
|
|
||||||
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
|
||||||
|
|
||||||
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<>();
|
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<>();
|
||||||
|
|
||||||
CompletableFuture itemsFuture;
|
CompletableFuture itemsFuture;
|
||||||
if (fieldsGroup.equals("listing")) {
|
if (fieldsGroup.equals("listing")) {
|
||||||
if (!dataManagementPlanTableRequest.getCriteria().isOnlyPublic()) {
|
if (!dataManagementPlanTableRequest.getCriteria().isOnlyPublic()) {
|
||||||
itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
|
List<DMP> dmps1 = items.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
|
||||||
.distinct()
|
.distinct().toList();
|
||||||
.selectAsync(item -> {
|
dataTable.setData(dmps1.stream().map(dmp -> {
|
||||||
|
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||||
|
datasetCriteria.setDmpIds(Collections.singletonList(dmp.getId()));
|
||||||
|
dmp.setDataset(retrieveRelevantDatasets(datasetCriteria, principalID));
|
||||||
|
|
||||||
|
|
||||||
|
return new DataManagementPlanListingModel().fromDataModelDatasets(dmp);
|
||||||
|
}).collect(Collectors.toList()));
|
||||||
|
/*.selectAsync(item -> {
|
||||||
item.setDataset(
|
item.setDataset(
|
||||||
item.getDataset().stream()
|
item.getDataset().stream()
|
||||||
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue())).collect(Collectors.toList()).stream()
|
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue())).collect(Collectors.toList()).stream()
|
||||||
.filter(dataset -> dataset.getDmp().getUsers().stream()
|
*//*.filter(dataset -> dataset.getDmp().getUsers().stream()
|
||||||
.filter(x -> x.getUser().getId().equals(principalID))
|
.filter(x -> x.getUser().getId().equals(principalID))
|
||||||
.collect(Collectors.toList()).size() > 0)
|
.collect(Collectors.toList()).size() > 0)*//*
|
||||||
.collect(Collectors.toSet()));
|
.collect(Collectors.toSet()));
|
||||||
return new DataManagementPlanListingModel().fromDataModelDatasets(item);
|
return new DataManagementPlanListingModel().fromDataModelDatasets(item);
|
||||||
})
|
})
|
||||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));*/
|
||||||
} else {
|
} else {
|
||||||
itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
|
List<DMP> dmps1 = items.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
|
||||||
.distinct()
|
.distinct().toList();
|
||||||
.selectAsync(item -> {
|
dataTable.setData(dmps1.stream().map(dmp -> {
|
||||||
|
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||||
|
datasetCriteria.setDmpIds(Collections.singletonList(dmp.getId()));
|
||||||
|
datasetCriteria.setIsPublic(true);
|
||||||
|
dmp.setDataset(retrieveRelevantDatasets(datasetCriteria));
|
||||||
|
|
||||||
|
|
||||||
|
return new DataManagementPlanListingModel().fromDataModelDatasets(dmp);
|
||||||
|
}).collect(Collectors.toList()));
|
||||||
|
/*.selectAsync(item -> {
|
||||||
item.setDataset(
|
item.setDataset(
|
||||||
item.getDataset().stream()
|
item.getDataset().stream()
|
||||||
.filter(dataset -> dataset.getStatus().equals(Dataset.Status.FINALISED.getValue())).collect(Collectors.toSet()));
|
.filter(dataset -> dataset.getStatus().equals(Dataset.Status.FINALISED.getValue())).collect(Collectors.toSet()));
|
||||||
return new DataManagementPlanListingModel().fromDataModelDatasets(item);
|
return new DataManagementPlanListingModel().fromDataModelDatasets(item);
|
||||||
})
|
})
|
||||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));*/
|
||||||
}
|
}
|
||||||
} else if (fieldsGroup.equals("autocomplete")) {
|
} else if (fieldsGroup.equals("autocomplete")) {
|
||||||
itemsFuture = pagedItems
|
dataTable.setData(items
|
||||||
.distinct()
|
.distinct()
|
||||||
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModelAutoComplete(item))
|
.select(item -> new DataManagementPlanListingModel().fromDataModelAutoComplete(item)));
|
||||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
|
||||||
} else {
|
} else {
|
||||||
itemsFuture = pagedItems
|
dataTable.setData(items
|
||||||
.distinct()
|
.distinct()
|
||||||
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModelAssociatedProfiles(item))
|
.select(item -> new DataManagementPlanListingModel().fromDataModelAssociatedProfiles(item)));
|
||||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletableFuture countFuture = authItems.distinct().countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
|
//CompletableFuture countFuture = authItems.distinct().countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
|
||||||
CompletableFuture.allOf(itemsFuture, countFuture).join();
|
dataTable.setTotalCount(totalData);
|
||||||
|
//CompletableFuture.allOf(itemsFuture).join();
|
||||||
return dataTable;
|
return dataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Set<Dataset> retrieveRelevantDatasets(DatasetCriteria datasetCriteria) {
|
||||||
|
return retrieveRelevantDatasets(datasetCriteria, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<Dataset> retrieveRelevantDatasets (DatasetCriteria datasetCriteria, UUID principal) {
|
||||||
|
QueryableList<Dataset> datasetItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria);
|
||||||
|
if (principal != null) {
|
||||||
|
UserInfo userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal);
|
||||||
|
List<Integer> roles = new ArrayList<>();
|
||||||
|
roles.add(0);
|
||||||
|
roles.add(1);
|
||||||
|
datasetItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getAuthenticated(datasetItems, userInfo, roles);
|
||||||
|
}
|
||||||
|
Long maxDatasets = datasetItems.count();
|
||||||
|
DatasetTableRequest datasetTableRequest = new DatasetTableRequest();
|
||||||
|
datasetTableRequest.setOffset(0);
|
||||||
|
datasetTableRequest.setLength(3);
|
||||||
|
Set<Dataset> datasetsSet = new LinkedHashSet<>();
|
||||||
|
try {
|
||||||
|
datasetItems = PaginationManager.applyPaging(datasetItems, datasetTableRequest);
|
||||||
|
List<Dataset> datasets = datasetItems.toList();
|
||||||
|
datasetsSet.addAll(datasets);
|
||||||
|
for (int i = 0; i < maxDatasets - datasets.size(); i++) {
|
||||||
|
Dataset fakedataset = new Dataset();
|
||||||
|
fakedataset.setId(UUID.randomUUID());
|
||||||
|
datasetsSet.add(fakedataset);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return datasetsSet;
|
||||||
|
}
|
||||||
|
|
||||||
public eu.eudat.models.data.dmp.DataManagementPlan getSingle(String id, Principal principal, boolean isPublic) throws Exception {
|
public eu.eudat.models.data.dmp.DataManagementPlan getSingle(String id, Principal principal, boolean isPublic) throws Exception {
|
||||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = new eu.eudat.models.data.dmp.DataManagementPlan();
|
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = new eu.eudat.models.data.dmp.DataManagementPlan();
|
||||||
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||||
|
@ -864,6 +924,7 @@ public class DataManagementPlanManager {
|
||||||
datasetElastic.setCollaborators(dataset1.getDmp().getUsers().stream().map(user -> {
|
datasetElastic.setCollaborators(dataset1.getDmp().getUsers().stream().map(user -> {
|
||||||
Collaborator collaborator = new Collaborator();
|
Collaborator collaborator = new Collaborator();
|
||||||
collaborator.setId(user.getId().toString());
|
collaborator.setId(user.getId().toString());
|
||||||
|
collaborator.setRole(user.getRole());
|
||||||
// collaborator.setName(user.getUser().getName());
|
// collaborator.setName(user.getUser().getName());
|
||||||
return collaborator;
|
return collaborator;
|
||||||
}).collect(Collectors.toList()));
|
}).collect(Collectors.toList()));
|
||||||
|
|
|
@ -22,6 +22,7 @@ import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.logic.builders.BuilderFactory;
|
import eu.eudat.logic.builders.BuilderFactory;
|
||||||
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
||||||
import eu.eudat.logic.mapper.elastic.DatasetMapper;
|
import eu.eudat.logic.mapper.elastic.DatasetMapper;
|
||||||
|
import eu.eudat.logic.mapper.elastic.criteria.DmpCriteriaMapper;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||||
|
@ -137,9 +138,21 @@ public class DatasetManager {
|
||||||
if (datasetTableRequest.getCriteria().getIsPublic() != null) {
|
if (datasetTableRequest.getCriteria().getIsPublic() != null) {
|
||||||
datasetCriteria.setPublic(datasetTableRequest.getCriteria().getIsPublic());
|
datasetCriteria.setPublic(datasetTableRequest.getCriteria().getIsPublic());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!datasetCriteria.isPublic()) {
|
||||||
|
if (datasetCriteria.getCollaborators() == null) {
|
||||||
|
datasetCriteria.setSortCriteria(new ArrayList<>());
|
||||||
|
}
|
||||||
|
datasetCriteria.getCollaborators().add(principal.getId());
|
||||||
|
}
|
||||||
if (datasetTableRequest.getCriteria().getGrantStatus() != null) {
|
if (datasetTableRequest.getCriteria().getGrantStatus() != null) {
|
||||||
datasetCriteria.setGrantStatus(datasetTableRequest.getCriteria().getGrantStatus());
|
datasetCriteria.setGrantStatus(datasetTableRequest.getCriteria().getGrantStatus());
|
||||||
}
|
}
|
||||||
|
if (datasetTableRequest.getOrderings() != null) {
|
||||||
|
datasetCriteria.setSortCriteria(DmpCriteriaMapper.toElasticSorting(datasetTableRequest.getOrderings()));
|
||||||
|
}
|
||||||
|
datasetCriteria.setOffset(datasetTableRequest.getOffset());
|
||||||
|
datasetCriteria.setSize(datasetTableRequest.getLength());
|
||||||
List<eu.eudat.elastic.entities.Dataset> datasets;
|
List<eu.eudat.elastic.entities.Dataset> datasets;
|
||||||
try {
|
try {
|
||||||
datasets = datasetRepository.exists() ?
|
datasets = datasetRepository.exists() ?
|
||||||
|
@ -206,6 +219,11 @@ public class DatasetManager {
|
||||||
datasetCriteria.setDatasetTemplates(datasetTableRequest.getCriteria().getDatasetProfile());
|
datasetCriteria.setDatasetTemplates(datasetTableRequest.getCriteria().getDatasetProfile());
|
||||||
datasetCriteria.setDmps(datasetTableRequest.getCriteria().getDmpIds());
|
datasetCriteria.setDmps(datasetTableRequest.getCriteria().getDmpIds());
|
||||||
datasetCriteria.setGrants(datasetTableRequest.getCriteria().getGrants());
|
datasetCriteria.setGrants(datasetTableRequest.getCriteria().getGrants());
|
||||||
|
if (datasetTableRequest.getOrderings() != null) {
|
||||||
|
datasetCriteria.setSortCriteria(DmpCriteriaMapper.toElasticSorting(datasetTableRequest.getOrderings()));
|
||||||
|
}
|
||||||
|
datasetCriteria.setOffset(datasetTableRequest.getOffset());
|
||||||
|
datasetCriteria.setSize(datasetTableRequest.getLength());
|
||||||
List<eu.eudat.elastic.entities.Dataset> datasets;
|
List<eu.eudat.elastic.entities.Dataset> datasets;
|
||||||
try {
|
try {
|
||||||
datasets = datasetRepository.exists() ?
|
datasets = datasetRepository.exists() ?
|
||||||
|
@ -214,9 +232,9 @@ public class DatasetManager {
|
||||||
logger.warn(ex.getMessage());
|
logger.warn(ex.getMessage());
|
||||||
datasets = null;
|
datasets = null;
|
||||||
}
|
}
|
||||||
datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
|
/*datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
|
||||||
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();
|
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();*/
|
||||||
/*QueryableList<Dataset> items;
|
QueryableList<Dataset> items;
|
||||||
if (datasets != null) {
|
if (datasets != null) {
|
||||||
if (!datasets.isEmpty()) {
|
if (!datasets.isEmpty()) {
|
||||||
items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
||||||
|
@ -227,7 +245,7 @@ public class DatasetManager {
|
||||||
items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()}));
|
items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()}));
|
||||||
} else {
|
} else {
|
||||||
items = datasetTableRequest.applyCriteria();
|
items = datasetTableRequest.applyCriteria();
|
||||||
}*/
|
}
|
||||||
|
|
||||||
if (principal.getId() != null && datasetTableRequest.getCriteria().getRole() != null) {
|
if (principal.getId() != null && datasetTableRequest.getCriteria().getRole() != null) {
|
||||||
items.where((builder, root) -> {
|
items.where((builder, root) -> {
|
||||||
|
|
|
@ -5,10 +5,11 @@ import eu.eudat.elastic.entities.Collaborator;
|
||||||
|
|
||||||
public class CollaboratorMapper {
|
public class CollaboratorMapper {
|
||||||
|
|
||||||
public static Collaborator toElastic(UserInfo user) {
|
public static Collaborator toElastic(UserInfo user, Integer role) {
|
||||||
Collaborator elastic = new Collaborator();
|
Collaborator elastic = new Collaborator();
|
||||||
elastic.setId(user.getId().toString());
|
elastic.setId(user.getId().toString());
|
||||||
elastic.setName(user.getName());
|
elastic.setName(user.getName());
|
||||||
|
elastic.setRole(role);
|
||||||
return elastic;
|
return elastic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,11 @@ public class DatasetMapper {
|
||||||
elastic.setDmp(dataset.getDmp().getId());
|
elastic.setDmp(dataset.getDmp().getId());
|
||||||
elastic.setGroup(dataset.getDmp().getGroupId());
|
elastic.setGroup(dataset.getDmp().getGroupId());
|
||||||
elastic.setGrant(dataset.getDmp().getGrant().getId());
|
elastic.setGrant(dataset.getDmp().getGrant().getId());
|
||||||
|
elastic.setCreated(dataset.getCreated());
|
||||||
|
elastic.setModified(dataset.getModified());
|
||||||
|
elastic.setFinalizedAt(dataset.getFinalizedAt());
|
||||||
if (dataset.getDmp().getUsers() != null) {
|
if (dataset.getDmp().getUsers() != null) {
|
||||||
elastic.setCollaborators(dataset.getDmp().getUsers().stream().map(user -> CollaboratorMapper.toElastic(user.getUser())).collect(Collectors.toList()));
|
elastic.setCollaborators(dataset.getDmp().getUsers().stream().map(user -> CollaboratorMapper.toElastic(user.getUser(), user.getRole())).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
DataManagementPlanCriteria dmpCriteria = new DataManagementPlanCriteria();
|
DataManagementPlanCriteria dmpCriteria = new DataManagementPlanCriteria();
|
||||||
dmpCriteria.setAllVersions(true);
|
dmpCriteria.setAllVersions(true);
|
||||||
|
|
|
@ -34,13 +34,17 @@ public class DmpMapper {
|
||||||
elastic.setId(dmp.getId());
|
elastic.setId(dmp.getId());
|
||||||
elastic.setGroupId(dmp.getGroupId());
|
elastic.setGroupId(dmp.getGroupId());
|
||||||
if (dmp.getUsers() != null) {
|
if (dmp.getUsers() != null) {
|
||||||
elastic.setCollaborators(dmp.getUsers().stream().map(user -> CollaboratorMapper.toElastic(user.getUser())).collect(Collectors.toList()));
|
elastic.setCollaborators(dmp.getUsers().stream().map(user -> CollaboratorMapper.toElastic(user.getUser(), user.getRole())).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
elastic.setDescription(dmp.getDescription());
|
elastic.setDescription(dmp.getDescription());
|
||||||
elastic.setGrant(dmp.getGrant().getId());
|
elastic.setGrant(dmp.getGrant().getId());
|
||||||
elastic.setLabel(dmp.getLabel());
|
elastic.setLabel(dmp.getLabel());
|
||||||
elastic.setPublic(dmp.isPublic());
|
elastic.setPublic(dmp.isPublic());
|
||||||
elastic.setStatus(dmp.getStatus());
|
elastic.setStatus(dmp.getStatus());
|
||||||
|
elastic.setCreated(dmp.getCreated());
|
||||||
|
elastic.setModified(dmp.getModified());
|
||||||
|
elastic.setFinalizedAt(dmp.getFinalizedAt());
|
||||||
|
elastic.setPublishedAt(dmp.getPublishedAt());
|
||||||
DataManagementPlanCriteria dmpCriteria = new DataManagementPlanCriteria();
|
DataManagementPlanCriteria dmpCriteria = new DataManagementPlanCriteria();
|
||||||
dmpCriteria.setAllVersions(true);
|
dmpCriteria.setAllVersions(true);
|
||||||
dmpCriteria.setGroupIds(Collections.singletonList(dmp.getGroupId()));
|
dmpCriteria.setGroupIds(Collections.singletonList(dmp.getGroupId()));
|
||||||
|
|
|
@ -2,14 +2,20 @@ package eu.eudat.logic.mapper.elastic.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.entities.Grant;
|
import eu.eudat.data.entities.Grant;
|
||||||
|
import eu.eudat.data.query.definition.helpers.ColumnOrderings;
|
||||||
|
import eu.eudat.data.query.definition.helpers.Ordering;
|
||||||
import eu.eudat.elastic.criteria.DmpCriteria;
|
import eu.eudat.elastic.criteria.DmpCriteria;
|
||||||
|
import eu.eudat.elastic.criteria.SortCriteria;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DmpCriteriaMapper {
|
public class DmpCriteriaMapper {
|
||||||
|
|
||||||
public static DmpCriteria toElasticCriteria(DataManagementPlanCriteria criteria) {
|
public static DmpCriteria toElasticCriteria(DataManagementPlanCriteria criteria, UUID principalID) {
|
||||||
DmpCriteria elastic = new DmpCriteria();
|
DmpCriteria elastic = new DmpCriteria();
|
||||||
|
|
||||||
elastic.setAllowAllVersions(criteria.getAllVersions());
|
elastic.setAllowAllVersions(criteria.getAllVersions());
|
||||||
|
@ -23,6 +29,12 @@ public class DmpCriteriaMapper {
|
||||||
elastic.setOrganizations(criteria.getOrganisations().stream().map(UUID::fromString).collect(Collectors.toList()));
|
elastic.setOrganizations(criteria.getOrganisations().stream().map(UUID::fromString).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
elastic.setPublic(criteria.getIsPublic());
|
elastic.setPublic(criteria.getIsPublic());
|
||||||
|
if (!elastic.isPublic()) {
|
||||||
|
elastic.setCollaborators(Collections.singletonList(principalID));
|
||||||
|
}
|
||||||
|
if (criteria.getRole() != null) {
|
||||||
|
elastic.setRoles(Collections.singletonList(criteria.getRole()));
|
||||||
|
}
|
||||||
if (criteria.getStatus() != null) {
|
if (criteria.getStatus() != null) {
|
||||||
elastic.setStatus(criteria.getStatus().shortValue());
|
elastic.setStatus(criteria.getStatus().shortValue());
|
||||||
}
|
}
|
||||||
|
@ -30,4 +42,18 @@ public class DmpCriteriaMapper {
|
||||||
elastic.setGrantStatus(criteria.getGrantStatus());
|
elastic.setGrantStatus(criteria.getGrantStatus());
|
||||||
return elastic;
|
return elastic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<SortCriteria> toElasticSorting(ColumnOrderings columnOrderings) {
|
||||||
|
List<SortCriteria> sortCriteria = new ArrayList<>();
|
||||||
|
if (columnOrderings.getFieldOrderings() != null && columnOrderings.getFieldOrderings().length > 0) {
|
||||||
|
for (Ordering ordering: columnOrderings.getFieldOrderings()) {
|
||||||
|
SortCriteria sortCriteria1 = new SortCriteria();
|
||||||
|
sortCriteria1.setFieldName(ordering.getFieldName());
|
||||||
|
sortCriteria1.setColumnType(ordering.getColumnType() != null ? SortCriteria.ColumnType.valueOf(ordering.getColumnType().name()): SortCriteria.ColumnType.COLUMN);
|
||||||
|
sortCriteria1.setOrderByType(SortCriteria.OrderByType.valueOf(ordering.getOrderByType().name()));
|
||||||
|
sortCriteria.add(sortCriteria1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sortCriteria;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,19 +24,19 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
private String id;
|
private String id;
|
||||||
private String label;
|
private String label;
|
||||||
private String grant;
|
private String grant;
|
||||||
private String profile;
|
// private String profile;
|
||||||
private Date creationTime;
|
// private Date creationTime;
|
||||||
private Date modifiedTime;
|
private Date modifiedTime;
|
||||||
private String organisations;
|
//private String organisations;
|
||||||
private int version;
|
private int version;
|
||||||
private int status;
|
private int status;
|
||||||
private UUID groupId;
|
private UUID groupId;
|
||||||
private List<DatasetUrlListing> datasets;
|
private List<DatasetUrlListing> datasets;
|
||||||
private List<AssociatedProfile> associatedProfiles;
|
//private List<AssociatedProfile> associatedProfiles;
|
||||||
private List<UserInfoListingModel> users;
|
private List<UserInfoListingModel> users;
|
||||||
private String description;
|
private String description;
|
||||||
private String grantAbbreviation;
|
// private String grantAbbreviation;
|
||||||
private String grantId;
|
// private String grantId;
|
||||||
private Date finalizedAt;
|
private Date finalizedAt;
|
||||||
private Boolean isPublic;
|
private Boolean isPublic;
|
||||||
private Date publishedAt;
|
private Date publishedAt;
|
||||||
|
@ -63,19 +63,19 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
this.grant = grant;
|
this.grant = grant;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProfile() {
|
/* public String getProfile() {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
public void setProfile(String profile) {
|
public void setProfile(String profile) {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public Date getCreationTime() {
|
/*public Date getCreationTime() {
|
||||||
return creationTime;
|
return creationTime;
|
||||||
}
|
}
|
||||||
public void setCreationTime(Date creationTime) {
|
public void setCreationTime(Date creationTime) {
|
||||||
this.creationTime = creationTime;
|
this.creationTime = creationTime;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public Date getModifiedTime() {
|
public Date getModifiedTime() {
|
||||||
return modifiedTime;
|
return modifiedTime;
|
||||||
|
@ -84,12 +84,12 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
this.modifiedTime = modifiedTime;
|
this.modifiedTime = modifiedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOrganisations() {
|
/*public String getOrganisations() {
|
||||||
return organisations;
|
return organisations;
|
||||||
}
|
}
|
||||||
public void setOrganisations(String organisations) {
|
public void setOrganisations(String organisations) {
|
||||||
this.organisations = organisations;
|
this.organisations = organisations;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public int getVersion() {
|
public int getVersion() {
|
||||||
return version;
|
return version;
|
||||||
|
@ -119,12 +119,12 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AssociatedProfile> getAssociatedProfiles() {
|
/*public List<AssociatedProfile> getAssociatedProfiles() {
|
||||||
return associatedProfiles;
|
return associatedProfiles;
|
||||||
}
|
}
|
||||||
public void setAssociatedProfiles(List<AssociatedProfile> associatedProfiles) {
|
public void setAssociatedProfiles(List<AssociatedProfile> associatedProfiles) {
|
||||||
this.associatedProfiles = associatedProfiles;
|
this.associatedProfiles = associatedProfiles;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public List<UserInfoListingModel> getUsers() {
|
public List<UserInfoListingModel> getUsers() {
|
||||||
return users;
|
return users;
|
||||||
|
@ -140,19 +140,19 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGrantAbbreviation() {
|
/*public String getGrantAbbreviation() {
|
||||||
return grantAbbreviation;
|
return grantAbbreviation;
|
||||||
}
|
}
|
||||||
public void setGrantAbbreviation(String grantAbbreviation) {
|
public void setGrantAbbreviation(String grantAbbreviation) {
|
||||||
this.grantAbbreviation = grantAbbreviation;
|
this.grantAbbreviation = grantAbbreviation;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public String getGrantId() {
|
/*public String getGrantId() {
|
||||||
return grantId;
|
return grantId;
|
||||||
}
|
}
|
||||||
public void setGrantId(String grantId) {
|
public void setGrantId(String grantId) {
|
||||||
this.grantId = grantId;
|
this.grantId = grantId;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public Date getFinalizedAt() {
|
public Date getFinalizedAt() {
|
||||||
return finalizedAt;
|
return finalizedAt;
|
||||||
|
@ -187,8 +187,8 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.groupId = entity.getGroupId();
|
this.groupId = entity.getGroupId();
|
||||||
this.creationTime = entity.getCreated();
|
/*this.creationTime = entity.getCreated();
|
||||||
this.associatedProfiles = entity.getAssociatedDmps().stream().map(item -> new AssociatedProfile().fromData(item)).collect(Collectors.toList());
|
this.associatedProfiles = entity.getAssociatedDmps().stream().map(item -> new AssociatedProfile().fromData(item)).collect(Collectors.toList());*/
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.groupId = entity.getGroupId();
|
this.groupId = entity.getGroupId();
|
||||||
this.creationTime = entity.getCreated();
|
// this.creationTime = entity.getCreated();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,26 +205,26 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
this.status = entity.getStatus();
|
this.status = entity.getStatus();
|
||||||
this.version = entity.getVersion();
|
this.version = entity.getVersion();
|
||||||
this.grant = entity.getGrant().getLabel();
|
this.grant = entity.getGrant().getLabel();
|
||||||
if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
/*if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
||||||
this.creationTime = entity.getCreated();
|
this.creationTime = entity.getCreated();*/
|
||||||
this.modifiedTime = entity.getModified();
|
this.modifiedTime = entity.getModified();
|
||||||
this.organisations = LabelBuilder.getLabel(entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()));
|
// this.organisations = LabelBuilder.getLabel(entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()));
|
||||||
this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());
|
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.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
||||||
this.description = entity.getDescription();
|
this.description = entity.getDescription();
|
||||||
this.grantAbbreviation = entity.getGrant().getAbbreviation();
|
// this.grantAbbreviation = entity.getGrant().getAbbreviation();
|
||||||
this.grantId = entity.getGrant().getId().toString();
|
// this.grantId = entity.getGrant().getId().toString();
|
||||||
this.finalizedAt = entity.getFinalizedAt();
|
this.finalizedAt = entity.getFinalizedAt();
|
||||||
this.isPublic = entity.isPublic();
|
this.isPublic = entity.isPublic();
|
||||||
this.publishedAt = entity.getPublishedAt();
|
this.publishedAt = entity.getPublishedAt();
|
||||||
|
|
||||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
/*if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||||
this.associatedProfiles = new LinkedList<>();
|
this.associatedProfiles = new LinkedList<>();
|
||||||
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) {
|
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) {
|
||||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
||||||
this.associatedProfiles.add(associatedProfile);
|
this.associatedProfiles.add(associatedProfile);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue