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