Package org.jboss.dashboard.kpi

Examples of org.jboss.dashboard.kpi.KPI


            Set<Section> sections = getSelectedSections(workspace);
            for (Section section : sections) {
                Dashboard dash = dashboardHandler.getDashboard(section);
                Iterator it = section.getPanels().iterator();
                while (it.hasNext()) {
                    KPI kpi = dash.getKPI((Panel) it.next());
                    if (kpi != null && !results.contains(kpi)) results.add(kpi);
                }
            }
        }
        final Locale l = LocaleManager.currentLocale();
        Collections.sort(results, new Comparator() {
            public int compare(Object o1, Object o2) {
                KPI s1 = (KPI) o1;
                KPI s2 = (KPI) o2;
                return s1.getDescription(l).compareTo(s2.getDescription(l));
            }
        });
        return results;
    }
View Full Code Here


    public List<KPI> getSelectedKPIs(DataProvider dataProvider) throws Exception {
        List<KPI> results = getSelectedKPIs();
        Iterator<KPI> it = results.iterator();
        while (it.hasNext()) {
            KPI kpi = it.next();
            if (kpi != null && !kpi.getDataProvider().equals(dataProvider)) {
                it.remove();
            }
        }
        return results;
    }
View Full Code Here

    public Set<DataProvider> getDataProviders() {
        Set<DataProvider> results = new HashSet<DataProvider>();
        Iterator it = getSection().getPanels().iterator();
        while (it.hasNext()) {
            KPI kpi = getKPI((Panel) it.next());

            // The KPI is null if the panel is not assigned to a region.
            if (kpi != null) results.add(kpi.getDataProvider());
        }
        return results;
    }
View Full Code Here

                        int numberOfKPIs = 0;
                        setAttribute("usedByOtherKpis", Boolean.FALSE);
                        Iterator it1 = kpis.iterator();
                        while (it1.hasNext()) {
                            KPI kpi = (KPI) it1.next();
                            if (kpi.getDataProvider().equals(dataProvider)) numberOfKPIs++;
                        }

                        String providerType = dataProvider.getDataProviderType().getDescription(getLocale());
                        ResourceBundle i18n = localeManager.getBundle("org.jboss.dashboard.displayer.messages", getLocale());
                        String deleteMessage = i18n.getString(DataProviderHandler.I18N_PREFFIX + "confirmDelete");
View Full Code Here

    protected void beforeRenderPanel(Panel panel, HttpServletRequest req, HttpServletResponse res) {
        super.beforeRenderPanel(panel, req, res);

        // Ensure the KPI editor/viewer component is initialized (at session level).
        KPI kpi = null;
        try {
            kpi = getKPI(panel);
        } catch (Exception e) {
            log.error("Error: ",e);
        }
View Full Code Here

    }


    protected void beforePanelInstanceRemove(PanelInstance instance) throws Exception {
        // Delete from persistence the KPI attached to the panel.
        KPI kpi = DashboardHandler.lookup().getKPI(instance);

        // Only delete not null KPIs based on deleteable providers.
        if (kpi != null && kpi.getDataProvider().isCanDelete()) {

            // Only delete the KPI if not referred by other panels.
            PanelsManager panelsManager = UIServices.lookup().getPanelsManager();
            Set<PanelInstance> panels = panelsManager.getPanelsByParameter(DashboardHandler.KPI_CODE, kpi.getCode());
            if (panels.size() == 1) {
                kpi.delete();
            }
        }
    }
View Full Code Here

        }
        return false;
    }

    public void replicateData(PanelInstance src, PanelInstance dest) throws Exception {
        KPI kpiSrc = DashboardHandler.lookup().getKPI(src);
        if (kpiSrc != null) {
            // Clone the original KPI.
            KPI kpiDest = DataDisplayerServices.lookup().getKPIManager().createKPI();
            kpiDest.setDataProvider(kpiSrc.getDataProvider());
            kpiDest.setDataDisplayer(kpiSrc.getDataDisplayer());
            kpiDest.setDescriptionI18nMap(kpiSrc.getDescriptionI18nMap());
            kpiDest.save();

            // Link the destination panel instance with the newly created KPI.
            dest.setParameterValue(DashboardHandler.KPI_CODE, kpiDest.getCode());
        }
    }
View Full Code Here

    /**
     * Create a default KPI.
     */
    public CommandResponse actionCreateKPI(final Panel panel, final CommandRequest request) throws Exception {
        // By now, make the panel work with a hard-coded KPI.
        KPI kpi = DataDisplayerServices.lookup().getKPIManager().createKPI();

        // Set the KPI's data provider
        String initialProvider = request.getRequestObject().getParameter("initialProvider");
        DataProvider provider = DataDisplayerServices.lookup().getDataProviderManager().getDataProviderByCode(initialProvider);
        kpi.setDataProvider(provider);

        // Set the KPI's data displayer
        DataDisplayerType displayerType = DataDisplayerServices.lookup().getDataDisplayerManager().getDisplayerTypeByUid(BarChartDisplayerType.UID);
        BarChartDisplayer displayer = (BarChartDisplayer) displayerType.createDataDisplayer();
        displayer.setDefaultSettings();
        displayer.setTitle(kpi.getDescription(LocaleManager.currentLocale()));
        displayer.setDataProvider(provider);
        kpi.setDataDisplayer(displayer);
        kpi.setCode(null);
        kpi.save(); // The KPI's id and code are auto-generated here.

        // Set a default description
        Locale locale = LocaleManager.currentLocale();
        ResourceBundle i18n = localeManager.getBundle("org.jboss.dashboard.ui.panel.kpi.messages", locale);
        kpi.setDescription(i18n.getString("kpiDriver.newKpi"), locale);

        // Save the relationship between the panel and the KPI.
        panel.getInstance().setParameterValue(DashboardHandler.KPI_CODE, kpi.getCode());

        // Go to edit mode.
        passKPItoUI(kpi);
        return panelActionEditMode(panel, request);
    }
View Full Code Here

        String lang = LocaleManager.currentLang();
        String kpiDescr = request.getRequestObject().getParameter(KPIEditor.PARAM_KPI_DESCRIPTION);
        if (!StringUtils.isBlank(kpiDescr)) panel.getInstance().setTitle(kpiDescr, lang);

        // Make changes persistent.
        KPI kpi = kpiEditor.getKpi();
        kpi.save();

        // Ensure that the UI editor & viewer see the KPI changes
        passKPItoUI(kpi);
    }
View Full Code Here

    // DashboardDriver interface

    public Set<DataProvider> getDataProvidersUsed(Panel panel) throws Exception {
        Set<DataProvider> results = new HashSet<DataProvider>();
        KPI kpi = getKPI(panel);
        if (kpi != null) results.add(kpi.getDataProvider());
        return results;
    }
View Full Code Here

TOP

Related Classes of org.jboss.dashboard.kpi.KPI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.