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