Search in sources :

Example 91 with ListData

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

the class RollupDatasetSelectElem method getFragment.

protected String getFragment(DataRepository data, String rollupID) {
    // check in the cache to see if there is a cached value for
    // this ID.  if so, return it.
    String cachedResult = CACHE.get(rollupID);
    if (cachedResult != null)
        return cachedResult;
    // lookup the data element [/ROLLUP_ID/Rollup Instance
    // List]. If it is missing or if it contains less than two
    // items, return an empty fragment (and save the empty
    // fragment to the cache).
    String instanceListName = rollupInstanceList(rollupID);
    ListData instanceList = getList(data, instanceListName);
    if (instanceList == null || instanceList.size() < 2)
        return CACHE.put(rollupID, "");
    // Construct an HTML fragment
    String prompt = resources.format("Rollup_Select_Prompt_FMT", rollupID);
    StringBuffer result = new StringBuffer();
    result.append("<tr><td>").append(HTMLUtils.escapeEntities(prompt)).append("&nbsp;</td>\n    <td colspan=10><select name='[").append(rollupPrefix(rollupID)).append("]s'>");
    for (int i = 0; i < instanceList.size(); i++) {
        String opt = HTMLUtils.escapeEntities((String) instanceList.get(i));
        result.append("\n<option value=\"").append(opt).append("\">").append(opt);
    }
    result.append("\n</select></td></tr>\n");
    return CACHE.put(rollupID, result.toString());
}
Also used : ListData(net.sourceforge.processdash.data.ListData)

Example 92 with ListData

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

the class PDashDataImpl method getList.

public List<String> getList(String dataName) {
    SimpleData sd = getSimpleValue(dataName);
    ListData ld = ListData.asListData(sd);
    if (ld == null)
        return null;
    List result = new ArrayList(ld.asList());
    for (int i = result.size(); i-- > 0; ) {
        Object item = result.get(i);
        if (item instanceof SimpleData)
            result.set(i, convert((SimpleData) item));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) SimpleData(net.sourceforge.processdash.data.SimpleData) ArrayList(java.util.ArrayList) List(java.util.List) ListData(net.sourceforge.processdash.data.ListData)

Example 93 with ListData

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

the class ResultSet method get.

/** Perform a query and return a result set. */
public static ResultSet get(DataRepository data, String forParam, String[] conditions, String orderBy, String[] dataNames, String basePrefix) {
    // get the list of prefixes
    ListData prefixList = getFilteredList(data, forParam, conditions, orderBy, basePrefix);
    // Create a result set to return
    ResultSet result = new ResultSet(prefixList.size(), dataNames.length);
    // write the column headers into the result set.
    result.setColName(0, null);
    for (int i = 0; i < dataNames.length; i++) result.setColName(i + 1, dataNames[i]);
    // get the data and fill the result set.
    String prefix, dataName;
    if (basePrefix == null)
        basePrefix = "";
    int baseLen = basePrefix.length();
    // remove / as well
    if (baseLen > 0)
        baseLen++;
    for (int p = 0; p < prefixList.size(); p++) {
        // get the next prefix
        Object pfx = prefixList.get(p);
        if (pfx instanceof String)
            prefix = (String) pfx;
        else if (pfx instanceof SimpleData)
            prefix = ((SimpleData) pfx).format();
        else
            continue;
        // write the row headers into the result set.
        if (prefix.length() > baseLen && prefix.startsWith(basePrefix))
            result.setRowName(p + 1, prefix.substring(baseLen));
        else {
            result.setRowName(p + 1, prefix);
            if (!prefix.startsWith("/"))
                prefix = DataRepository.createDataName(basePrefix, prefix);
        }
        // look up the data for this row.
        for (int d = 0; d < dataNames.length; d++) if (dataNames[d].startsWith("\"")) {
            try {
                result.setData(p + 1, d + 1, new StringData(dataNames[d]));
            } catch (MalformedValueException mve) {
            }
        } else if (dataNames[d].indexOf('[') != -1) {
            try {
                result.setData(p + 1, d + 1, data.evaluate(dataNames[d], prefix));
            } catch (Exception e) {
            }
        } else {
            dataName = DataRepository.createDataName(prefix, dataNames[d]);
            result.setData(p + 1, d + 1, data.getSimpleValue(dataName));
        }
    }
    return result;
}
Also used : MalformedValueException(net.sourceforge.processdash.data.MalformedValueException) SimpleData(net.sourceforge.processdash.data.SimpleData) LocalizedString(net.sourceforge.processdash.util.LocalizedString) StringData(net.sourceforge.processdash.data.StringData) MalformedValueException(net.sourceforge.processdash.data.MalformedValueException) ListData(net.sourceforge.processdash.data.ListData)

Example 94 with ListData

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

the class ResultSet method getResultSetFromRepository.

private static ResultSet getResultSetFromRepository(DataRepository data, String prefix, String useParam) {
    String dataName = DataRepository.createDataName(prefix, useParam);
    ListData l = ListData.asListData(data.getSimpleValue(dataName));
    if (l != null && l.size() == 1)
        return (ResultSet) l.get(0);
    else
        return null;
}
Also used : LocalizedString(net.sourceforge.processdash.util.LocalizedString) ListData(net.sourceforge.processdash.data.ListData)

Example 95 with ListData

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

the class ResultSet method getFilteredList.

private static ListData getFilteredList(DataRepository data, String forParam, String[] conditions, String orderBy, String basePrefix) {
    ListData result;
    // return a list containing only one element - the base prefix.
    if (forParam == null || forParam.length() == 0 || forParam.equals(".")) {
        result = new ListData();
        result.add(basePrefix);
    // if the for parameter specifies a data list rather than
    // a tag name, or if the base prefix is empty, return all the
    // items in the list in question.
    } else if (basePrefix == null || basePrefix.length() == 0 || !forParamIsTagName(forParam)) {
        result = getList(data, forParam, conditions, orderBy, basePrefix);
    // otherwise, get the appropriate prefix list, and create
    // a filtered copy containing only those prefixes that
    // start with the base prefix.
    } else {
        ListData fullPrefixList = getList(data, forParam, conditions, orderBy, basePrefix);
        result = new ListData();
        String item;
        for (int i = 0; i < fullPrefixList.size(); i++) {
            item = (String) fullPrefixList.get(i);
            if (item.equals(basePrefix) || item.startsWith(basePrefix + "/"))
                result.add(item);
        }
    }
    return result;
}
Also used : LocalizedString(net.sourceforge.processdash.util.LocalizedString) ListData(net.sourceforge.processdash.data.ListData)

Aggregations

ListData (net.sourceforge.processdash.data.ListData)129 SimpleData (net.sourceforge.processdash.data.SimpleData)20 ArrayList (java.util.ArrayList)18 List (java.util.List)16 Iterator (java.util.Iterator)15 StringData (net.sourceforge.processdash.data.StringData)15 EVTaskListData (net.sourceforge.processdash.ev.EVTaskListData)9 Map (java.util.Map)8 HashSet (java.util.HashSet)7 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 LinkedList (java.util.LinkedList)5 DoubleData (net.sourceforge.processdash.data.DoubleData)5 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)5 LocalizedString (net.sourceforge.processdash.util.LocalizedString)5 NodeList (org.w3c.dom.NodeList)5 Date (java.util.Date)4 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)4 Element (org.w3c.dom.Element)4