use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class TextReport method writeXml.
/** Write result set data in XML format */
private void writeXml(ResultSet resultSet) throws IOException {
out.write("Content-Type: text/xml\r\n\r\n");
out.flush();
boolean whitespace = parameters.containsKey("whitespace");
boolean inlineAttributes = parameters.containsKey("dataAsAttr");
if (inlineAttributes) {
for (int col = 1; col <= resultSet.numCols(); col++) {
String colName = resultSet.getColName(col);
String attrName = textToSafeAttrName(colName);
resultSet.setColName(col, attrName);
}
}
XmlSerializer xml = XMLUtils.getXmlSerializer(whitespace);
xml.setOutput(outStream, ENCODING);
xml.startDocument(ENCODING, null);
xml.startTag(null, RESULT_SET_TAG);
for (int row = 1; row <= resultSet.numRows(); row++) {
xml.startTag(null, RESULT_ITEM_TAG);
xml.attribute(null, PATH_ATTR, resultSet.getRowName(row));
for (int col = 1; col <= resultSet.numCols(); col++) {
String name = resultSet.getColName(col);
SimpleData d = resultSet.getData(row, col);
String value = (d == null ? null : d.format());
if (inlineAttributes) {
if (value != null)
xml.attribute(null, name, value);
} else {
xml.startTag(null, RESULT_DATA_TAG);
xml.attribute(null, NAME_ATTR, name);
if (value != null)
xml.attribute(null, VALUE_ATTR, value);
xml.endTag(null, RESULT_DATA_TAG);
}
}
xml.endTag(null, RESULT_ITEM_TAG);
}
xml.endTag(null, RESULT_SET_TAG);
xml.endDocument();
}
use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class RadarChart method maybeScaleDataAxes.
private void maybeScaleDataAxes() {
for (int i = 0; i < data.numCols(); i++) {
int n = i + 1;
String target = getParameter("t" + n);
if (!StringUtils.hasValue(target))
continue;
double targetVal = 0;
try {
targetVal = FormatUtil.parseNumber(target);
} catch (Exception e) {
SaveableData val = getDataRepository().getInheritableValue(getPrefix(), target);
if (val != null) {
SimpleData sVal = val.getSimpleValue();
if (sVal instanceof NumberData)
targetVal = ((NumberData) sVal).getDouble();
}
}
if (targetVal == 0)
continue;
boolean reverse = parameters.containsKey("r" + n);
SimpleData d = data.getData(1, n);
if (d instanceof NumberData) {
NumberData num = (NumberData) d;
double val = num.getDouble();
if (Double.isInfinite(val) || Double.isNaN(val))
val = 1.0;
else if (reverse)
val = 2.0 / (1.0 + (val / targetVal));
else
val = val / targetVal;
data.setData(1, n, new DoubleData(val));
}
}
}
use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class MetricsAlert method writeContents.
@Override
protected void writeContents() throws IOException {
if (alertIsDisabled())
return;
String expression = getParameter("Expression");
if (!StringUtils.hasValue(expression))
return;
try {
SimpleData value = getDataRepository().evaluate(expression, getPrefix());
writeContentsForValue(value);
} catch (Exception e) {
out.println("<html><head>");
out.println(HEADER_ITEMS);
out.println("</head><body><div class=\"alertMalformedExpression\">");
out.print(resources.format("Expression_Error_HTML_FMT", HTMLUtils.escapeEntities(expression)));
out.println("</div></body></html");
}
}
use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class ProbeMethod method getSelectedMethod.
public static String getSelectedMethod(DataRepository data, String prefix, String targetDataElem) {
String dataName = DataRepository.createDataName(prefix, targetDataElem + "/Probe Method");
SimpleData val = data.getSimpleValue(dataName);
return (val == null ? null : val.format());
}
use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class MethodsPage method parseFormData.
public boolean parseFormData() {
buildMethods();
String what = purpose.getKey();
String method = (String) params.get(what);
if (method == null)
return false;
String qual = what + method;
SimpleData estimate, range, lpi, upi;
// Save the chosen method
putValue(getDataName(SEL_METHOD), StringData.create(method));
// Save the estimated value
estimate = getNum(qual, ProbeMethod.FLD_ESTIMATE);
if (estimate == N_A)
return false;
if (!ImmutableDoubleData.READ_ONLY_ZERO.lessThan(estimate))
return false;
putValue(targetDataElement, estimate);
estimateWasSaved(estimate);
// Save beta0 and beta1
putValue(getDataName("Beta0"), getNum(qual, ProbeMethod.FLD_BETA0));
putValue(getDataName("Beta1"), getNum(qual, ProbeMethod.FLD_BETA1));
// Save the range
putValue(getDataName("Range"), range = getNum(qual, ProbeMethod.FLD_RANGE));
// Save the interval percent
putValue(getDataName("Interval Percent"), getNum(qual, ProbeMethod.FLD_PERCENT, 1));
// Save the correlation
putValue(getDataName("R Squared"), getNum(qual, ProbeMethod.FLD_CORRELATION, 1));
// Save the LPI and UPI
if (range instanceof DoubleData) {
double est = ((DoubleData) estimate).getDouble();
double rng = ((DoubleData) range).getDouble();
upi = new DoubleData(est + rng);
lpi = new DoubleData(Math.max(0, est - rng));
} else
upi = lpi = N_A;
putValue(getDataName("LPI"), lpi);
putValue(getDataName("UPI"), upi);
// Save the input values that were used to capture data
histData.saveLastRunValues();
return true;
}
Aggregations