Search in sources :

Example 16 with DataContext

use of net.sourceforge.processdash.data.DataContext in project processdash by dtuma.

the class WorkflowMappingAltererFactory method get.

public static WorkflowMappingAlterer get(DashboardContext ctx, String projectId) {
    // find the root path of the project with the given ID.
    DataContext data = ctx.getData();
    String projPath = findProject(ctx.getHierarchy(), data, PropertyKey.ROOT, projectId);
    if (projPath == null)
        return null;
    // identify the name of the user who is running this logic
    String ownerName = WBSEditor.getKnownOwnerName();
    if (ownerName == null)
        ownerName = System.getProperty("user.name");
    // retrieve the location of the data directory, and create an alterer
    String teamDataUrl = getVal(data, projPath, "Team_Data_Directory_URL");
    String teamDataDir = getVal(data, projPath, "Team_Data_Directory");
    return new WorkflowMappingAltererProjectDir(ownerName, FilenameMapper.remap(teamDataUrl), FilenameMapper.remap(teamDataDir));
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext)

Example 17 with DataContext

use of net.sourceforge.processdash.data.DataContext in project processdash by dtuma.

the class TableOfMetrics method writeTable.

private void writeTable() throws IOException {
    DataContext dataContext = getDataContext();
    // retrieve the heading and label the user wants displayed
    String heading = getParameter(HEADING_PARAM);
    String label = getParameter(LABEL_PARAM);
    // retrieve the list of columns the user wants to display
    List columns = new ArrayList();
    for (int i = 0; i < COLUMNS.length; i++) {
        if (COLUMNS[i].isShowing(parameters))
            columns.add(COLUMNS[i]);
    }
    if (dataContext.getSimpleValue("Rollup Tag") != null)
        columns.remove(MetricsTableColumn.TO_DATE);
    if (columns.isEmpty()) {
        out.write("<!-- no columns selected;  no table to display -->\n\n");
        return;
    }
    // retrieve the list of metrics the user wants to display
    Map[] metrics = SnippetDataEnumerator.getEnumeratedValues(parameters, ITEM_TYPE);
    if (metrics == null) {
        out.write("<!-- no metrics selected;  no table to display -->\n\n");
        return;
    }
    // write out heading if requested
    if (StringUtils.hasValue(heading)) {
        out.write("<h2>");
        out.write(HTMLUtils.escapeEntities(heading));
        out.write("</h2>\n\n");
    }
    String mergeTables = getParameter(MERGE_PARAM);
    if (mergeTables != null) {
        out.write(AbstractViewPageAssembler.MERGE_TABLES_DIRECTIVE);
        out.write(mergeTables);
        out.write(" -->");
    }
    // write the header row of the table
    out.write("<p><table><tr><th align=\"left\">");
    if (label != null)
        out.write(HTMLUtils.escapeEntities(label));
    out.write("</th>\n");
    boolean pad = true;
    for (Iterator i = columns.iterator(); i.hasNext(); ) {
        MetricsTableColumn col = (MetricsTableColumn) i.next();
        col.writeHeader(out, resources, pad);
        pad = false;
    }
    out.write("</tr>\n");
    if (mergeTables != null)
        out.write(AbstractViewPageAssembler.MERGE_TABLES_CUT_MARK);
    // write a table row for each metric
    for (int i = 0; i < metrics.length; i++) writeTableRow(metrics[i], columns, dataContext);
    out.write("</table></p>\n\n");
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 18 with DataContext

use of net.sourceforge.processdash.data.DataContext in project processdash by dtuma.

the class TableOfPhaseMetrics method writeContents.

protected void writeContents() throws IOException {
    DataContext dataContext = getDataContext();
    // retrieve the heading and label the user wants displayed
    String heading = getParameter(HEADING_PARAM);
    String label = getParameter(LABEL_PARAM);
    // retrieve the list of columns the user wants to display
    List columns = new ArrayList();
    for (int i = 0; i < COLUMNS.length; i++) {
        if (COLUMNS[i].isShowing(parameters))
            columns.add(COLUMNS[i]);
    }
    if (dataContext.getSimpleValue("Rollup Tag") != null) {
        columns.remove(MetricsTableColumn.TO_DATE);
        columns.remove(MetricsTableColumn.TO_DATE_PCT);
    }
    if (columns.isEmpty()) {
        out.write("<!-- no columns selected;  no table to display -->\n\n");
        return;
    }
    ProcessUtil procUtil = new ProcessUtil(getDataContext());
    // retrieve the list of phases the user wants to display
    String phaseList = getSelectedPhaseList();
    List phases = null;
    for (int i = 0; i < PHASES.length; i++) {
        if (PHASES[i][0].equals(phaseList)) {
            phases = procUtil.getProcessListPlain(PHASES[i][1]);
            break;
        }
    }
    if (phases == null)
        // default to all phases
        phases = procUtil.getProcessListPlain(PHASES[0][1]);
    // filter the list of phases, if applicable
    phases = procUtil.filterPhaseList(phases);
    applyExplicitPhaseFilter(phases);
    if (phases.isEmpty()) {
        out.write("<!-- no phases selected;  no table to display -->\n\n");
        return;
    }
    // retrieve the list of metrics the user wants to display
    Map[] metrics = SnippetDataEnumerator.getEnumeratedValues(parameters, ITEM_TYPE);
    if (metrics == null) {
        out.write("<!-- no metrics selected;  no table to display -->\n\n");
        return;
    }
    // write out heading if requested
    if (StringUtils.hasValue(heading)) {
        out.write("<h2>");
        out.write(HTMLUtils.escapeEntities(heading));
        out.write("</h2>\n\n");
    }
    String mergeTables = getParameter(MERGE_PARAM);
    if (mergeTables != null) {
        out.write(AbstractViewPageAssembler.MERGE_TABLES_DIRECTIVE);
        out.write(mergeTables);
        out.write(" -->");
    }
    // write the header row of the table
    out.write("<p><table><tr><th align=\"left\">");
    if (label != null)
        out.write(esc(label));
    out.write("</th>\n");
    if (metrics.length > 1) {
        for (int i = 0; i < metrics.length; i++) {
            out.write("<th");
            out.write(MetricsTableColumn.PADDING_LEFT);
            out.write(" colspan=\"");
            out.write(Integer.toString(columns.size()));
            out.write("\">");
            String metricName = (String) metrics[i].get(DISPLAY_NAME_ATTR);
            if (metricName == null || metricName.trim().length() == 0) {
                String dataName = (String) metrics[i].get(DATA_NAME_ATTR);
                metricName = TranslatingAutocompleter.translateDataName(dataName);
            }
            out.write(esc(metricName));
            out.write("</th>\n");
        }
        out.write("</tr>\n");
    }
    if (columns.size() > 1) {
        out.write("<tr><th></th>");
        for (int j = 0; j < metrics.length; j++) {
            boolean pad = true;
            for (Iterator i = columns.iterator(); i.hasNext(); ) {
                MetricsTableColumn col = (MetricsTableColumn) i.next();
                col.writeHeader(out, resources, pad);
                pad = false;
            }
        }
        out.write("</tr>\n");
    }
    if (mergeTables != null)
        out.write(AbstractViewPageAssembler.MERGE_TABLES_CUT_MARK);
    // write a table row for each process phase
    for (Iterator i = phases.iterator(); i.hasNext(); ) {
        String phase = (String) i.next();
        writeTableRow(phase, metrics, columns, dataContext, procUtil);
    }
    if (parameters.containsKey("ShowTotalRow") && ALL_PHASES.equals(phaseList))
        writeTableRow(null, metrics, columns, dataContext, procUtil);
    out.write("</table></p>\n\n");
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ProcessUtil(net.sourceforge.processdash.process.ProcessUtil) Map(java.util.Map)

Aggregations

DataContext (net.sourceforge.processdash.data.DataContext)18 SimpleData (net.sourceforge.processdash.data.SimpleData)5 ArrayList (java.util.ArrayList)4 Iterator (java.util.Iterator)4 List (java.util.List)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ProcessDashboard (net.sourceforge.processdash.ProcessDashboard)2 DateData (net.sourceforge.processdash.data.DateData)2 ListData (net.sourceforge.processdash.data.ListData)2 ProcessUtil (net.sourceforge.processdash.process.ProcessUtil)2 BufferedOutputStream (java.io.BufferedOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 URL (java.net.URL)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 DoubleData (net.sourceforge.processdash.data.DoubleData)1