Commit 029ab3b4 authored by Matija Obreza's avatar Matija Obreza

Use isFullltextQuery()

parent 501f785f
......@@ -28,10 +28,7 @@ import java.util.UUID;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.auditlog.service.AuditTrailService;
import org.genesys.catalog.model.dataset.Dataset;
import org.genesys.catalog.service.DatasetService;
......@@ -70,6 +67,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.Tuple;
import com.querydsl.jpa.impl.JPAQuery;
......@@ -270,7 +269,7 @@ public class AccessionServiceImpl implements AccessionService {
public long countAccessions(AccessionFilter filter) {
long total = elasticsearchService.count(Accession.class, filter);
if (total < 10000 && StringUtils.isBlank(filter._text)) {
if (total < 10000 && ! filter.isFulltextQuery()) {
// If total is below 10K and no full-text query, use actual count
total = accessionRepository.count(filter.buildPredicate());
}
......@@ -369,7 +368,7 @@ public class AccessionServiceImpl implements AccessionService {
@Override
// @Cacheable(value = "apiResponses.accessionApi1.list", unless = "#result == null", keyGenerator = "shortFilterKeyGenerator")
public Page<Accession> list(AccessionFilter filter, Pageable page) {
if (StringUtils.isNotBlank(filter._text)) {
if (filter.isFulltextQuery()) {
return elasticsearchService.findAll(Accession.class, filter, filter._text, page);
}
......
......@@ -199,7 +199,7 @@ public class DownloadServiceImpl implements DownloadService {
@Override
public void writeXlsxMCPD(AccessionFilter filter, OutputStream outputStream) throws IOException {
if (StringUtils.isNotBlank(filter._text)) {
if (filter.isFulltextQuery()) {
throw new IOException("Cannot download MCPD when using full-text queries.");
}
......@@ -774,7 +774,7 @@ public class DownloadServiceImpl implements DownloadService {
@Override
public void writeXlsxPDCI(final AccessionFilter filter, final OutputStream outputStream) throws IOException {
if (StringUtils.isNotBlank(filter._text)) {
if (filter.isFulltextQuery()) {
throw new IOException("Cannot download MCPD when using full-text queries.");
}
......
......@@ -27,7 +27,6 @@ import java.util.stream.Collectors;
import javax.sql.DataSource;
import org.apache.commons.lang3.StringUtils;
import org.genesys2.server.exception.MaxPageLimitException;
import org.genesys2.server.model.elastic.AccessionDetails;
import org.genesys2.server.model.genesys.Accession;
......@@ -477,7 +476,7 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
query.where(filt);
if (StringUtils.isNotBlank(filter._text)) {
if (filter.isFulltextQuery()) {
return elasticsearchService.distinctCoordinates(filt, filter._text);
} else {
List<Tuple> results = query.fetch();
......
......@@ -41,7 +41,6 @@ import java.util.zip.ZipOutputStream;
import javax.persistence.EntityManager;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.security.SecurityContextUtil;
import org.genesys.blocks.security.model.AclSid;
import org.genesys.blocks.security.service.CustomAclService;
......@@ -1053,7 +1052,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
// TODO FIXME Need proper term URLs
public void writeAccessions(final AccessionFilter filter, final OutputStream outputStream) throws Exception {
if (StringUtils.isNotBlank(filter._text)) {
if (filter.isFulltextQuery()) {
throw new IOException("Cannot download DWC-A when using full-text queries.");
}
......
......@@ -22,6 +22,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.validation.ConstraintViolationException;
import org.apache.commons.lang3.RandomStringUtils;
import org.genesys.catalog.model.filters.DescriptorFilter;
import org.genesys.catalog.model.traits.Descriptor;
......@@ -33,7 +35,6 @@ import org.genesys.catalog.model.vocab.VocabularyTerm;
import org.genesys2.server.exception.InvalidApiUsageException;
import org.genesys2.server.exception.NotFoundElement;
import org.genesys2.server.model.PublishState;
import org.genesys2.server.model.impl.Crop;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.dao.ConcurrencyFailureException;
......@@ -47,8 +48,6 @@ import org.springframework.data.domain.Sort;
import com.google.common.collect.Lists;
import javax.validation.ConstraintViolationException;
public class DescriptorServiceTest extends CatalogServiceTest {
private static final String DESCRIPTOR_TITLE_1 = "D1";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment