Search in sources :

Example 11 with DataPair

use of net.sourceforge.processdash.util.DataPair in project processdash by dtuma.

the class ProbeDatabaseUtil method buildResultSet.

private ProbeDatabaseResultSet buildResultSet(String[] columnHeaders, List<Enactment> enactmentList) {
    // retrieve the time-in-phase data for this workflow
    Map timeInPhase = histData.getTotalTimeInPhase();
    timeInPhase.remove(WorkflowHistDataHelper.TOTAL_PHASE_KEY);
    for (Map.Entry e : ((Map<String, Object>) timeInPhase).entrySet()) {
        DataPair d = (DataPair) e.getValue();
        e.setValue(d.actual);
    }
    // Create an empty result set to hold the data.
    int numRows = enactmentList.size();
    ProbeDatabaseResultSet result = new ProbeDatabaseResultSet(numRows, columnHeaders, workflowName, timeInPhase);
    // iterate over enactment info and store it into the result set.
    for (int i = numRows; i-- > 0; ) {
        Enactment e = enactmentList.get(i);
        int row = i + 1;
        // retrieve the dashboard path for this row and store in result
        result.setRowName(row, e.getProjectName() + "/" + e.getRootName());
        // retrieve the plan item ID for this row and store in result
        result.setData(row, ProbeData.IDENTIFIER, str(e.getRootID()));
        // store time and completion date data in the result.
        result.setData(row, ProbeData.EST_TIME, num(histData.getTime(e, null, false), 60));
        result.setData(row, ProbeData.ACT_TIME, num(e.actualTime(), 60));
        result.setData(row, ProbeData.COMPLETED_DATE, date(e.completed));
        // retrieve size data and store it into the result set
        String sizeUnits = require(getString("Size Units", false));
        result.setData(row, ProbeData.EST_OBJ_LOC, num(histData.getSize(e, sizeUnits, "Estimated Proxy"), 1));
        result.setData(row, ProbeData.EST_NC_LOC, num(histData.getSize(e, sizeUnits, false), 1));
        result.setData(row, ProbeData.ACT_NC_LOC, num(histData.getSize(e, sizeUnits, true), 1));
    }
    return result;
}
Also used : Entry(java.util.Map.Entry) Enactment(net.sourceforge.processdash.tool.db.WorkflowHistDataHelper.Enactment) Map(java.util.Map) DataPair(net.sourceforge.processdash.util.DataPair)

Example 12 with DataPair

use of net.sourceforge.processdash.util.DataPair in project processdash by dtuma.

the class DefectAnalysisPage method getTotalDefectsByPhaseToDate.

private ResultSet getTotalDefectsByPhaseToDate(ChartData chartData, boolean removed) {
    Map<String, DataPair>[] raw = chartData.histData.getDefectsByPhase();
    Map<String, DataPair> counts = raw[removed ? WorkflowHistDataHelper.REM : WorkflowHistDataHelper.INJ];
    double total = counts.remove(TOTAL).actual;
    List<String> phases = new ArrayList<String>(counts.keySet());
    ResultSet data = new ResultSet(phases.size(), 2);
    data.setColName(0, getRes("Phase"));
    data.setColName(2, getRes("Percent_Units"));
    data.setFormat(2, "100%");
    for (int row = phases.size(); row > 0; row--) {
        String phase = (String) phases.get(row - 1);
        data.setRowName(row, phase);
        data.setData(row, 1, num(counts.get(phase).actual));
        data.setData(row, 2, num(counts.get(phase).actual / total));
    }
    return data;
}
Also used : ArrayList(java.util.ArrayList) ResultSet(net.sourceforge.processdash.data.util.ResultSet) Map(java.util.Map) DataPair(net.sourceforge.processdash.util.DataPair)

Example 13 with DataPair

use of net.sourceforge.processdash.util.DataPair in project processdash by dtuma.

the class AnalysisPage method configureSizeUnits.

private static void configureSizeUnits(ChartData chartData, DashboardContext ctx) {
    String workflowID = chartData.histData.getWorkflowID();
    String workflowName = chartData.histData.getWorkflowName();
    DataRepository data = ctx.getData();
    // check for an explicit setting for this workflow
    if (setSizeUnits(chartData, data, workflowID + "/Size_Units"))
        return;
    // check for a setting stored for another workflow with this name
    if (setSizeUnits(chartData, data, workflowName + "/Size_Units"))
        return;
    // check for the size unit we guessed during the current session
    if (setSizeUnits(chartData, data, workflowID + "//Size_Units_Guess"))
        return;
    // no luck so far; examine the historical data and make a best guess
    double bestSize = 0;
    String bestUnits = null;
    for (Entry<String, DataPair> e : chartData.histData.getAddedAndModifiedSizes().entrySet()) {
        double oneSize = Math.max(e.getValue().plan, e.getValue().actual);
        if (oneSize > bestSize && !isTimeUnits(e.getKey())) {
            bestSize = oneSize;
            bestUnits = e.getKey();
        }
    }
    if (bestUnits != null) {
        // if we find a good metric, use it and save our decision for the
        // rest of this session. This ensures that the charts won't silently
        // switch size units (for example, when different filters are in
        // effect), as that erratic behavior could confuse/mislead users.
        String dataName = "/Workflow_Prefs/" + workflowID + "//Size_Units_Guess";
        data.putValue(dataName, StringData.create(bestUnits));
        chartData.setPrimarySizeUnits(bestUnits);
        return;
    }
    // no actual size data is present. Use "Hours" as our guess.
    chartData.setPrimarySizeUnits("Hours");
}
Also used : DataRepository(net.sourceforge.processdash.data.repository.DataRepository) DataPair(net.sourceforge.processdash.util.DataPair)

Example 14 with DataPair

use of net.sourceforge.processdash.util.DataPair in project processdash by dtuma.

the class WorkflowHistDataHelper method calculateYields.

private void calculateYields(Map<String, DataPair> inj, Map<String, DataPair> rem, Map<String, DataPair> processYields, Map<String, DataPair> phaseYields) {
    // calculate cumulative defects injected and removed so far by phase
    Map<String, DataPair> cumInj = cum(inj);
    Map<String, DataPair> cumRem = cum(rem);
    cumRem.remove(Defect.AFTER_DEVELOPMENT);
    // special handling for the first phase
    Iterator<String> phaseNames = cumRem.keySet().iterator();
    String firstPhase = phaseNames.next();
    DataPair firstPhaseYield = new DataPair(rem.get(firstPhase)).divide(cumInj.get(firstPhase));
    phaseYields.put(firstPhase, firstPhaseYield);
    String prevPhase = firstPhase;
    // iterate over remaining phases and calculate yields
    while (phaseNames.hasNext()) {
        String phase = phaseNames.next();
        DataPair processYield = new DataPair(cumRem.get(prevPhase)).divide(cumInj.get(prevPhase));
        processYields.put(phase, processYield);
        DataPair phaseYield = new DataPair(rem.get(phase)).divide(new DataPair(cumInj.get(phase)).subtract(cumRem.get(prevPhase)));
        phaseYields.put(phase, phaseYield);
        prevPhase = phase;
    }
    // write an entry for total process yield
    DataPair totalProcessYield = new DataPair(cumRem.get(prevPhase)).divide(cumInj.get(prevPhase));
    processYields.put(TOTAL_PHASE_KEY, totalProcessYield);
}
Also used : DataPair(net.sourceforge.processdash.util.DataPair)

Example 15 with DataPair

use of net.sourceforge.processdash.util.DataPair in project processdash by dtuma.

the class WorkflowPlanSummary method writePhaseChart.

private void writePhaseChart(boolean plan, String titleRes, String columnRes, double factor, Map<String, DataPair> phaseData) throws IOException {
    int numRows = phaseData.size() - 1;
    ResultSet data = new ResultSet(numRows, 1);
    int row = 0;
    for (Entry<String, DataPair> e : phaseData.entrySet()) {
        if (++row > numRows)
            break;
        data.setRowName(row, e.getKey());
        double value = plan ? e.getValue().plan : e.getValue().actual;
        data.setData(row, 1, new DoubleData(value / factor));
    }
    writeChart((plan ? "Plan" : "Actual"), titleRes, columnRes, data);
}
Also used : ResultSet(net.sourceforge.processdash.data.util.ResultSet) DoubleData(net.sourceforge.processdash.data.DoubleData) DataPair(net.sourceforge.processdash.util.DataPair)

Aggregations

DataPair (net.sourceforge.processdash.util.DataPair)17 LinkedHashMap (java.util.LinkedHashMap)7 Map (java.util.Map)6 ResultSet (net.sourceforge.processdash.data.util.ResultSet)3 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 DoubleData (net.sourceforge.processdash.data.DoubleData)1 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)1 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)1 WorkflowHistDataHelper (net.sourceforge.processdash.tool.db.WorkflowHistDataHelper)1 Enactment (net.sourceforge.processdash.tool.db.WorkflowHistDataHelper.Enactment)1