Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ALS-7152] Can't search for table name #23

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public String createUpdate(List<Weight> weights) {
.collect(Collectors.joining(", ' ',\n "));
return """
UPDATE concept_node
SET SEARCHABLE_FIELDS = to_tsvector(data_table.search_str)
SET SEARCHABLE_FIELDS = to_tsvector(replace(data_table.search_str, '_', '/'))
FROM
(
SELECT
Expand All @@ -43,6 +43,8 @@ concept_node.concept_node_id AS id, string_agg(value, ' ') AS values
concept_node.concept_node_id
) AS concept_node_meta_str ON concept_node_meta_str.id = concept_node.concept_node_id
LEFT JOIN dataset ON concept_node.dataset_id = dataset.dataset_id
LEFT JOIN concept_node AS parent ON concept_node.parent_id = parent.concept_node_id
LEFT JOIN concept_node AS grandparent ON parent.parent_id = grandparent.concept_node_id
) AS data_table
WHERE concept_node.concept_node_id = data_table.search_key;
""".formatted(searchableFields);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package edu.harvard.dbmi.avillach.dictionary.facet;

import edu.harvard.dbmi.avillach.dictionary.filter.Filter;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice;

import java.io.IOException;
import java.lang.reflect.Type;

@ControllerAdvice
public class FilterPreProcessor implements RequestBodyAdvice {
@Override
public boolean supports(
MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType
) {
return true;
}

@Override
public HttpInputMessage beforeBodyRead(
HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
Class<? extends HttpMessageConverter<?>> converterType
) throws IOException {
return inputMessage;
}

@Override
public Object afterBodyRead(
Object body, HttpInputMessage inputMessage, MethodParameter parameter,
Type targetType, Class<? extends HttpMessageConverter<?>> converterType
) {
if (body instanceof Filter filter && StringUtils.hasLength(filter.search())) {
return new Filter(filter.facets(), filter.search().replaceAll("_", "/"));
}
return body;
}

@Override
public Object handleEmptyBody(
Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
Class<? extends HttpMessageConverter<?>> converterType
) {
return body;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty test file

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package edu.harvard.dbmi.avillach.dictionary.facet;

import static org.junit.jupiter.api.Assertions.*;

class FilterPreProcessorTest {

}