Search in sources :

Example 16 with SimpleData

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

the class SelectLabelFilter method getDefinedLabelsArray.

private JSONArray getDefinedLabelsArray(String projectRoot) {
    String dataName = DataRepository.createDataName(projectRoot, LABELS_DATA_NAME);
    SimpleData labelsValue = getDataRepository().getSimpleValue(dataName);
    ListData list = ListData.asListData(labelsValue);
    JSONArray result = new JSONArray();
    try {
        result.addAll(Globsearch.getTags(list));
        Collections.sort(result, String.CASE_INSENSITIVE_ORDER);
    } catch (Throwable t) {
    // the Globsearch.getTags() method was added in PD 1.14.5.  In
    // earlier versions, this will throw an exception.  Gracefully
    // degrade and diable autocompletion support.
    }
    return result;
}
Also used : JSONArray(org.json.simple.JSONArray) SimpleData(net.sourceforge.processdash.data.SimpleData) ListData(net.sourceforge.processdash.data.ListData)

Example 17 with SimpleData

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

the class UserDataWriter method writeActualDataForNode.

private void writeActualDataForNode(XmlSerializer ser, DashHierarchy hier, PropertyKey node) throws IOException {
    String path = node.path();
    String wbsID = getWbsOrClientIdForPath(path);
    if (!hasValue(wbsID))
        return;
    SimpleData actualTime = getData(path, "Time");
    SimpleData startDate = getData(path, "Started");
    SimpleData completionDate = getData(path, "Completed");
    boolean reportSubtasks = isPSPTaskWithReportableSubtaskData(hier, node, actualTime, completionDate);
    if (hasValue(actualTime) || hasValue(startDate) || hasValue(completionDate) || reportSubtasks) {
        ser.startTag(null, ACTUAL_DATA_TAG);
        ser.attribute(null, WBS_ID_ATTR, wbsID);
        writeTimeDataAttr(ser, TIME_ATTR, actualTime);
        writeActualDataAttr(ser, START_DATE_ATTR, startDate);
        writeActualDataAttr(ser, COMPLETION_DATE_ATTR, completionDate);
        if (reportSubtasks)
            writeActualDataForPSPPhases(ser, hier, node);
        ser.endTag(null, ACTUAL_DATA_TAG);
    }
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 18 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 19 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 20 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)

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