From 36be1cfa90f913356fe96bf7df7e1687765504ab Mon Sep 17 00:00:00 2001 From: TDeSain Date: Tue, 19 Nov 2024 16:55:34 -0500 Subject: [PATCH] Refactor findByDatasetId method in DashboardDrawerService - Changed return type from DashboardDrawerList to DashboardDrawer - Added logic to handle single record return - Updated default return to an empty DashboardDrawer instance --- .../dashboarddrawer/DashboardDrawerService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/dashboarddrawer/DashboardDrawerService.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/dashboarddrawer/DashboardDrawerService.java index be701c3..e804cd9 100644 --- a/src/main/java/edu/harvard/dbmi/avillach/dictionary/dashboarddrawer/DashboardDrawerService.java +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/dashboarddrawer/DashboardDrawerService.java @@ -39,12 +39,16 @@ public DashboardDrawerList findAll() { * @param datasetId the ID of the dataset to fetch. * @return a Dashboard instance with drawer-specific columns and rows. */ - public DashboardDrawerList findByDatasetId(Integer datasetId) { + public DashboardDrawer findByDatasetId(Integer datasetId) { if (dashboardLayout.equalsIgnoreCase("bdc")) { List records = repository.getDashboardDrawerRows(datasetId); - return new DashboardDrawerList(records); + // Should be atomic as the query is an aggregation on the dataset table. + // Probably a better way to do this. + if (records.size() == 1) { + return records.get(0); + } } - return new DashboardDrawerList(new ArrayList<>()); + return new DashboardDrawer(-1, "", "", new ArrayList<>(), "", new ArrayList<>(), "", ""); } } \ No newline at end of file