Search in sources :

Example 6 with ListData

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

the class Listfor method call.

/** Perform a procedure call.
     *
     * This method <b>must</b> be thread-safe.
     */
public Object call(List arguments, ExpressionContext context) {
    ListData result = new ListData();
    String name = asString(getArg(arguments, 0));
    if (name == null)
        return null;
    Iterator i = collapseLists(arguments, 1).iterator();
    String path, dataName;
    while (i.hasNext()) {
        path = asStringVal(i.next());
        if (path == null)
            continue;
        dataName = DataRepository.createDataName(path, name);
        result.addAll(asList(context.get(dataName)));
    }
    return result;
}
Also used : Iterator(java.util.Iterator) ListData(net.sourceforge.processdash.data.ListData)

Example 7 with ListData

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

the class HTMLPreprocessor method getList.

/** Lookup the named list and return it.
     *
     * if the name is enclosed in braces [] it refers to a data
     * element - otherwise it refers to a cgi environment variable or
     * a query/post parameter.
     *
     * If no list is found by that name, will return an empty list.
     */
private ListData getList(String listName) {
    if (listName.startsWith("[")) {
        // listName names a data element
        listName = trimDelim(listName);
        SimpleData d = getSimpleValue(listName);
        if (d instanceof ListData)
            return (ListData) d;
        if (d instanceof StringData)
            return ((StringData) d).asList();
        if (d instanceof SimpleData) {
            ListData result = new ListData();
            result.add(d.format());
        }
        return EMPTY_LIST;
    } else {
        // listName names an environment variable or parameter
        ListData result = new ListData();
        // try for an environment variable first.
        Object envVal = env.get(listName);
        if (envVal instanceof String) {
            result.add((String) envVal);
            return result;
        }
        // look for a parameter value.
        Object allParam = params.get(listName + "_ALL");
        if (allParam instanceof String[]) {
            String[] param = (String[]) allParam;
            for (int i = 0; i < param.length; i++) result.add(param[i]);
        } else {
            Object p = params.get(listName);
            if (p == null)
                p = getResource(listName);
            if (p instanceof String) {
                String paramVal = (String) p;
                if (paramVal.startsWith("LIST="))
                    return new ListData(paramVal.substring(5));
                else
                    result.add(paramVal);
            }
        }
        return result;
    }
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) EscapeString(net.sourceforge.processdash.util.EscapeString) StringData(net.sourceforge.processdash.data.StringData) ListData(net.sourceforge.processdash.data.ListData)

Example 8 with ListData

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

the class SyncWBS method savePermissionData.

/** Parse data from the permissions form, and save it to the repository.
     */
private void savePermissionData() {
    ListData delete = new ListData();
    ListData complete = new ListData();
    ListData pspSubsets = new ListData();
    for (Iterator i = parameters.entrySet().iterator(); i.hasNext(); ) {
        Map.Entry e = (Map.Entry) i.next();
        if (e.getValue() == null || "".equals(e.getValue()))
            continue;
        String name = (String) e.getKey();
        if (name.endsWith("_ALL"))
            ;
        else if (name.startsWith(DELETE_PREFIX))
            delete.add(name.substring(DELETE_PREFIX.length()));
        else if (name.startsWith(COMPLETE_PREFIX))
            complete.add(name.substring(COMPLETE_PREFIX.length()));
        else if (name.startsWith(PSP_SUBSET_PREFIX)) {
            pspSubsets.add(name.substring(PSP_SUBSET_PREFIX.length()));
            pspSubsets.add(e.getValue());
        }
    }
    getDataRepository().putValue(getDataName(DELETE_DATANAME), delete);
    getDataRepository().putValue(getDataName(COMPLETE_DATANAME), complete);
    getDataRepository().putValue(getDataName(PSP_SUBSET_DATANAME), pspSubsets);
    printWaitPage();
}
Also used : Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) ListData(net.sourceforge.processdash.data.ListData)

Example 9 with ListData

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

the class SyncWBS method printChanges.

/** Print a list of changes made by a synchronization operation.
     */
private boolean printChanges(List changeList) {
    ListData oldChanges = (ListData) getDataContext().getSimpleValue(CHANGES_DATANAME);
    if (oldChanges != null) {
        changeList.addAll(0, oldChanges.asList());
        getDataContext().putValue(CHANGES_DATANAME, null);
    }
    out.print("<html><head><title>Synchronization Complete</title></head>");
    out.print("<body><h1>Synchronization Complete</h1>");
    if (changeList.isEmpty()) {
        out.print("<p>Your hierarchy is up to date - no changes " + "were necessary.");
        if (parameters.containsKey(TriggerURI.IS_TRIGGERING)) {
            out.print(TriggerURI.NULL_DOCUMENT_MARKER);
            JOptionPane.showMessageDialog(getParentComponent(), "Your hierarchy is up to date - no changes were necessary.", "Synchronization Complete", JOptionPane.PLAIN_MESSAGE);
        }
    } else {
        out.print("<p>The following changes were made to your hierarchy:");
        out.print("<ul>");
        Iterator i = changeList.iterator();
        while (i.hasNext()) {
            out.print("<li>");
            out.print(HTMLUtils.escapeEntities(String.valueOf(i.next())));
        }
        out.print("</ul>");
    }
    out.print("</body></html>");
    return !changeList.isEmpty();
}
Also used : Iterator(java.util.Iterator) ListData(net.sourceforge.processdash.data.ListData)

Example 10 with ListData

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

the class SyncWBS method saveChangeList.

private void saveChangeList(HierarchySynchronizer synch) {
    ListData changes = (ListData) getDataContext().getSimpleValue(CHANGES_DATANAME);
    if (changes == null)
        changes = new ListData();
    for (Iterator i = synch.getChanges().iterator(); i.hasNext(); ) changes.add(String.valueOf(i.next()));
    getDataContext().putValue(CHANGES_DATANAME, changes);
}
Also used : Iterator(java.util.Iterator) 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