Skip to content

Commit

Permalink
Refactor findByDatasetId method in DashboardDrawerService
Browse files Browse the repository at this point in the history
- Changed return type from DashboardDrawerList to DashboardDrawer
- Added logic to handle single record return
- Updated default return to an empty DashboardDrawer instance
  • Loading branch information
TDeSain committed Nov 19, 2024
1 parent 8623e5e commit 36be1cf
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<DashboardDrawer> 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<>(), "", "");
}
}

0 comments on commit 36be1cf

Please sign in to comment.