private void activeSavedSearchByIdOrName(Integer savedSearchId, String savedSearchName) { Subject subject = UserSessionManager.getSessionSubject(); SavedSearchCriteria criteria = new SavedSearchCriteria(); criteria.addFilterSubjectId(subject.getId()); criteria.addFilterId(savedSearchId); // null OK criteria.addFilterName(savedSearchName); // null OK GWTServiceLookup.getSearchService() .findSavedSearchesByCriteria( criteria, new AsyncCallback<List<SavedSearch>>() { @Override public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError("Failure to select saved search", caught); } @Override public void onSuccess(List<SavedSearch> results) { if (results.size() != 1) { CoreGUI.getMessageCenter() .notify(new Message("Error selecting saved search", Severity.Error)); } else { SavedSearch savedSearch = results.get(0); activateSavedSearch(savedSearch); } } }); }
private void createSavedSearch(final String name, final String pattern) { Subject subject = UserSessionManager.getSessionSubject(); SavedSearch newSavedSearch = new SavedSearch(searchSubsystem, name, pattern, subject); GWTServiceLookup.getSearchService() .createSavedSearch( newSavedSearch, new AsyncCallback<Integer>() { @Override public void onSuccess(Integer newSavedSearchId) { currentSearchId = newSavedSearchId; } @Override public void onFailure(Throwable caught) {} }); }
protected Dashboard getDefaultDashboard() { Subject sessionSubject = UserSessionManager.getSessionSubject(); Resource resource = resourceComposite.getResource(); Dashboard dashboard = new Dashboard(); dashboard.setName(DASHBOARD_NAME_PREFIX + sessionSubject.getId() + "_" + resource.getId()); dashboard.setCategory(DashboardCategory.RESOURCE); dashboard.setResource(resource); dashboard.setColumns(2); // TODO, add real portlets // set leftmost column and let the rest be equally divided dashboard.setColumnWidths("40%"); dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3")); // figure out which portlets to display and how HashMap<String, String> resKeyNameMap = DashboardView.processPortletNameMapForResource(resourceComposite); int colLeft = 0; int colRight = 1; int rowLeft = 0; int rowRight = 0; // Left Column if (resKeyNameMap.containsKey( ResourceMetricsPortlet.KEY)) { // measurments top left if available DashboardPortlet measurements = new DashboardPortlet(ResourceMetricsPortlet.NAME, ResourceMetricsPortlet.KEY, 220); dashboard.addPortlet(measurements, colLeft, rowLeft++); resKeyNameMap.remove(ResourceMetricsPortlet.KEY); } // right Column(approx 60%. As larger more room to display table and N rows.) if (resKeyNameMap.containsKey(ResourceAlertsPortlet.KEY)) { // alerts top right if available DashboardPortlet alerts = new DashboardPortlet(ResourceAlertsPortlet.NAME, ResourceAlertsPortlet.KEY, 220); dashboard.addPortlet(alerts, colRight, rowRight++); resKeyNameMap.remove(ResourceAlertsPortlet.KEY); } if (resKeyNameMap.containsKey(ResourceOperationsPortlet.KEY)) { // operations if available DashboardPortlet ops = new DashboardPortlet(ResourceOperationsPortlet.NAME, ResourceOperationsPortlet.KEY, 220); dashboard.addPortlet(ops, colRight, rowRight++); resKeyNameMap.remove(ResourceOperationsPortlet.KEY); } if (resKeyNameMap.containsKey( ResourceConfigurationUpdatesPortlet.KEY)) { // configuration if available DashboardPortlet ops = new DashboardPortlet( ResourceConfigurationUpdatesPortlet.NAME, ResourceConfigurationUpdatesPortlet.KEY, 220); dashboard.addPortlet(ops, colRight, rowRight++); resKeyNameMap.remove(ResourceConfigurationUpdatesPortlet.KEY); } // Fill out left column(typically smaller portlets) then alternate cols with remaining boolean displayLeft = false; for (String key : resKeyNameMap.keySet()) { DashboardPortlet portlet = new DashboardPortlet(resKeyNameMap.get(key), key, 100); if (rowLeft < 4) { dashboard.addPortlet(portlet, colLeft, rowLeft++); } else { // alternate if (!displayLeft) { dashboard.addPortlet(portlet, colRight, rowRight++); } else { dashboard.addPortlet(portlet, colLeft, rowLeft++); } // toggle displayLeft = !displayLeft; } } return dashboard; }