Search in sources :

Example 31 with DoubleData

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

the class CumulativeDefectChartSnippet method addRow.

protected void addRow(ResultSet data, int row, Date d, int num, int cum) {
    DateData date = new DateData(d, true);
    date.setFormatAsDateOnly(true);
    data.setRowName(row, date.format());
    data.setData(row, 1, date);
    data.setData(row, 2, new DoubleData(num));
    data.setData(row, 3, new DoubleData(cum));
}
Also used : DateData(net.sourceforge.processdash.data.DateData) DoubleData(net.sourceforge.processdash.data.DoubleData)

Example 32 with DoubleData

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

the class DataNameCollector method run.

public static Collection run(DataRepository data, String prefix, boolean numbersOnly, boolean discardHidden, Collection dest) {
    Map dataElements = data.getDefaultDataElementsFor(prefix);
    if (dataElements == null)
        return dest;
    Pattern hiddenDataPattern = null;
    if (discardHidden)
        try {
            String hiddenRegexp = "(" + Settings.getVal(SETTING_NAME) + ")";
            hiddenDataPattern = Pattern.compile(hiddenRegexp, Pattern.CASE_INSENSITIVE);
        } catch (Exception e) {
        }
    for (Iterator i = dataElements.entrySet().iterator(); i.hasNext(); ) {
        Map.Entry e = (Map.Entry) i.next();
        String name = (String) e.getKey();
        if (numbersOnly) {
            Object val = e.getValue();
            if ((val instanceof DoubleData == false) && (val instanceof CompiledScript == false))
                continue;
            if (NONNUMERIC_DATA.contains(name))
                continue;
        }
        if (hiddenDataPattern != null && hiddenDataPattern.matcher(name).find())
            continue;
        dest.add(name);
    }
    return dest;
}
Also used : CompiledScript(net.sourceforge.processdash.data.compiler.CompiledScript) Pattern(java.util.regex.Pattern) Iterator(java.util.Iterator) Map(java.util.Map) IOException(java.io.IOException) DoubleData(net.sourceforge.processdash.data.DoubleData)

Example 33 with DoubleData

use of net.sourceforge.processdash.data.DoubleData 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)

Example 34 with DoubleData

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

the class EstErrorScatterChartSnippet method getProjectKeys.

private List<Integer> getProjectKeys() {
    List<Integer> result = new ArrayList<Integer>();
    ListData l = ListData.asListData(getDataContext().getSimpleValue("DB_Project_Keys"));
    if (l != null) {
        for (int i = l.size(); i-- > 0; ) result.add(((DoubleData) l.get(i)).getInteger());
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) DoubleData(net.sourceforge.processdash.data.DoubleData) ListData(net.sourceforge.processdash.data.ListData)

Example 35 with DoubleData

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

the class DefectAnalysisPage method getDefectRemovalLeverage.

@//
Chart(//
id = "drl", //
type = "line", //
titleKey = "Defects.Leverage.Title", format = "headerComment=${Defects.Leverage.Comment_FMT}")
public ResultSet getDefectRemovalLeverage(ChartData chartData) {
    ResultSet data = getPhaseRemovalRates(chartData);
    if (data == null || data.numCols() < 2)
        return null;
    for (int row = data.numRows(); row > 0; row--) {
        double denom = ((DoubleData) data.getData(row, 1)).getDouble();
        for (int col = data.numCols(); col > 1; col--) {
            double val = ((DoubleData) data.getData(row, col)).getDouble();
            double drl = val / denom;
            data.setData(row, col, num(drl));
        }
        data.setData(row, 1, num(1));
    }
    // store the name of the last workflow phase in the args, so it can
    // be used in the construction of chart headers/labels
    chartData.chartArgs = new String[] { data.getColName(1) };
    return data;
}
Also used : ResultSet(net.sourceforge.processdash.data.util.ResultSet) DoubleData(net.sourceforge.processdash.data.DoubleData)

Aggregations

DoubleData (net.sourceforge.processdash.data.DoubleData)39 SimpleData (net.sourceforge.processdash.data.SimpleData)15 Iterator (java.util.Iterator)7 ImmutableDoubleData (net.sourceforge.processdash.data.ImmutableDoubleData)7 ListData (net.sourceforge.processdash.data.ListData)5 NumberData (net.sourceforge.processdash.data.NumberData)5 ResultSet (net.sourceforge.processdash.data.util.ResultSet)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 SaveableData (net.sourceforge.processdash.data.SaveableData)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 NumberFunction (net.sourceforge.processdash.data.NumberFunction)3 StringData (net.sourceforge.processdash.data.StringData)3 CompiledScript (net.sourceforge.processdash.data.compiler.CompiledScript)3 IOException (java.io.IOException)2 DateData (net.sourceforge.processdash.data.DateData)2 MalformedValueException (net.sourceforge.processdash.data.MalformedValueException)2 StudyGroupManager (net.sourceforge.processdash.tool.db.StudyGroupManager)2