From cc87da1b9d0ebd6a8408d24cd3934c45eeca5325 Mon Sep 17 00:00:00 2001 From: David Gauldie Date: Tue, 30 Jul 2024 11:21:04 -0400 Subject: [PATCH] fixed issue with error being thrown with empty concepts --- .../components/dataset/tera-dataset-overview-table.vue | 3 +-- packages/client/hmi-client/src/services/concept.ts | 4 +++- .../hmiserver/controller/mira/MiraController.java | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/client/hmi-client/src/components/dataset/tera-dataset-overview-table.vue b/packages/client/hmi-client/src/components/dataset/tera-dataset-overview-table.vue index bd467c52f8..fdf321e911 100644 --- a/packages/client/hmi-client/src/components/dataset/tera-dataset-overview-table.vue +++ b/packages/client/hmi-client/src/components/dataset/tera-dataset-overview-table.vue @@ -96,8 +96,7 @@ watch( async () => { tableData.value = await Promise.all( props.dataset.columns?.map(async (col) => { - const identifier = - col.metadata?.groundings?.identifiers ?? parseCurie(String(col.grounding?.identifiers[0].curie)); + const identifier = col.metadata?.groundings?.identifiers ?? parseCurie(col.grounding?.identifiers[0].curie); return { id: col.name, name: formatName(col.name), diff --git a/packages/client/hmi-client/src/services/concept.ts b/packages/client/hmi-client/src/services/concept.ts index 74ab1e6ee9..56738d3445 100644 --- a/packages/client/hmi-client/src/services/concept.ts +++ b/packages/client/hmi-client/src/services/concept.ts @@ -102,7 +102,9 @@ function getCurieFromGroundingIdentifier(identifier: Object | undefined): string return ''; } -function parseCurie(curie: string) { +function parseCurie(curie: string | undefined): { [key: string]: string } { + if (!curie) return {}; + const key = curie.split(':')[0]; const value = curie.split(':')[1]; return { [key]: value }; diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/controller/mira/MiraController.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/controller/mira/MiraController.java index c68d90ca97..b50163021c 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/controller/mira/MiraController.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/controller/mira/MiraController.java @@ -305,11 +305,15 @@ public ResponseEntity cancelTask(@PathVariable("task-id") final UUID taskI @GetMapping("/currie/{curies}") @Secured(Roles.USER) public ResponseEntity> searchConcept(@PathVariable("curies") final String curies) { + if (curies == null || curies.isEmpty()) { + return ResponseEntity.noContent().build(); + } + final ResponseEntity> response; try { response = proxy.getEntities(curies); } catch (final FeignException e) { - throw handleMiraFeignException(e, "concepts", "curies", curies, "mira.concepts.bad-curies"); + throw handleMiraFeignException(e, "concepts", "curies", curies, "mira.concept.bad-curies"); } return new ResponseEntity(response.getBody(), response.getStatusCode()); @@ -326,7 +330,7 @@ public ResponseEntity> search( try { response = proxy.search(q, limit, offset); } catch (final FeignException e) { - throw handleMiraFeignException(e, "concepts", "query", q, "mira.concepts.bad-query"); + throw handleMiraFeignException(e, "concepts", "query", q, "mira.concept.bad-query"); } return new ResponseEntity(response.getBody(), response.getStatusCode());