Commit b2f78498 authored by Matija Obreza's avatar Matija Obreza

Added licensing headers and updated obsolete fragments

parent 127ef78e
/**
* Copyright 2016 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.genesys2.server.service;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilters;
......
/**
* Copyright 2016 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.genesys2.server.service;
public interface IndexAliasConstants {
......
/**
* Copyright 2016 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.genesys2.server.service.impl;
import com.hazelcast.core.ILock;
......@@ -129,7 +145,7 @@ public class ElasticSearchManagementServiceImpl implements ElasticSearchManageme
*/
@Override
public void regenerateIndexes(final String indexName) throws ElasticsearchException {
Class clazz = null;
Class<?> clazz = null;
String readAlias = null;
String writeAlias = null;
if (IndexAliasConstants.INDEX_FULLTEXT.equals(indexName)) {
......
/**
* Copyright 2016 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.genesys2.server.service.impl;
import java.sql.ResultSet;
......@@ -85,7 +101,7 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
@Override
public Page<AccessionDetails> search(String query, Pageable pageable) throws SearchException {
SearchQuery searchQuery = new NativeSearchQueryBuilder().withIndices(IndexAliasConstants.INDEXALIAS_PASSPORT_READ).withTypes(IndexAliasConstants.PASSPORT_TYPE)
.withQuery(org.elasticsearch.index.query.QueryBuilders.queryString(query).defaultOperator(Operator.AND)).withPageable(pageable).build();
.withQuery(org.elasticsearch.index.query.QueryBuilders.queryStringQuery(query).defaultOperator(Operator.AND)).withPageable(pageable).build();
try {
Page<AccessionDetails> sampleEntities = elasticsearchTemplate.queryForPage(searchQuery, AccessionDetails.class);
......@@ -98,7 +114,7 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
@Override
public List<String> autocompleteSearch(String query) throws SearchException {
SearchQuery searchQuery = new NativeSearchQueryBuilder().withIndices(IndexAliasConstants.INDEXALIAS_PASSPORT_READ).withTypes(IndexAliasConstants.PASSPORT_TYPE)
.withQuery(org.elasticsearch.index.query.QueryBuilders.queryString("acceNumb:(" + query + "*)").defaultOperator(Operator.AND))
.withQuery(org.elasticsearch.index.query.QueryBuilders.queryStringQuery("acceNumb:(" + query + "*)").defaultOperator(Operator.AND))
.withSort(SortBuilders.fieldSort(FilterConstants.ACCENUMB).order(SortOrder.ASC)).withPageable(new PageRequest(0, 10)).build();
try {
......@@ -243,9 +259,9 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
if (FilterConstants.ALIAS.equals(key)) {
// Nested
orFilter.add(FilterBuilders.nestedFilter("aliases", QueryBuilders.queryString("aliases.name" + ":(" + sb.toString() + ")")));
orFilter.add(FilterBuilders.nestedFilter("aliases", QueryBuilders.queryStringQuery("aliases.name" + ":(" + sb.toString() + ")")));
} else {
orFilter.add(FilterBuilders.queryFilter(QueryBuilders.queryString(key + ":(" + sb.toString() + ")")));
orFilter.add(FilterBuilders.queryFilter(QueryBuilders.queryStringQuery(key + ":(" + sb.toString() + ")")));
}
} else {
// terms
......@@ -280,9 +296,9 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
if (genesysFilter.isAnalyzed()) {
if (FilterConstants.ALIAS.equals(key)) {
orFilter.add(FilterBuilders.nestedFilter("aliases",
QueryBuilders.queryString("aliases.name" + ":" + startsWith.getStartsWith() + "*")));
QueryBuilders.queryStringQuery("aliases.name" + ":" + startsWith.getStartsWith() + "*")));
} else {
orFilter.add(FilterBuilders.queryFilter(QueryBuilders.queryString(key + ":" + startsWith.getStartsWith() + "*")));
orFilter.add(FilterBuilders.queryFilter(QueryBuilders.queryStringQuery(key + ":" + startsWith.getStartsWith() + "*")));
}
} else {
orFilter.add(FilterBuilders.prefixFilter(key, startsWith.getStartsWith()));
......
......@@ -18,7 +18,7 @@ package org.genesys2.server.service.impl;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.functionScoreQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.index.query.QueryBuilders.queryString;
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.fieldValueFactorFunction;
import java.util.ArrayList;
......@@ -144,7 +144,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
.withQuery(
functionScoreQuery(
boolQuery().must(matchQuery(CLASSPK_SHORTNAME, classPK.getShortName())).must(
queryString(query).defaultOperator(QueryStringQueryBuilder.Operator.AND))).add(
queryStringQuery(query).defaultOperator(QueryStringQueryBuilder.Operator.AND))).add(
fieldValueFactorFunction("score").factor(1.0f))).withPageable(pageable).build();
try {
......@@ -156,7 +156,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
}
private Page<?> toEntities(FacetedPage<FullTextDocument> fulltextResults, Pageable pageable) {
List content = new ArrayList(fulltextResults.getSize());
List<Object> content = new ArrayList<>(fulltextResults.getSize());
for (FullTextDocument document : fulltextResults.getContent()) {
content.add(toEntity(document.getClassPK().getClassName(), document.getId()));
}
......@@ -185,7 +185,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
}
SearchQuery searchQuery;
Class clazz;
Class<?> clazz;
if (section.equals(ACCESSION_SECTION)) {
throw new UnsupportedOperationException("Use ElasticsearchServiceImpl for accession search");
......@@ -195,7 +195,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
.withQuery(
functionScoreQuery(
boolQuery().must(matchQuery(CLASSPK_SHORTNAME, section)).must(
queryString(query).defaultOperator(QueryStringQueryBuilder.Operator.AND))).add(
queryStringQuery(query).defaultOperator(QueryStringQueryBuilder.Operator.AND))).add(
fieldValueFactorFunction("score").factor(1.0f))).withPageable(pageable).build();
clazz = FullTextDocument.class;
}
......
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