From 3414220e3bc12492a3cc67972480fbee0b2e318f Mon Sep 17 00:00:00 2001 From: Pavel Grafkin Date: Tue, 26 Feb 2019 10:37:49 -0500 Subject: [PATCH] Fixes Concept Set optimization for Impala --- .../webapi/service/VocabularyService.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/ohdsi/webapi/service/VocabularyService.java b/src/main/java/org/ohdsi/webapi/service/VocabularyService.java index 01f1045278..85b0435f1f 100644 --- a/src/main/java/org/ohdsi/webapi/service/VocabularyService.java +++ b/src/main/java/org/ohdsi/webapi/service/VocabularyService.java @@ -1064,28 +1064,28 @@ public ConceptSetOptimizationResult optimizeConceptSet(@PathParam("sourceKey") S // Find all of the concepts that should be considered for optimization // Create a hashtable to hold all of the contents of the ConceptSetExpression // for use later - Hashtable allConceptSetItems = new Hashtable(); - ArrayList includedConcepts = new ArrayList(); - ArrayList descendantConcepts = new ArrayList(); - ArrayList allOtherConcepts = new ArrayList(); + Hashtable allConceptSetItems = new Hashtable<>(); + ArrayList includedConcepts = new ArrayList<>(); + ArrayList descendantConcepts = new ArrayList<>(); + ArrayList allOtherConcepts = new ArrayList<>(); for(ConceptSetExpression.ConceptSetItem item : conceptSetExpression.items) { - allConceptSetItems.put(item.concept.conceptId.toString(), item); + allConceptSetItems.put(item.concept.conceptId.intValue(), item); if (!item.isExcluded) { - includedConcepts.add(item.concept.conceptId.toString()); + includedConcepts.add(item.concept.conceptId.intValue()); if (item.includeDescendants) { - descendantConcepts.add(item.concept.conceptId.toString()); + descendantConcepts.add(item.concept.conceptId.intValue()); } } else { - allOtherConcepts.add(item.concept.conceptId.toString()); + allOtherConcepts.add(item.concept.conceptId.intValue()); } } // If no descendant concepts are specified, initialize this field to use concept_id = 0 so the query will work properly if (descendantConcepts.isEmpty()) - descendantConcepts.add("0"); + descendantConcepts.add(0); - String allConceptsList = this.JoinArray(includedConcepts.toArray(new String[includedConcepts.size()])); - String descendantConceptsList = this.JoinArray(descendantConcepts.toArray(new String[descendantConcepts.size()])); + String allConceptsList = includedConcepts.stream().map(Object::toString).collect(Collectors.joining(", ")); + String descendantConceptsList = descendantConcepts.stream().map(Object::toString).collect(Collectors.joining(", ")); sql_statement = SqlRender.renderSql(sql_statement, new String[]{"allConcepts", "descendantConcepts", "cdm_database_schema"}, new String[]{allConceptsList, descendantConceptsList, tableQualifier}); sql_statement = SqlTranslate.translateSql(sql_statement, source.getSourceDialect()); @@ -1099,7 +1099,7 @@ public ConceptSetOptimizationResult optimizeConceptSet(@PathParam("sourceKey") S ArrayList removedExpressionItems = new ArrayList<>(); List> rows = getSourceJdbcTemplate(source).queryForList(sql_statement); for (Map rs : rows) { - String conceptId = String.valueOf(rs.get("concept_id")); + Integer conceptId = Integer.parseInt(rs.get("concept_id").toString()); String removed = String.valueOf(rs.get("removed")); ConceptSetExpression.ConceptSetItem csi = allConceptSetItems.get(conceptId); if (removed.equals("0")) { @@ -1110,7 +1110,7 @@ public ConceptSetOptimizationResult optimizeConceptSet(@PathParam("sourceKey") S } // Re-add back the other concepts that are not considered // as part of the optimizatin process - for(String conceptId : allOtherConcepts) { + for(Integer conceptId : allOtherConcepts) { ConceptSetExpression.ConceptSetItem csi = allConceptSetItems.get(conceptId); optimzedExpressionItems.add(csi); }