forked from Luke-Sikina/picsure-search-refinement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDashboardDrawerService.java
50 lines (42 loc) · 1.61 KB
/
DashboardDrawerService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package edu.harvard.dbmi.avillach.dictionary.dashboarddrawer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@Service
public class DashboardDrawerService {
private final DashboardDrawerRepository repository;
private final String dashboardLayout;
@Autowired
public DashboardDrawerService(DashboardDrawerRepository repository, @Value("${dashboard.layout.type}") String dashboardLayout) {
this.repository = repository;
this.dashboardLayout = dashboardLayout;
}
/**
* Retrieves the Dashboard Drawer for all datasets.
*
* @return All Dashboard Instances and their metadata.
*/
public Optional<DashboardDrawerList> findAll() {
if (dashboardLayout.equalsIgnoreCase("bdc")) {
List<DashboardDrawer> records = repository.getDashboardDrawerRows();
return Optional.of(new DashboardDrawerList(records));
}
return Optional.of(new DashboardDrawerList(new ArrayList<>()));
}
/**
* Retrieves the Dashboard Drawer for a specific dataset.
*
*
* @param datasetId the ID of the dataset to fetch.
* @return a single Dashboard instance with drawer-specific metadata.
*/
public Optional<DashboardDrawer> findByDatasetId(Integer datasetId) {
if ("bdc".equalsIgnoreCase(dashboardLayout)) {
return repository.getDashboardDrawerRows(datasetId);
}
return Optional.empty();
}
}