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-7760] Replicate Old Search in new Data-Dictionary (#53)
**[CHORE] GH Actions Fix** - Fixed GitHub Actions to resolve workflow issues. **Testing Enhancements** - Added `@ActiveProfiles("test")` to testing classes to remove spam logs from `DataSourceVerifier` during unit tests. **JSON Parsing Refactor** - Created `JsonBlobParser` for improved JSON parsing. - Refactored `ConceptResultSetUtil` to use `JsonBlobParser` for clearer separation of concerns. **Code Cleanup** - Removed unused imports from `ConceptShell` and `ContinuousConcept` classes to improve code readability. **Legacy Search Feature** - Implemented a new legacy search feature including service, controller, and related model classes. - Updated `ConceptRepository` to support legacy search queries. - Added test cases to ensure functionality. **Testing Improvements** - Added unit tests for `LegacySearchQueryMapper` to validate JSON parsing and string replacement. - Introduced integration tests for `LegacySearchController` to verify search response correctness using a PostgreSQL container. **Initial Configurations** - Added application properties for database configuration and dashboard settings. - Introduced Docker commands for local development with sample weights configuration. - Included `weights.csv` and `dictonaryRequest.http` as sample data for testing API requests. **Search Query Refactor** - Created `LegacySearchRepository` to handle legacy search functionalities. - Moved query logic (`ALLOW_FILTERING_Q`) to `QueryUtility`. - Removed legacy search code from `ConceptRepository` for better separation of concerns. **Filter Processing Refactor** - Introduced `FilterProcessor` to centralize filter processing logic. - Enhanced methods in `MetadataResultSetUtil` (`getDescription`, `getParentName`, `getParentDisplay`) for better validation using `StringUtils`. **Repository Enhancements** - Added `LegacySearchRepositoryTest` to verify legacy search functionalities. - Refactored legacy search logic from `ConceptService` into `LegacySearchRepository`. - Cleaned up unused imports and methods for better maintainability. --- Co-authored-by: Luke Sikina <lucas.skina@gmail.com>
- Loading branch information
Showing
47 changed files
with
828 additions
and
101 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Docker commands for local development | ||
### Docker build | ||
```bash | ||
docker build --no-cache --build-arg SPRING_PROFILE=bdc-dev -t weights:latest . | ||
``` | ||
|
||
### Docker run | ||
You will need a local weights.csv file. | ||
```bash | ||
docker run --rm -t --name dictionary-weights --network=host -v ./weights.csv:/weights.csv weights:latest | ||
``` |
9 changes: 9 additions & 0 deletions
9
dictionaryweights/src/main/resources/application-bdc-dev.properties
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,9 @@ | ||
spring.application.name=dictionaryweights | ||
spring.main.web-application-type=none | ||
|
||
spring.datasource.url=jdbc:postgresql://localhost:5432/dictionary_db?currentSchema=dict | ||
spring.datasource.username=username | ||
spring.datasource.password=password | ||
spring.datasource.driver-class-name=org.postgresql.Driver | ||
|
||
weights.filename=/weights.csv |
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,7 @@ | ||
concept_node.DISPLAY,2 | ||
concept_node.CONCEPT_PATH,2 | ||
dataset.FULL_NAME,1 | ||
dataset.DESCRIPTION,1 | ||
parent.DISPLAY,1 | ||
grandparent.DISPLAY,1 | ||
concept_node_meta_str,1 |
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,15 @@ | ||
# curl 'https://dev.picsure.biodatacatalyst.nhlbi.nih.gov/picsure/proxy/dictionary-api/concepts?page_number=1&page_size=1' | ||
# -H 'origin: https://dev.picsure.biodatacatalyst.nhlbi.nih.gov' | ||
# -H 'referer: https://dev.picsure.biodatacatalyst.nhlbi.nih.gov/' | ||
# --data-raw '{"facets":[],"search":"","consents":[]}' | ||
POST http://localhost:80/concepts?page_number=0&page_size=100 | ||
Content-Type: application/json | ||
|
||
{"facets":[],"search":"lipid triglyceride"} | ||
|
||
### | ||
|
||
POST http://localhost:80/search | ||
Content-Type: application/json | ||
|
||
{"@type":"GeneralQueryRequest","resourceCredentials":{},"query":{"searchTerm":"breast","includedTags":[],"excludedTags":[],"returnTags":"true","offset":0,"limit":10000000},"resourceUUID":null} |
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
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
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
1 change: 0 additions & 1 deletion
1
src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ConceptShell.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
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
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
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
34 changes: 34 additions & 0 deletions
34
src/main/java/edu/harvard/dbmi/avillach/dictionary/filter/FilterProcessor.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,34 @@ | ||
package edu.harvard.dbmi.avillach.dictionary.filter; | ||
|
||
import edu.harvard.dbmi.avillach.dictionary.facet.Facet; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.StringUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
@Component | ||
public class FilterProcessor { | ||
|
||
public Filter processsFilter(Filter filter) { | ||
List<Facet> newFacets = filter.facets(); | ||
List<String> newConsents = filter.consents(); | ||
if (filter.facets() != null) { | ||
newFacets = new ArrayList<>(filter.facets()); | ||
newFacets.sort(Comparator.comparing(Facet::name)); | ||
} | ||
if (filter.consents() != null) { | ||
newConsents = new ArrayList<>(newConsents); | ||
newConsents.sort(Comparator.comparing(Function.identity())); | ||
} | ||
filter = new Filter(newFacets, filter.search(), newConsents); | ||
|
||
if (StringUtils.hasLength(filter.search())) { | ||
filter = new Filter(filter.facets(), filter.search().replaceAll("_", "/"), filter.consents()); | ||
} | ||
return filter; | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchController.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,32 @@ | ||
package edu.harvard.dbmi.avillach.dictionary.legacysearch; | ||
|
||
import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.LegacyResponse; | ||
import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.LegacySearchQuery; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import java.io.IOException; | ||
|
||
@Controller | ||
public class LegacySearchController { | ||
|
||
private final LegacySearchService legacySearchService; | ||
private final LegacySearchQueryMapper legacySearchQueryMapper; | ||
|
||
@Autowired | ||
public LegacySearchController(LegacySearchService legacySearchService, LegacySearchQueryMapper legacySearchQueryMapper) { | ||
this.legacySearchService = legacySearchService; | ||
this.legacySearchQueryMapper = legacySearchQueryMapper; | ||
} | ||
|
||
@RequestMapping(path = "/search") | ||
public ResponseEntity<LegacyResponse> legacySearch(@RequestBody String jsonString) throws IOException { | ||
LegacySearchQuery legacySearchQuery = legacySearchQueryMapper.mapFromJson(jsonString); | ||
return ResponseEntity | ||
.ok(new LegacyResponse(legacySearchService.getSearchResults(legacySearchQuery.filter(), legacySearchQuery.pageable()))); | ||
} | ||
|
||
} |
Oops, something went wrong.