Search in sources :

Example 1 with DashboardContext

use of net.sourceforge.processdash.DashboardContext in project processdash by dtuma.

the class EVReport method writeCharts.

protected List<ChartItem> writeCharts(EVTaskList evModel, EVSchedule schedule, EVTaskFilter filter, boolean hideNames, int width, int height, ChartListPurpose p, String singleChartId, Map<String, String> chartHelpMap) {
    DashboardContext ctx = getDashboardContext();
    Object exportMarker = parameters.get("EXPORT");
    boolean filterInEffect = (filter != null);
    boolean isRollup = (evModel instanceof EVTaskListRollup);
    List<ChartItem> chartList = TaskScheduleChartUtil.getChartsForTaskList(evModel.getID(), getDataRepository(), filterInEffect, isRollup, hideNames, p);
    for (Iterator i = chartList.iterator(); i.hasNext(); ) {
        ChartItem chart = (ChartItem) i.next();
        if (chart == null) {
            i.remove();
            continue;
        }
        try {
            SnippetWidget w = chart.snip.getWidget("view", null);
            if (w instanceof HtmlEvChart) {
                String chartId = getChartId(chart);
                if (chartHelpMap != null && w instanceof HelpAwareEvChart) {
                    String helpUri = ((HelpAwareEvChart) w).getHelpUri();
                    if (StringUtils.hasValue(helpUri))
                        chartHelpMap.put(chartId, helpUri);
                }
                if (singleChartId != null && !singleChartId.equals(chartId))
                    continue;
                Map environment = TaskScheduleChartUtil.getEnvironment(evModel, schedule, filter, chart.snip, ctx);
                Map params = TaskScheduleChartUtil.getParameters(chart.settings);
                params.put("title", chart.name);
                params.put("width", Integer.toString(width));
                params.put("height", Integer.toString(height));
                params.put("noBorder", "t");
                if (hideNames)
                    params.put(CUSTOMIZE_HIDE_NAMES, "t");
                if (exportMarker != null)
                    params.put("EXPORT", exportMarker);
                else if (singleChartId == null)
                    params.put("href", getChartDrillDownUrl(chartId));
                // write the chart to an in-memory buffer. If any errors
                // occur, we will fall out to the exception handler.
                StringWriter buf = new StringWriter();
                ((HtmlEvChart) w).writeChartAsHtml(buf, environment, params);
                // The generation of the chart was successful.  Write out
                // the chart, surrounded by a DIV to control layout.
                out.write("<div class='evChartItem' style='width:" + width + "px; height:" + height + "px'>");
                out.write(buf.toString());
                out.write("</div>");
            } else {
                i.remove();
            }
            out.write(" ");
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Unexpected error when displaying " + "EV snippet widget with id '" + chart.snip.getId() + "'", e);
        }
    }
    return chartList;
}
Also used : DashboardContext(net.sourceforge.processdash.DashboardContext) SnippetWidget(net.sourceforge.processdash.ui.snippet.SnippetWidget) HtmlEvChart(net.sourceforge.processdash.ev.ui.chart.HtmlEvChart) HelpAwareEvChart(net.sourceforge.processdash.ev.ui.chart.HelpAwareEvChart) EVTaskListRollup(net.sourceforge.processdash.ev.EVTaskListRollup) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException) IOException(java.io.IOException) StringWriter(java.io.StringWriter) Iterator(java.util.Iterator) CachedURLObject(net.sourceforge.processdash.net.cache.CachedURLObject) ChartItem(net.sourceforge.processdash.ev.ui.TaskScheduleChartUtil.ChartItem) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 2 with DashboardContext

use of net.sourceforge.processdash.DashboardContext in project processdash by dtuma.

the class TaskStatusApi method getTargetPath.

/** Retrieve the target path from the incoming HTTP request */
private String getTargetPath() {
    // use the prefix, if one was supplied in the request
    String result = getPrefix();
    // selected task
    if (!StringUtils.hasValue(result)) {
        DashboardContext ctx = getDashboardContext();
        DashboardTimeLog tl = (DashboardTimeLog) ctx.getTimeLog();
        TimeLoggingModel tlm = tl.getTimeLoggingModel();
        result = tlm.getActiveTaskModel().getPath();
    }
    // verify that the named path exists and is a leaf task
    DashHierarchy hier = getPSPProperties();
    PropertyKey key = hier.findExistingKey(result);
    if (key == null)
        throw new WebApiException("no-such-task", 404, "The task '" + result + "' was not found.");
    else if (hier.getNumChildren(key) != 0)
        throw new WebApiException("not-leaf-task", 400, "The item '" + result + "' is not a leaf task.");
    return result;
}
Also used : DashboardContext(net.sourceforge.processdash.DashboardContext) DashboardTimeLog(net.sourceforge.processdash.log.time.DashboardTimeLog) TimeLoggingModel(net.sourceforge.processdash.log.time.TimeLoggingModel) DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 3 with DashboardContext

use of net.sourceforge.processdash.DashboardContext in project processdash by dtuma.

the class AnalysisPage method getChartData.

protected static ChartData getChartData(HttpServletRequest req, boolean applyFilter) {
    ChartData result = new ChartData();
    String workflowID = req.getParameter("workflow");
    if (!StringUtils.hasValue(workflowID))
        return null;
    DashboardContext ctx = (DashboardContext) PDashServletUtils.buildEnvironment(req).get(TinyCGI.DASHBOARD_CONTEXT);
    DatabasePlugin databasePlugin = ctx.getDatabasePlugin();
    QueryUtils.waitForAllProjects(databasePlugin);
    QueryRunner query = databasePlugin.getObject(QueryRunner.class);
    result.histData = new WorkflowHistDataHelper(query, workflowID);
    if (result.histData.getWorkflowName() == null)
        return null;
    if (applyFilter)
        configureFilter(result.histData, req);
    configureSizeUnits(result, ctx);
    return result;
}
Also used : DashboardContext(net.sourceforge.processdash.DashboardContext) DatabasePlugin(net.sourceforge.processdash.tool.db.DatabasePlugin) WorkflowHistDataHelper(net.sourceforge.processdash.tool.db.WorkflowHistDataHelper) QueryRunner(net.sourceforge.processdash.tool.db.QueryRunner)

Example 4 with DashboardContext

use of net.sourceforge.processdash.DashboardContext in project processdash by dtuma.

the class SizeMetricApiDispatcher method getTargetPath.

/** Retrieve the target path from the incoming HTTP request */
private String getTargetPath() {
    // use the prefix, if one was supplied in the request
    String result = getPrefix();
    // selected task
    if (!StringUtils.hasValue(result)) {
        DashboardContext ctx = getDashboardContext();
        DashboardTimeLog tl = (DashboardTimeLog) ctx.getTimeLog();
        TimeLoggingModel tlm = tl.getTimeLoggingModel();
        result = tlm.getActiveTaskModel().getPath();
    }
    return result;
}
Also used : DashboardContext(net.sourceforge.processdash.DashboardContext) DashboardTimeLog(net.sourceforge.processdash.log.time.DashboardTimeLog) TimeLoggingModel(net.sourceforge.processdash.log.time.TimeLoggingModel)

Example 5 with DashboardContext

use of net.sourceforge.processdash.DashboardContext in project processdash by dtuma.

the class DisplayState method writeTimingState.

private void writeTimingState() {
    DashboardContext ctx = getDashboardContext();
    DashboardTimeLog tl = (DashboardTimeLog) ctx.getTimeLog();
    TimeLoggingModel tlm = tl.getTimeLoggingModel();
    String path = tlm.getActiveTaskModel().getPath();
    String isTiming = tlm.isPaused() ? "false" : "true";
    out.write("Content-Type: text/plain\r\n\r\n");
    out.write("activeTask=" + path + "\r\n");
    out.write("isTiming=" + isTiming + "\r\n");
    out.flush();
}
Also used : DashboardContext(net.sourceforge.processdash.DashboardContext) DashboardTimeLog(net.sourceforge.processdash.log.time.DashboardTimeLog) TimeLoggingModel(net.sourceforge.processdash.log.time.TimeLoggingModel)

Aggregations

DashboardContext (net.sourceforge.processdash.DashboardContext)7 DashboardTimeLog (net.sourceforge.processdash.log.time.DashboardTimeLog)3 TimeLoggingModel (net.sourceforge.processdash.log.time.TimeLoggingModel)3 TreeMap (java.util.TreeMap)2 DatabasePlugin (net.sourceforge.processdash.tool.db.DatabasePlugin)2 QueryRunner (net.sourceforge.processdash.tool.db.QueryRunner)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 JDialog (javax.swing.JDialog)1 PDashContext (net.sourceforge.processdash.api.PDashContext)1 EVTaskListRollup (net.sourceforge.processdash.ev.EVTaskListRollup)1 ChartItem (net.sourceforge.processdash.ev.ui.TaskScheduleChartUtil.ChartItem)1 HelpAwareEvChart (net.sourceforge.processdash.ev.ui.chart.HelpAwareEvChart)1 HtmlEvChart (net.sourceforge.processdash.ev.ui.chart.HtmlEvChart)1 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)1 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)1 CachedURLObject (net.sourceforge.processdash.net.cache.CachedURLObject)1