Search in sources :

Example 1 with NumberFunction

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

the class TimingMetricsRecorder method saveTiming.

protected boolean saveTiming(String basePath) {
    Map timings = getTimings(basePath);
    if (timings == null)
        return false;
    for (Iterator i = timings.entrySet().iterator(); i.hasNext(); ) {
        Map.Entry e = (Map.Entry) i.next();
        String pathName = (String) e.getKey();
        long[] pathValue = (long[]) e.getValue();
        String timeElementName = DataRepository.createDataName(pathName, "Time");
        String orphanElementName = DataRepository.createDataName(pathName, "Orphaned Time");
        SaveableData currentVal = data.getValue(timeElementName);
        SaveableData orphanedVal = data.getValue(orphanElementName);
        if (pathValue == null) {
            if (orphanedVal != null)
                // if a previous orphan value exists, clear it.
                data.putValue(orphanElementName, null);
            if (currentVal == null)
                // the data repository agrees with us.  All is well.
                continue;
            else if (!(currentVal instanceof DoubleData) || (currentVal instanceof NumberFunction))
                // there.  Leave it alone.
                continue;
            else
                // there is an existing number there;  erase it.
                data.putValue(timeElementName, null);
        } else if (approver.isTimeLoggingAllowed(pathName) == false) {
            // the time log has entries for this path, but the time isn't
            // supposed to be logged there.  Record it as orphaned time.
            allPathsTouched.add(pathName);
            storeNumberIfChanged(orphanElementName, orphanedVal, pathValue);
        } else {
            allPathsTouched.add(pathName);
            storeNumberIfChanged(timeElementName, currentVal, pathValue);
            if (orphanedVal != null)
                data.putValue(orphanElementName, null);
        }
    }
    return true;
}
Also used : NumberFunction(net.sourceforge.processdash.data.NumberFunction) Iterator(java.util.Iterator) SaveableData(net.sourceforge.processdash.data.SaveableData) HashMap(java.util.HashMap) Map(java.util.Map) DoubleData(net.sourceforge.processdash.data.DoubleData)

Example 2 with NumberFunction

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

the class DefectLog method modifyDataValue.

private void modifyDataValue(String dataName, int increment, boolean ignoreExistingValue) {
    // the phase name. don't store or modify counts associated with these.
    if (dataName.contains(" /Defects "))
        return;
    String prefix = dataPrefix + getDataNamespace();
    dataName = DataRepository.createDataName(prefix, dataName);
    DoubleData val;
    try {
        val = (DoubleData) data.getValue(dataName);
    } catch (ClassCastException cce) {
        // Do nothing - don't overwrite values of other types
        return;
    }
    if (val instanceof NumberFunction) {
        // Do nothing - don't overwrite old-style calculations
        return;
    } else if (ignoreExistingValue && increment == 0) {
        if (val != null && val.getDouble() != 0)
            data.restoreDefaultValue(dataName);
        return;
    } else if (val == null || ignoreExistingValue) {
        val = new DoubleData(increment);
    } else {
        val = new DoubleData(val.getInteger() + increment);
    }
    val.setEditable(false);
    data.putValue(dataName, val);
}
Also used : NumberFunction(net.sourceforge.processdash.data.NumberFunction) DoubleData(net.sourceforge.processdash.data.DoubleData)

Example 3 with NumberFunction

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

the class DashboardTimeLog method timeLoggingAllowed.

static boolean timeLoggingAllowed(PropertyKey node, DashHierarchy props, DataContext data, List timingForbiddenPaths) {
    if (node == null || props == null || data == null || Settings.isReadOnly())
        return false;
    // forbidden path), don't allow time to be logged there.
    if (Filter.matchesFilter(timingForbiddenPaths, node.path()))
        return false;
    // the node explicitly defines a "Time_Logging_Allowed" marker.
    if (props.pget(node).getNumChildren() > 0) {
        String dataName = DataRepository.createDataName(node.path(), "Time_Logging_Allowed");
        SimpleData marker = data.getSimpleValue(dataName);
        return (marker != null && marker.test());
    }
    // check to see if the current node defines time as a calculation.
    // if it does, logging time here is not allowed.
    String dataName = DataRepository.createDataName(node.path(), "Time");
    Object timeData = data.getValue(dataName);
    if (timeData == null)
        return true;
    if (!(timeData instanceof DoubleData))
        return false;
    if (timeData instanceof NumberFunction)
        return false;
    return true;
}
Also used : NumberFunction(net.sourceforge.processdash.data.NumberFunction) SimpleData(net.sourceforge.processdash.data.SimpleData) DoubleData(net.sourceforge.processdash.data.DoubleData)

Aggregations

DoubleData (net.sourceforge.processdash.data.DoubleData)3 NumberFunction (net.sourceforge.processdash.data.NumberFunction)3 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 SaveableData (net.sourceforge.processdash.data.SaveableData)1 SimpleData (net.sourceforge.processdash.data.SimpleData)1