Skip to content

Commit

Permalink
Deparameterise the method, no need to share with external projects
Browse files Browse the repository at this point in the history
  • Loading branch information
vietnguyengit committed Apr 23, 2024
1 parent 8fb53ca commit a138f7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public class AodnDiscoveryParameterVocabService {
@Autowired
VocabsUtils cacheArdcVocabsUtils;

@Value("${elasticsearch.index.categories.name}")
String categoriesIndexName;

@Autowired
ElasticsearchClient portalElasticsearchClient;

Expand Down Expand Up @@ -52,7 +49,7 @@ comparing by combined values (id and url) of the concept object
public List<String> getAodnDiscoveryCategories(List<ThemesModel> themes) throws IOException {
List<String> results = new ArrayList<>();
// Iterate over the top-level vocabularies
for (JsonNode topLevelVocab : cacheArdcVocabsUtils.getDiscoveryCategories(categoriesIndexName)) {
for (JsonNode topLevelVocab : cacheArdcVocabsUtils.getDiscoveryCategories()) {
if (topLevelVocab.has("narrower") && !topLevelVocab.get("narrower").isEmpty()) {
for (JsonNode secondLevelVocab : topLevelVocab.get("narrower")) {
String secondLevelVocabLabel = secondLevelVocab.get("label").asText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void refreshDiscoveryCategoriesIndex() throws IOException {
@Cacheable(AppConstants.AODN_DISCOVERY_CATEGORIES_CACHE)
// TODO research strategy to avoid multiple refresh runs at the same schedule by multiple indexer instances
// A way to do it is read the value from Elastic search, if it has updated within say 24 hrs then use it
public List<JsonNode> getDiscoveryCategories(String categoriesIndexName) throws IOException {
public List<JsonNode> getDiscoveryCategories() throws IOException {
List<JsonNode> categories = new ArrayList<>();
log.info("Fetching AODN Discovery Parameter Vocabularies from {}", categoriesIndexName);
try {
Expand Down Expand Up @@ -140,7 +140,7 @@ public void refreshCache() throws IOException {
log.info("Refreshing AODN Discovery Parameter Vocabularies cache");
clearCache();
this.refreshDiscoveryCategoriesIndex();
self.getDiscoveryCategories(categoriesIndexName);
self.getDiscoveryCategories();
}

@CacheEvict(value = AppConstants.AODN_DISCOVERY_CATEGORIES_CACHE, allEntries = true)
Expand Down

0 comments on commit a138f7c

Please sign in to comment.