forked from Luke-Sikina/picsure-search-refinement
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ALS-7152] Can't search for table name
- TSVector splits on underscore - Replace underscores in search and in builder
- Loading branch information
Luke Sikina
committed
Aug 27, 2024
1 parent
2b08c24
commit 9a062d5
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/edu/harvard/dbmi/avillach/dictionary/facet/FilterPreProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |