Fixed some issues and added Dataset description on index
This commit is contained in:
parent
35b89edabc
commit
5ec02a89de
|
@ -9,7 +9,7 @@ import java.util.UUID;
|
|||
* Created by ikalyvas on 7/5/2018.
|
||||
*/
|
||||
public class DatasetCriteria extends Criteria {
|
||||
private String label;
|
||||
private String like;
|
||||
private List<UUID> datasetTemplates;
|
||||
private Short status;
|
||||
private List<UUID> dmps;
|
||||
|
@ -22,12 +22,12 @@ public class DatasetCriteria extends Criteria {
|
|||
private boolean isPublic;
|
||||
private Short grantStatus;
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
public String getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
public void setLike(String like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
public List<UUID> getDatasetTemplates() {
|
||||
|
|
|
@ -46,6 +46,7 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
private String id;
|
||||
private List<Tag> tags = new LinkedList<>();
|
||||
private String label;
|
||||
private String description;
|
||||
private UUID template;
|
||||
private Short status;
|
||||
private UUID dmp;
|
||||
|
@ -81,6 +82,14 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
this.label = label;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public UUID getTemplate() {
|
||||
return template;
|
||||
}
|
||||
|
@ -166,6 +175,7 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
builder.startObject();
|
||||
builder.field("id", this.id);
|
||||
builder.field("label", this.label);
|
||||
builder.field("description", this.description);
|
||||
builder.field("template", this.template.toString());
|
||||
builder.field("status", this.status.toString());
|
||||
builder.field("dmp", this.dmp.toString());
|
||||
|
@ -227,6 +237,7 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
this.tags = ((List<HashMap>) fields.get("tags")).stream().map(hashMap -> new Tag().fromElasticEntity(hashMap)).collect(Collectors.toList());
|
||||
}
|
||||
this.label = (String) fields.get("label");
|
||||
this.description = (String) fields.get("description");
|
||||
this.template = UUID.fromString((String) fields.get("template"));
|
||||
this.status = Short.valueOf((String) fields.get("status"));
|
||||
this.dmp = UUID.fromString((String) fields.get("dmp"));
|
||||
|
|
|
@ -3,9 +3,6 @@ package eu.eudat.elastic.repository;
|
|||
import eu.eudat.elastic.criteria.DatasetCriteria;
|
||||
import eu.eudat.elastic.entities.Dataset;
|
||||
import eu.eudat.elastic.entities.Tag;
|
||||
import org.elasticsearch.client.core.CountRequest;
|
||||
import org.elasticsearch.client.core.CountResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexRequest;
|
||||
import org.elasticsearch.action.get.GetRequest;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
|
@ -13,6 +10,9 @@ import org.elasticsearch.action.search.SearchRequest;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.client.RequestOptions;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.elasticsearch.client.core.CountRequest;
|
||||
import org.elasticsearch.client.core.CountResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexRequest;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
|
@ -26,8 +26,8 @@ import java.io.IOException;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service("datasetRepository")
|
||||
public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteria> {
|
||||
|
@ -53,23 +53,26 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Dataset> query(DatasetCriteria criteria) throws ExecutionException, InterruptedException, IOException {
|
||||
public List<Dataset> query(DatasetCriteria criteria) throws IOException {
|
||||
SearchRequest searchRequest = new SearchRequest("datasets");
|
||||
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||||
|
||||
CountRequest countRequest = new CountRequest("datasets");
|
||||
countRequest.query(QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", new short[]{Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()})));
|
||||
countRequest.query(QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList()))));
|
||||
CountResponse countResponse = getClient().count(countRequest, RequestOptions.DEFAULT);
|
||||
Long count = countResponse.getCount();
|
||||
|
||||
searchSourceBuilder.size(count.intValue());
|
||||
|
||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", new short[]{Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()}));
|
||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList())));
|
||||
if (criteria.isPublic()) {
|
||||
boolQuery = boolQuery.should(QueryBuilders.termQuery("public.keyword", "true"));
|
||||
}
|
||||
if (criteria.getLabel() != null && !criteria.getLabel().isEmpty()) {
|
||||
boolQuery = boolQuery.should(QueryBuilders.matchPhrasePrefixQuery("label", criteria.getLabel()));
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) {
|
||||
boolQuery = boolQuery.should(QueryBuilders.queryStringQuery("*" + criteria.getLike() + "*").fields(Stream.of(new Object[][] {
|
||||
{ "label", 1.0f },
|
||||
{ "description", 1.0f },
|
||||
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Float) data[1]))));
|
||||
}
|
||||
|
||||
if (criteria.getDatasetTemplates() != null && criteria.getDatasetTemplates().size() > 0) {
|
||||
|
@ -100,8 +103,10 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
|||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("collaborators.id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
if (criteria.getAllowAllVersions() != null && !criteria.getAllowAllVersions()) {
|
||||
boolQuery = boolQuery.should(QueryBuilders.termQuery("lastVersion.keyword", "true"));
|
||||
if (!criteria.isPublic()) {
|
||||
if (criteria.getAllowAllVersions() != null && !criteria.getAllowAllVersions()) {
|
||||
boolQuery = boolQuery.should(QueryBuilders.termQuery("lastVersion.keyword", "true"));
|
||||
}
|
||||
}
|
||||
|
||||
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
|
||||
|
|
|
@ -926,6 +926,7 @@ public class DataManagementPlanManager {
|
|||
eu.eudat.elastic.entities.Dataset datasetElastic = new eu.eudat.elastic.entities.Dataset();
|
||||
datasetElastic.setId(dataset1.getId().toString());
|
||||
datasetElastic.setLabel(dataset1.getLabel());
|
||||
datasetElastic.setDescription(dataset1.getDescription());
|
||||
datasetElastic.setTemplate(dataset1.getProfile().getId());
|
||||
datasetElastic.setStatus(dataset1.getStatus());
|
||||
datasetElastic.setDmp(dataset1.getDmp().getId());
|
||||
|
|
|
@ -52,7 +52,6 @@ import org.springframework.core.env.Environment;
|
|||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
@ -73,9 +72,7 @@ import javax.xml.xpath.XPathConstants;
|
|||
import javax.xml.xpath.XPathFactory;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -109,7 +106,7 @@ public class DatasetManager {
|
|||
|
||||
public DataTableData<DatasetListingModel> getPaged(DatasetTableRequest datasetTableRequest, Principal principal) throws Exception {
|
||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||
datasetCriteria.setLabel(datasetTableRequest.getCriteria().getLike());
|
||||
datasetCriteria.setLike(datasetTableRequest.getCriteria().getLike());
|
||||
datasetCriteria.setDatasetTemplates(datasetTableRequest.getCriteria().getDatasetTemplates());
|
||||
if (datasetTableRequest.getCriteria().getStatus() != null) {
|
||||
datasetCriteria.setStatus(datasetTableRequest.getCriteria().getStatus().shortValue());
|
||||
|
@ -194,7 +191,7 @@ public class DatasetManager {
|
|||
|
||||
public DataTableData<DatasetListingModel> getPaged(DatasetPublicTableRequest datasetTableRequest, Principal principal) throws Exception {
|
||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||
datasetCriteria.setLabel(datasetTableRequest.getCriteria().getLike());
|
||||
datasetCriteria.setLike(datasetTableRequest.getCriteria().getLike());
|
||||
datasetCriteria.setDatasetTemplates(datasetTableRequest.getCriteria().getDatasetProfile());
|
||||
datasetCriteria.setDmps(datasetTableRequest.getCriteria().getDmpIds());
|
||||
datasetCriteria.setGrants(datasetTableRequest.getCriteria().getGrants());
|
||||
|
@ -593,6 +590,7 @@ public class DatasetManager {
|
|||
dataset.setId(datasetWizardModel.getId().toString());
|
||||
dataset.setTags(datasetWizardModel.getTags());
|
||||
dataset.setLabel(datasetWizardModel.getLabel());
|
||||
dataset.setDescription(datasetWizardModel.getDescription());
|
||||
dataset.setTemplate(datasetWizardModel.getProfile());
|
||||
dataset.setStatus(datasetWizardModel.getStatus());
|
||||
dataset.setDmp(datasetWizardModel.getDmp().getId());
|
||||
|
|
|
@ -139,9 +139,6 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
|
|||
request.criteria.grantStatus = value.grantStatus;
|
||||
}
|
||||
request.criteria.isPublic = this.isPublic;
|
||||
if (this.isPublic) {
|
||||
request.criteria.allVersions = true;
|
||||
}
|
||||
// if (this.itemId) {
|
||||
// // request.criteria.groupIds = [this.itemId];
|
||||
// request.criteria.allVersions = true;
|
||||
|
|
Loading…
Reference in New Issue