-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for dictionary service
- Loading branch information
Showing
7 changed files
with
77 additions
and
10 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...ssing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/dictionary/Concept.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,6 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing.dictionary; | ||
|
||
import java.util.Map; | ||
|
||
public record Concept(String conceptPath, String name, Map<String, String> meta) { | ||
} |
30 changes: 30 additions & 0 deletions
30
...main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/dictionary/DictionaryService.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,30 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing.dictionary; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.core.ParameterizedTypeReference; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
@ConditionalOnProperty("dictionary.host") | ||
public class DictionaryService { | ||
|
||
public static final ParameterizedTypeReference<List<Concept>> CONCEPT_LIST_TYPE_REFERENCE = new ParameterizedTypeReference<>() { | ||
}; | ||
private final String dictionaryHost; | ||
private final RestTemplate restTemplate; | ||
|
||
public DictionaryService(@Value("${dictionary.host}") String dictionaryHostTemplate, @Value("${TARGET_STACK}") String targetStack) { | ||
this.dictionaryHost = dictionaryHostTemplate.replace("___TARGET_STACK___", targetStack); | ||
this.restTemplate = new RestTemplate(); | ||
} | ||
|
||
public List<Concept> getConcepts(List<String> conceptPaths) { | ||
return restTemplate.exchange(dictionaryHost, HttpMethod.POST, new HttpEntity<>(conceptPaths), CONCEPT_LIST_TYPE_REFERENCE).getBody(); | ||
} | ||
} |
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
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