Search in sources :

Example 1 with DashboardSearchResult

use of org.hisp.dhis.dashboard.DashboardSearchResult in project dhis2-core by dhis2.

the class DefaultDashboardService method search.

@Override
public DashboardSearchResult search(String query, Set<DashboardItemType> maxTypes) {
    Set<String> words = Sets.newHashSet(query.split(TextUtils.SPACE));
    List<App> dashboardApps = appManager.getAppsByType(AppType.DASHBOARD_WIDGET, new HashSet<>(appManager.getApps(null)));
    DashboardSearchResult result = new DashboardSearchResult();
    result.setUsers(userService.getAllUsersBetweenByName(query, 0, getMax(DashboardItemType.USERS, maxTypes)));
    result.setCharts(objectManager.getBetweenLikeName(Chart.class, words, 0, getMax(DashboardItemType.CHART, maxTypes)));
    result.setEventCharts(objectManager.getBetweenLikeName(EventChart.class, words, 0, getMax(DashboardItemType.EVENT_CHART, maxTypes)));
    result.setMaps(objectManager.getBetweenLikeName(Map.class, words, 0, getMax(DashboardItemType.MAP, maxTypes)));
    result.setReportTables(objectManager.getBetweenLikeName(ReportTable.class, words, 0, getMax(DashboardItemType.REPORT_TABLE, maxTypes)));
    result.setEventReports(objectManager.getBetweenLikeName(EventReport.class, words, 0, getMax(DashboardItemType.EVENT_REPORT, maxTypes)));
    result.setReports(objectManager.getBetweenLikeName(Report.class, words, 0, getMax(DashboardItemType.REPORTS, maxTypes)));
    result.setResources(objectManager.getBetweenLikeName(Document.class, words, 0, getMax(DashboardItemType.RESOURCES, maxTypes)));
    result.setApps(appManager.getAppsByName(query, dashboardApps, "ilike"));
    return result;
}
Also used : App(org.hisp.dhis.appmanager.App) EventReport(org.hisp.dhis.eventreport.EventReport) Report(org.hisp.dhis.report.Report) EventChart(org.hisp.dhis.eventchart.EventChart) ReportTable(org.hisp.dhis.reporttable.ReportTable) Document(org.hisp.dhis.document.Document) EventReport(org.hisp.dhis.eventreport.EventReport) DashboardSearchResult(org.hisp.dhis.dashboard.DashboardSearchResult) Map(org.hisp.dhis.mapping.Map) EventChart(org.hisp.dhis.eventchart.EventChart) Chart(org.hisp.dhis.chart.Chart)

Aggregations

App (org.hisp.dhis.appmanager.App)1 Chart (org.hisp.dhis.chart.Chart)1 DashboardSearchResult (org.hisp.dhis.dashboard.DashboardSearchResult)1 Document (org.hisp.dhis.document.Document)1 EventChart (org.hisp.dhis.eventchart.EventChart)1 EventReport (org.hisp.dhis.eventreport.EventReport)1 Map (org.hisp.dhis.mapping.Map)1 Report (org.hisp.dhis.report.Report)1 ReportTable (org.hisp.dhis.reporttable.ReportTable)1