Search in sources :

Example 46 with ResultSet

use of net.sourceforge.processdash.data.util.ResultSet in project processdash by dtuma.

the class CumulativeDefectChartSnippet method buildData.

private void buildData() throws IOException {
    // query data from the database
    String hql = getTinyWebServer().getRequestAsString("/dash/snippets/cumDefects.hql");
    PDashQuery query = getPdash().getQuery();
    List<Object[]> defectCounts = query.query(hql);
    // Calc the number of rows we expect in our result set: one per day
    int numRows;
    if (defectCounts.isEmpty()) {
        numRows = 0;
    } else if (defectCounts.size() == 1) {
        numRows = 2;
    } else {
        Date start = (Date) defectCounts.get(0)[0];
        Date end = (Date) defectCounts.get(defectCounts.size() - 1)[0];
        long len = end.getTime() - start.getTime() + DAY_DELTA;
        numRows = (int) (len / DateUtils.DAYS) + 1;
    }
    // create a result set to hold the data
    ResultSet data = new ResultSet(numRows, 3);
    data.setColName(0, resources.getString("Date"));
    data.setColName(1, resources.getString("Date"));
    data.setColName(2, resources.getString("Count"));
    data.setColName(3, resources.getString("Cumulative"));
    // load defect data into the result set
    int row = 0;
    int cum = 0;
    Calendar lastDate = Calendar.getInstance();
    for (int i = 0; i < defectCounts.size(); i++) {
        Object[] oneCount = defectCounts.get(i);
        Date d = (Date) oneCount[0];
        int num = ((Number) oneCount[1]).intValue();
        if (i == 0) {
            // add a "zero" point preceding the first row
            lastDate.setTime(d);
            lastDate.add(Calendar.DATE, -1);
            addRow(data, ++row, lastDate.getTime(), 0, 0);
        } else {
            // add extra rows for days when no defects were removed
            long datePadCutoff = d.getTime() - DAY_DELTA;
            while (datePadCutoff > lastDate.getTimeInMillis()) {
                lastDate.add(Calendar.DATE, 1);
                addRow(data, ++row, lastDate.getTime(), 0, cum);
            }
        }
        // now add a row for the current data point
        cum += num;
        lastDate.setTime(d);
        addRow(data, ++row, d, num, cum);
    }
    // store the result set into the repository
    ListData l = new ListData();
    l.add(data);
    getDataContext().putValue(DATA_NAME, l);
}
Also used : PDashQuery(net.sourceforge.processdash.api.PDashQuery) Calendar(java.util.Calendar) ResultSet(net.sourceforge.processdash.data.util.ResultSet) Date(java.util.Date) ListData(net.sourceforge.processdash.data.ListData)

Example 47 with ResultSet

use of net.sourceforge.processdash.data.util.ResultSet in project processdash by dtuma.

the class DefectAnalysisPage method getEscapedDefectDensity.

@//
Chart(//
id = "escapes", //
type = "line", //
titleKey = "Defects.Escaped_Title", format = "headerComment=${Defects.Escaped_Header_FMT}")
public ResultSet getEscapedDefectDensity(ChartData chartData) {
    // request defect density for the "after development" pseudophase
    chartData.chartArgs = new String[] { Defect.AFTER_DEVELOPMENT };
    ResultSet data = getSinglePhaseDefectDensity(chartData, true);
    data.setColName(1, //
    resources.format(//
    "Defects.Escape_Scatter.Axis_FMT", chartData.getDensityStr()));
    // now store the name of the last workflow phase in the args, so it can
    // be used in the construction of chart headers/labels
    List<String> phases = chartData.getPhases();
    String lastPhase = phases.get(phases.size() - 1);
    chartData.chartArgs[0] = lastPhase;
    return data;
}
Also used : ResultSet(net.sourceforge.processdash.data.util.ResultSet)

Example 48 with ResultSet

use of net.sourceforge.processdash.data.util.ResultSet in project processdash by dtuma.

the class DefectAnalysisPage method getDefectsRemovedToDate.

@//
Chart(//
id = "remToDate", //
type = "pie", //
titleKey = "Defects.Removed_By_Phase_Title", //
format = "colorScheme=consistent\nconsistentSkip=2", smallFmt = "hideLegend=t")
public ResultSet getDefectsRemovedToDate(ChartData chartData) {
    ResultSet data = getTotalDefectsByPhaseToDate(chartData, true);
    data.setColName(1, getRes("Defects_Removed"));
    String lastPhase = data.getRowName(data.numRows() - 1);
    data.setRowName(data.numRows(), resources.format("Workflow.Analysis.After_FMT", lastPhase));
    return data;
}
Also used : ResultSet(net.sourceforge.processdash.data.util.ResultSet)

Example 49 with ResultSet

use of net.sourceforge.processdash.data.util.ResultSet in project processdash by dtuma.

the class DefectAnalysisPage method getRemovedDefectsByPhase.

@//
Chart(//
id = "remByPhase", //
type = "area", //
titleKey = "Defects.Phase_Removed_Title", //
format = "stacked=pct\ncolorScheme=consistent\nconsistentSkip=2", smallFmt = "hideLegend=t")
public ResultSet getRemovedDefectsByPhase(ChartData chartData) {
    List<String> phases = chartData.getPhases();
    phases.add(Defect.AFTER_DEVELOPMENT);
    ResultSet data = getDefectsByPhase(chartData, phases, true, Denom.None);
    String lastPhase = phases.get(phases.size() - 2);
    data.setColName(data.numCols(), resources.format("Workflow.Analysis.After_FMT", lastPhase));
    return data;
}
Also used : ResultSet(net.sourceforge.processdash.data.util.ResultSet)

Example 50 with ResultSet

use of net.sourceforge.processdash.data.util.ResultSet in project processdash by dtuma.

the class EstErrorScatterChartSnippet method buildData.

private void buildData(Resources res) throws IOException {
    // query data from the database
    String[] hql = getTinyWebServer().getRequestAsString("/dash/snippets/estErrorScatter.hql").split(";\\s*");
    PDashQuery query = getPdash().getQuery();
    List enactmentKeys = query.query(hql[0], getProjectKeys(), CURRENT);
    List<Object[]> taskStatus = query.query(hql[1], enactmentKeys, CURRENT);
    List<Object[]> sizeData = query.query(hql[2], enactmentKeys, CURRENT);
    // create a result set to hold the data
    ResultSet data = new ResultSet(taskStatus.size(), 7);
    data.setColName(0, res.getString("Component"));
    data.setColName(1, res.getString("Size_Units"));
    data.setColName(2, res.getString("Plan_Size"));
    data.setColName(3, res.getString("Actual_Size"));
    data.setColName(4, res.getString("Size_Est_Error"));
    data.setColName(5, res.getString("Plan_Time"));
    data.setColName(6, res.getString("Actual_Time"));
    data.setColName(7, res.getString("Time_Est_Error"));
    data.setFormat(4, "100%");
    data.setFormat(7, "100%");
    // load time data into the result set
    for (int i = 0; i < taskStatus.size(); i++) {
        Object[] oneTask = taskStatus.get(i);
        int row = i + 1;
        data.setRowName(row, (String) oneTask[1]);
        double planTime = ((Number) oneTask[2]).doubleValue();
        double actualTime = ((Number) oneTask[3]).doubleValue();
        data.setData(row, 5, StringData.create(formatTime(planTime)));
        data.setData(row, 6, StringData.create(formatTime(actualTime)));
        if (planTime > 0) {
            double timeErr = (actualTime - planTime) / planTime;
            data.setData(row, 7, new DoubleData(timeErr));
        }
    }
    // load size data into the result set
    for (Object[] oneSize : sizeData) {
        int row = getRow(taskStatus, oneSize[0]);
        if (row != -1) {
            String units = (String) oneSize[1];
            StringData currentUnits = (StringData) data.getData(row, 1);
            if (currentUnits == null)
                data.setData(row, 1, StringData.create(units));
            else if (!units.equals(currentUnits.format()))
                continue;
            int col = "Plan".equals(oneSize[2]) ? 2 : 3;
            double size = ((Number) oneSize[3]).doubleValue();
            data.setData(row, col, new DoubleData(size));
        }
    }
    // go back and calculate size estimating errors
    boolean requireSize = parameters.containsKey("RequireSize");
    for (int i = data.numRows(); i > 0; i--) {
        DoubleData plan = (DoubleData) data.getData(i, 2);
        DoubleData actual = (DoubleData) data.getData(i, 3);
        if (hasValue(plan) && hasValue(actual)) {
            double sizeError = (actual.getDouble() - plan.getDouble()) / plan.getDouble();
            data.setData(i, 4, new DoubleData(sizeError));
        } else if (requireSize) {
            data.removeRow(i);
        }
    }
    // store the result set into the repository
    ListData l = new ListData();
    l.add(data);
    getDataContext().putValue(DATA_NAME, l);
}
Also used : PDashQuery(net.sourceforge.processdash.api.PDashQuery) DoubleData(net.sourceforge.processdash.data.DoubleData) ListData(net.sourceforge.processdash.data.ListData) ResultSet(net.sourceforge.processdash.data.util.ResultSet) List(java.util.List) ArrayList(java.util.ArrayList) StringData(net.sourceforge.processdash.data.StringData)

Aggregations

ResultSet (net.sourceforge.processdash.data.util.ResultSet)57 Enactment (net.sourceforge.processdash.tool.db.WorkflowHistDataHelper.Enactment)11 DoubleData (net.sourceforge.processdash.data.DoubleData)5 ArrayList (java.util.ArrayList)4 ListData (net.sourceforge.processdash.data.ListData)3 DataPair (net.sourceforge.processdash.util.DataPair)3 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 PDashQuery (net.sourceforge.processdash.api.PDashQuery)2 PhaseType (net.sourceforge.processdash.tool.db.WorkflowHistDataHelper.PhaseType)2 IOException (java.io.IOException)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 ServletException (javax.servlet.ServletException)1 DataContext (net.sourceforge.processdash.data.DataContext)1 StringData (net.sourceforge.processdash.data.StringData)1