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({
|
||||
@NamedEntityGraph(
|
||||
name = "dataManagementPlanListingModel",
|
||||
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"), @NamedAttributeNode("associatedDmps"),
|
||||
@NamedAttributeNode("grant"), @NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")},
|
||||
subgraphs = {
|
||||
attributeNodes = {
|
||||
@NamedAttributeNode("grant"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile")}/*,*/
|
||||
/*subgraphs = {
|
||||
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")}),
|
||||
}
|
||||
}*/
|
||||
),
|
||||
@NamedEntityGraph(
|
||||
name = "fullyDetailed",
|
||||
|
|
|
@ -21,6 +21,9 @@ public class DatasetCriteria extends Criteria {
|
|||
private List<Tag> tags;
|
||||
private boolean isPublic;
|
||||
private Short grantStatus;
|
||||
private int offset;
|
||||
private int size;
|
||||
private List<SortCriteria> sortCriteria;
|
||||
|
||||
public String getLike() {
|
||||
return like;
|
||||
|
@ -117,4 +120,28 @@ public class DatasetCriteria extends Criteria {
|
|||
public void setGrantStatus(Short 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> grants;
|
||||
private List<UUID> collaborators;
|
||||
private List<Integer> roles;
|
||||
private List<UUID> organizations;
|
||||
private boolean isPublic;
|
||||
private List<UUID> groupIds;
|
||||
private boolean allowAllVersions;
|
||||
private Short grantStatus;
|
||||
private int offset;
|
||||
private int size;
|
||||
private List<SortCriteria> sortCriteria;
|
||||
|
||||
|
||||
public String getLike() {
|
||||
return like;
|
||||
|
@ -55,6 +60,14 @@ public class DmpCriteria extends Criteria {
|
|||
this.collaborators = collaborators;
|
||||
}
|
||||
|
||||
public List<Integer> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<Integer> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public List<UUID> getOrganizations() {
|
||||
return organizations;
|
||||
}
|
||||
|
@ -94,4 +107,28 @@ public class DmpCriteria extends Criteria {
|
|||
public void setGrantStatus(Short 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.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Collaborator implements ElasticEntity<Collaborator> {
|
||||
private String id;
|
||||
private String name;
|
||||
private int role;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
|
@ -26,11 +26,20 @@ public class Collaborator implements ElasticEntity<Collaborator> {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public int getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(int role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
||||
builder.startObject();
|
||||
builder.field("id", this.id);
|
||||
builder.field("name", this.name);
|
||||
builder.field("role", this.role);
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
@ -39,6 +48,7 @@ public class Collaborator implements ElasticEntity<Collaborator> {
|
|||
public Collaborator fromElasticEntity(Map fields) {
|
||||
this.id = (String) fields.get("id");
|
||||
this.name = (String) fields.get("name");
|
||||
this.role = (int) fields.get("role");
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -59,6 +60,9 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
private Boolean isPublic;
|
||||
private Short grantStatus;
|
||||
private String formData;
|
||||
private Date created;
|
||||
private Date modified;
|
||||
private Date finalizedAt;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
|
@ -188,6 +192,30 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
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
|
||||
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
||||
builder.startObject();
|
||||
|
@ -197,6 +225,9 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
builder.field("template", this.template.toString());
|
||||
builder.field("status", this.status.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) {
|
||||
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.group = UUID.fromString((String) fields.get("group"));
|
||||
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) {
|
||||
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 java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Dmp implements ElasticEntity<Dmp> {
|
||||
|
@ -55,6 +52,11 @@ public class Dmp implements ElasticEntity<Dmp> {
|
|||
private List<Dataset> datasets;
|
||||
private UUID grant;
|
||||
private Short grantStatus;
|
||||
private Date created;
|
||||
private Date modified;
|
||||
private Date finalizedAt;
|
||||
private Date publishedAt;
|
||||
private String doi;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
@ -168,6 +170,46 @@ public class Dmp implements ElasticEntity<Dmp> {
|
|||
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
|
||||
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
||||
builder.startObject();
|
||||
|
@ -233,6 +275,11 @@ public class Dmp implements ElasticEntity<Dmp> {
|
|||
builder.field(MapKey.GRANT.getName(), this.grant.toString());
|
||||
}
|
||||
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();
|
||||
return builder;
|
||||
}
|
||||
|
@ -282,7 +329,12 @@ public class Dmp implements ElasticEntity<Dmp> {
|
|||
ISPUBLIC ("isPublic"),
|
||||
DATASETS ("datasets"),
|
||||
GRANT ("grant"),
|
||||
GRANTSTATUS ("grantStatus");
|
||||
GRANTSTATUS ("grantStatus"),
|
||||
CREATED ("created"),
|
||||
MODIFIED ("modified"),
|
||||
FINALIZEDAT ("finalizedAt"),
|
||||
PUBLISHEDAT ("publishedAt"),
|
||||
DOI ("doi");
|
||||
|
||||
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.ParsedNested;
|
||||
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.LoggerFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
@ -120,6 +123,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
|||
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())));
|
||||
List<SortBuilder> sortBuilders = new ArrayList<>();
|
||||
if (criteria.isPublic()) {
|
||||
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.public", "true"));
|
||||
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());
|
||||
}
|
||||
|
||||
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());
|
||||
searchSourceBuilder.query(nestedQueryBuilder);
|
||||
searchSourceBuilder.query(nestedQueryBuilder).from(criteria.getOffset()).size(criteria.getSize());
|
||||
sortBuilders.forEach(searchSourceBuilder::sort);
|
||||
searchRequest.source(searchSourceBuilder);
|
||||
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
||||
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.reindex.DeleteByQueryRequest;
|
||||
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.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -97,6 +100,7 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
|||
searchSourceBuilder.size(count.intValue());
|
||||
|
||||
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()) {
|
||||
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.ISPUBLIC.getName(), true));
|
||||
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) {
|
||||
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()) {
|
||||
|
@ -145,7 +153,26 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
|||
} else {
|
||||
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);
|
||||
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());
|
||||
|
@ -153,6 +180,67 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
|||
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() {
|
||||
try {
|
||||
if (!this.exists()) {
|
||||
|
|
|
@ -182,14 +182,14 @@ public class DashBoardManager {
|
|||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
||||
.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")
|
||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||
.take(numberofactivities)
|
||||
.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;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import eu.eudat.data.enumeration.notification.ActiveStatus;
|
|||
import eu.eudat.data.enumeration.notification.ContactType;
|
||||
import eu.eudat.data.enumeration.notification.NotificationType;
|
||||
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.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.elastic.criteria.DmpCriteria;
|
||||
|
@ -129,13 +130,19 @@ public class DataManagementPlanManager {
|
|||
List<Dmp> dmps = null;
|
||||
QueryableList<DMP> items = null;
|
||||
QueryableList<DMP> authItems = null;
|
||||
Long totalData = 0L;
|
||||
if (apiContext.getOperationsContext().getElasticRepository().getDmpRepository() != null) {
|
||||
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);
|
||||
if (dmps != null && !dmps.isEmpty()) {
|
||||
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())));
|
||||
PaginationManager.applyOrder(items, dataManagementPlanTableRequest);
|
||||
totalData = apiContext.getOperationsContext().getElasticRepository().getDmpRepository().count(criteria);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.warn(ex.getMessage(), ex);
|
||||
|
@ -144,7 +151,6 @@ public class DataManagementPlanManager {
|
|||
}
|
||||
if (items == null) {
|
||||
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
||||
}
|
||||
List<Integer> roles = new LinkedList<>();
|
||||
if (!dataManagementPlanTableRequest.getCriteria().isOnlyPublic()) {
|
||||
if (dataManagementPlanTableRequest.getCriteria().getRole() != null)
|
||||
|
@ -153,54 +159,108 @@ public class DataManagementPlanManager {
|
|||
} else {
|
||||
authItems = items;
|
||||
}
|
||||
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
||||
totalData = authItems.count();
|
||||
items = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<>();
|
||||
|
||||
CompletableFuture itemsFuture;
|
||||
if (fieldsGroup.equals("listing")) {
|
||||
if (!dataManagementPlanTableRequest.getCriteria().isOnlyPublic()) {
|
||||
itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
|
||||
.distinct()
|
||||
.selectAsync(item -> {
|
||||
List<DMP> dmps1 = items.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
|
||||
.distinct().toList();
|
||||
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.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.getDmp().getUsers().stream()
|
||||
*//*.filter(dataset -> dataset.getDmp().getUsers().stream()
|
||||
.filter(x -> x.getUser().getId().equals(principalID))
|
||||
.collect(Collectors.toList()).size() > 0)
|
||||
.collect(Collectors.toList()).size() > 0)*//*
|
||||
.collect(Collectors.toSet()));
|
||||
return new DataManagementPlanListingModel().fromDataModelDatasets(item);
|
||||
})
|
||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));*/
|
||||
} else {
|
||||
itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
|
||||
.distinct()
|
||||
.selectAsync(item -> {
|
||||
List<DMP> dmps1 = items.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
|
||||
.distinct().toList();
|
||||
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.getDataset().stream()
|
||||
.filter(dataset -> dataset.getStatus().equals(Dataset.Status.FINALISED.getValue())).collect(Collectors.toSet()));
|
||||
return new DataManagementPlanListingModel().fromDataModelDatasets(item);
|
||||
})
|
||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));*/
|
||||
}
|
||||
} else if (fieldsGroup.equals("autocomplete")) {
|
||||
itemsFuture = pagedItems
|
||||
dataTable.setData(items
|
||||
.distinct()
|
||||
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModelAutoComplete(item))
|
||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
||||
.select(item -> new DataManagementPlanListingModel().fromDataModelAutoComplete(item)));
|
||||
} else {
|
||||
itemsFuture = pagedItems
|
||||
dataTable.setData(items
|
||||
.distinct()
|
||||
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModelAssociatedProfiles(item))
|
||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
||||
.select(item -> new DataManagementPlanListingModel().fromDataModelAssociatedProfiles(item)));
|
||||
}
|
||||
|
||||
CompletableFuture countFuture = authItems.distinct().countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
|
||||
CompletableFuture.allOf(itemsFuture, countFuture).join();
|
||||
//CompletableFuture countFuture = authItems.distinct().countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
|
||||
dataTable.setTotalCount(totalData);
|
||||
//CompletableFuture.allOf(itemsFuture).join();
|
||||
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 {
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = new eu.eudat.models.data.dmp.DataManagementPlan();
|
||||
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||
|
@ -864,6 +924,7 @@ public class DataManagementPlanManager {
|
|||
datasetElastic.setCollaborators(dataset1.getDmp().getUsers().stream().map(user -> {
|
||||
Collaborator collaborator = new Collaborator();
|
||||
collaborator.setId(user.getId().toString());
|
||||
collaborator.setRole(user.getRole());
|
||||
// collaborator.setName(user.getUser().getName());
|
||||
return collaborator;
|
||||
}).collect(Collectors.toList()));
|
||||
|
|
|
@ -22,6 +22,7 @@ import eu.eudat.exceptions.security.UnauthorisedException;
|
|||
import eu.eudat.logic.builders.BuilderFactory;
|
||||
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
||||
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.services.ApiContext;
|
||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||
|
@ -137,9 +138,21 @@ public class DatasetManager {
|
|||
if (datasetTableRequest.getCriteria().getIsPublic() != null) {
|
||||
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) {
|
||||
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;
|
||||
try {
|
||||
datasets = datasetRepository.exists() ?
|
||||
|
@ -206,6 +219,11 @@ public class DatasetManager {
|
|||
datasetCriteria.setDatasetTemplates(datasetTableRequest.getCriteria().getDatasetProfile());
|
||||
datasetCriteria.setDmps(datasetTableRequest.getCriteria().getDmpIds());
|
||||
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;
|
||||
try {
|
||||
datasets = datasetRepository.exists() ?
|
||||
|
@ -214,9 +232,9 @@ public class DatasetManager {
|
|||
logger.warn(ex.getMessage());
|
||||
datasets = null;
|
||||
}
|
||||
datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
|
||||
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();
|
||||
/*QueryableList<Dataset> items;
|
||||
/*datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
|
||||
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();*/
|
||||
QueryableList<Dataset> items;
|
||||
if (datasets != null) {
|
||||
if (!datasets.isEmpty()) {
|
||||
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()}));
|
||||
} else {
|
||||
items = datasetTableRequest.applyCriteria();
|
||||
}*/
|
||||
}
|
||||
|
||||
if (principal.getId() != null && datasetTableRequest.getCriteria().getRole() != null) {
|
||||
items.where((builder, root) -> {
|
||||
|
|
|
@ -5,10 +5,11 @@ import eu.eudat.elastic.entities.Collaborator;
|
|||
|
||||
public class CollaboratorMapper {
|
||||
|
||||
public static Collaborator toElastic(UserInfo user) {
|
||||
public static Collaborator toElastic(UserInfo user, Integer role) {
|
||||
Collaborator elastic = new Collaborator();
|
||||
elastic.setId(user.getId().toString());
|
||||
elastic.setName(user.getName());
|
||||
elastic.setRole(role);
|
||||
return elastic;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,11 @@ public class DatasetMapper {
|
|||
elastic.setDmp(dataset.getDmp().getId());
|
||||
elastic.setGroup(dataset.getDmp().getGroupId());
|
||||
elastic.setGrant(dataset.getDmp().getGrant().getId());
|
||||
elastic.setCreated(dataset.getCreated());
|
||||
elastic.setModified(dataset.getModified());
|
||||
elastic.setFinalizedAt(dataset.getFinalizedAt());
|
||||
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();
|
||||
dmpCriteria.setAllVersions(true);
|
||||
|
|
|
@ -34,13 +34,17 @@ public class DmpMapper {
|
|||
elastic.setId(dmp.getId());
|
||||
elastic.setGroupId(dmp.getGroupId());
|
||||
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.setGrant(dmp.getGrant().getId());
|
||||
elastic.setLabel(dmp.getLabel());
|
||||
elastic.setPublic(dmp.isPublic());
|
||||
elastic.setStatus(dmp.getStatus());
|
||||
elastic.setCreated(dmp.getCreated());
|
||||
elastic.setModified(dmp.getModified());
|
||||
elastic.setFinalizedAt(dmp.getFinalizedAt());
|
||||
elastic.setPublishedAt(dmp.getPublishedAt());
|
||||
DataManagementPlanCriteria dmpCriteria = new DataManagementPlanCriteria();
|
||||
dmpCriteria.setAllVersions(true);
|
||||
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.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.SortCriteria;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DmpCriteriaMapper {
|
||||
|
||||
public static DmpCriteria toElasticCriteria(DataManagementPlanCriteria criteria) {
|
||||
public static DmpCriteria toElasticCriteria(DataManagementPlanCriteria criteria, UUID principalID) {
|
||||
DmpCriteria elastic = new DmpCriteria();
|
||||
|
||||
elastic.setAllowAllVersions(criteria.getAllVersions());
|
||||
|
@ -23,6 +29,12 @@ public class DmpCriteriaMapper {
|
|||
elastic.setOrganizations(criteria.getOrganisations().stream().map(UUID::fromString).collect(Collectors.toList()));
|
||||
}
|
||||
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) {
|
||||
elastic.setStatus(criteria.getStatus().shortValue());
|
||||
}
|
||||
|
@ -30,4 +42,18 @@ public class DmpCriteriaMapper {
|
|||
elastic.setGrantStatus(criteria.getGrantStatus());
|
||||
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 label;
|
||||
private String grant;
|
||||
private String profile;
|
||||
private Date creationTime;
|
||||
// private String profile;
|
||||
// private Date creationTime;
|
||||
private Date modifiedTime;
|
||||
private String organisations;
|
||||
//private String organisations;
|
||||
private int version;
|
||||
private int status;
|
||||
private UUID groupId;
|
||||
private List<DatasetUrlListing> datasets;
|
||||
private List<AssociatedProfile> associatedProfiles;
|
||||
//private List<AssociatedProfile> associatedProfiles;
|
||||
private List<UserInfoListingModel> users;
|
||||
private String description;
|
||||
private String grantAbbreviation;
|
||||
private String grantId;
|
||||
// private String grantAbbreviation;
|
||||
// private String grantId;
|
||||
private Date finalizedAt;
|
||||
private Boolean isPublic;
|
||||
private Date publishedAt;
|
||||
|
@ -63,19 +63,19 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.grant = grant;
|
||||
}
|
||||
|
||||
public String getProfile() {
|
||||
/* public String getProfile() {
|
||||
return profile;
|
||||
}
|
||||
public void setProfile(String profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
}*/
|
||||
|
||||
public Date getCreationTime() {
|
||||
/*public Date getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
public void setCreationTime(Date creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
}*/
|
||||
|
||||
public Date getModifiedTime() {
|
||||
return modifiedTime;
|
||||
|
@ -84,12 +84,12 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.modifiedTime = modifiedTime;
|
||||
}
|
||||
|
||||
public String getOrganisations() {
|
||||
/*public String getOrganisations() {
|
||||
return organisations;
|
||||
}
|
||||
public void setOrganisations(String organisations) {
|
||||
this.organisations = organisations;
|
||||
}
|
||||
}*/
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
|
@ -119,12 +119,12 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.status = status;
|
||||
}
|
||||
|
||||
public List<AssociatedProfile> getAssociatedProfiles() {
|
||||
/*public List<AssociatedProfile> getAssociatedProfiles() {
|
||||
return associatedProfiles;
|
||||
}
|
||||
public void setAssociatedProfiles(List<AssociatedProfile> associatedProfiles) {
|
||||
this.associatedProfiles = associatedProfiles;
|
||||
}
|
||||
}*/
|
||||
|
||||
public List<UserInfoListingModel> getUsers() {
|
||||
return users;
|
||||
|
@ -140,19 +140,19 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public String getGrantAbbreviation() {
|
||||
/*public String getGrantAbbreviation() {
|
||||
return grantAbbreviation;
|
||||
}
|
||||
public void setGrantAbbreviation(String grantAbbreviation) {
|
||||
this.grantAbbreviation = grantAbbreviation;
|
||||
}
|
||||
}*/
|
||||
|
||||
public String getGrantId() {
|
||||
/*public String getGrantId() {
|
||||
return grantId;
|
||||
}
|
||||
public void setGrantId(String grantId) {
|
||||
this.grantId = grantId;
|
||||
}
|
||||
}*/
|
||||
|
||||
public Date getFinalizedAt() {
|
||||
return finalizedAt;
|
||||
|
@ -187,8 +187,8 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.id = entity.getId().toString();
|
||||
this.label = entity.getLabel();
|
||||
this.groupId = entity.getGroupId();
|
||||
this.creationTime = entity.getCreated();
|
||||
this.associatedProfiles = entity.getAssociatedDmps().stream().map(item -> new AssociatedProfile().fromData(item)).collect(Collectors.toList());
|
||||
/*this.creationTime = entity.getCreated();
|
||||
this.associatedProfiles = entity.getAssociatedDmps().stream().map(item -> new AssociatedProfile().fromData(item)).collect(Collectors.toList());*/
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.id = entity.getId().toString();
|
||||
this.label = entity.getLabel();
|
||||
this.groupId = entity.getGroupId();
|
||||
this.creationTime = entity.getCreated();
|
||||
// this.creationTime = entity.getCreated();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -205,26 +205,26 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
this.status = entity.getStatus();
|
||||
this.version = entity.getVersion();
|
||||
this.grant = entity.getGrant().getLabel();
|
||||
if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
||||
this.creationTime = entity.getCreated();
|
||||
/*if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
||||
this.creationTime = entity.getCreated();*/
|
||||
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.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
||||
this.description = entity.getDescription();
|
||||
this.grantAbbreviation = entity.getGrant().getAbbreviation();
|
||||
this.grantId = entity.getGrant().getId().toString();
|
||||
// this.grantAbbreviation = entity.getGrant().getAbbreviation();
|
||||
// this.grantId = entity.getGrant().getId().toString();
|
||||
this.finalizedAt = entity.getFinalizedAt();
|
||||
this.isPublic = entity.isPublic();
|
||||
this.publishedAt = entity.getPublishedAt();
|
||||
|
||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||
/*if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||
this.associatedProfiles = new LinkedList<>();
|
||||
for (DatasetProfile datasetProfile: entity.getAssociatedDmps()) {
|
||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(datasetProfile);
|
||||
this.associatedProfiles.add(associatedProfile);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue