Search in sources :

Example 36 with SimpleData

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();
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) XmlSerializer(org.xmlpull.v1.XmlSerializer)

Example 37 with SimpleData

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));
        }
    }
}
Also used : NumberData(net.sourceforge.processdash.data.NumberData) SimpleData(net.sourceforge.processdash.data.SimpleData) SaveableData(net.sourceforge.processdash.data.SaveableData) DoubleData(net.sourceforge.processdash.data.DoubleData)

Example 38 with SimpleData

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");
    }
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) IOException(java.io.IOException)

Example 39 with SimpleData

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());
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 40 with SimpleData

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;
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) DoubleData(net.sourceforge.processdash.data.DoubleData) ImmutableDoubleData(net.sourceforge.processdash.data.ImmutableDoubleData)

Aggregations

SimpleData (net.sourceforge.processdash.data.SimpleData)164 ListData (net.sourceforge.processdash.data.ListData)20 DoubleData (net.sourceforge.processdash.data.DoubleData)15 SaveableData (net.sourceforge.processdash.data.SaveableData)14 StringData (net.sourceforge.processdash.data.StringData)13 IOException (java.io.IOException)11 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)11 DateData (net.sourceforge.processdash.data.DateData)10 Iterator (java.util.Iterator)9 List (java.util.List)7 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 ImmutableDoubleData (net.sourceforge.processdash.data.ImmutableDoubleData)6 NumberData (net.sourceforge.processdash.data.NumberData)6 Element (org.w3c.dom.Element)6 Map (java.util.Map)5 DataContext (net.sourceforge.processdash.data.DataContext)5 EscapeString (net.sourceforge.processdash.util.EscapeString)5 File (java.io.File)4