Search in sources :

Example 11 with DoubleData

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

the class MethodsPage method getNum.

protected SimpleData getNum(String qual, String name, double mult) {
    String inputFieldName = qual + name;
    String inputFieldValue = (String) params.get(inputFieldName);
    SimpleData result = N_A;
    try {
        double value = Double.parseDouble(inputFieldValue);
        if (!Double.isInfinite(value) && !Double.isNaN(value))
            result = new DoubleData(value * mult);
    } catch (NumberFormatException nfe) {
    }
    return result;
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) DoubleData(net.sourceforge.processdash.data.DoubleData) ImmutableDoubleData(net.sourceforge.processdash.data.ImmutableDoubleData)

Example 12 with DoubleData

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

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

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

the class McfSizeMetricApiHandler method validateAndStoreData.

/**
     * Retrieve the size data parameters from the incoming request and ensure
     * they represent valid size metric data. If so, write them into the data
     * repository.
     * 
     * @param request
     *            the request we are processing
     * @param dataPrefix
     *            the data repository prefix where metrics should be stored
     */
private void validateAndStoreData(SizeMetricApiRequestData request, String dataPrefix) {
    // parse and validate the supplied parameter values
    StringData description = getDescription(request);
    StringData sizeUnits = getSizeUnits(request);
    DoubleData actSize = getActualSize(request);
    // store them into the data repository
    putData(request, dataPrefix + "/" + DESCRIPTION_ELEM, description);
    putData(request, dataPrefix + "/" + UNITS_ELEM, sizeUnits);
    putData(request, dataPrefix + "/" + ACT_SIZE_ELEM, actSize);
}
Also used : StringData(net.sourceforge.processdash.data.StringData) DoubleData(net.sourceforge.processdash.data.DoubleData)

Example 15 with DoubleData

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

the class TimingMetricsRecorderTest method testCleanupBogusElements.

public void testCleanupBogusElements() throws Exception {
    // the mere act of creating the recorder should have initialized
    // all times to their correct values
    assertTimes(expectedTimes);
    // add a bogus value to the data repository
    StringData stringData = new StringData("\"foo");
    data.putValue("/Project/Time", new DoubleData(666, false));
    data.putValue("/Non Project/Time", stringData);
    // but we don't want it to show up.
    expectedTimes.put("/Project", new Integer(0));
    boolean timesMatch = false;
    try {
        assertTimes(expectedTimes);
        timesMatch = true;
    } catch (AssertionFailedError afe) {
    }
    assertFalse("expected times NOT to match", timesMatch);
    // this should cause things to get cleaned up
    recorder.timeLogChanged(new TimeLogEvent(timeLog));
    assertTimes(expectedTimes);
    assertSame(stringData, data.getValue("/Non Project/Time"));
}
Also used : StringData(net.sourceforge.processdash.data.StringData) AssertionFailedError(junit.framework.AssertionFailedError) 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