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;
}
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;
}
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);
}
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);
}
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"));
}
Aggregations