use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.
the class AutoData method newEmptyList.
/** Construct an empty list. */
protected static ListData newEmptyList() {
ListData result = new ListData();
result.setEditable(false);
return result;
}
use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.
the class HTMLPreprocessor method processForeachDirective.
/** process a foreach directive within the buffer */
private void processForeachDirective(DirectiveMatch foreach) {
StringBuffer text = foreach.buf;
String blockNum = blockNum("foreach", foreach.directive);
// find the matching endfor.
DirectiveMatch endfor = new DirectiveMatch(text, blockNum + "endfor", foreach.end, true);
if (!endfor.matches()) {
// if the endfor is missing, delete this directive and abort.
System.err.println("foreach directive without matching endfor - aborting.");
foreach.replace("");
return;
}
// get the list of values that we should iterate over. This can be
// specified either as a list literal using the "values" attribute,
// or via a list variable using the "list" attribute.
String values = foreach.getAttribute("values");
ListData list;
if (isNull(values)) {
String listName = foreach.getAttribute("list");
list = getList(listName);
} else {
list = new ListData(values);
}
// iterate over the list and calculate the resulting contents.
String loopIndex = foreach.getAttribute("name");
String loopContents = text.substring(foreach.end, endfor.begin);
StringBuffer replacement = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
Object oneVal = list.get(i);
String strVal = (oneVal == null ? "" : oneVal.toString());
String iterResults = StringUtils.findAndReplace(loopContents, loopIndex, strVal);
replacement.append(iterResults);
}
// replace the directive with the iterated contents. Note
// that we explicitly replace the initial foreach tag with an
// empty string, so the overall processing loop (in the
// preprocess method) will process these iterated contents.
text.replace(foreach.end, endfor.end, replacement.toString());
foreach.replace("");
}
use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.
the class DefaultTaskLabeler method loadLabelData.
private void loadLabelData(String path) {
String dataName = DataRepository.createDataName(path, LABELS_DATA_NAME);
ListData list = ListData.asListData(data.getSimpleValue(dataName));
if (list == null || list.size() == 0)
return;
maybeListenForDataChanges(dataName);
String currentLabel = null;
String currentMilestone = null;
for (int i = 0; i < list.size(); i++) {
String item = StringUtils.asString(list.get(i));
if (item == null || item.length() == 0) {
continue;
} else if (NO_LABEL.equals(item) || LABEL_PREFIX.equals(item)) {
currentLabel = currentMilestone = null;
} else if (item.startsWith(LABEL_PREFIX)) {
currentLabel = item.substring(LABEL_PREFIX.length());
currentMilestone = null;
if (currentLabel.startsWith("_"))
hiddenLabels.add(currentLabel);
} else if (item.startsWith(MILESTONE_ID_LABEL_PREFIX)) {
currentMilestone = item;
hiddenLabels.add(currentMilestone);
if (currentLabel.startsWith("Milestone:"))
hiddenLabels.add(currentLabel.substring(10));
} else if (LABEL_HIDDEN_MARKER.equals(item)) {
hiddenLabels.add(currentLabel);
} else {
String taskID = item;
Set labelsForTask = (Set) labelData.get(taskID);
if (labelsForTask == null) {
labelsForTask = new HashSet();
labelData.put(taskID, labelsForTask);
}
if (currentLabel != null)
labelsForTask.add(currentLabel);
if (currentMilestone != null)
labelsForTask.add(currentMilestone);
}
}
}
use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.
the class EVCalculator method maybeReorderTasksAfterPostmortemTask.
private void maybeReorderTasksAfterPostmortemTask(List<EVTask> evLeaves, EVTask onePmTask) {
// find this task within the ev leaf list.
int pmTaskPos = evLeaves.indexOf(onePmTask);
if (pmTaskPos == -1)
return;
// identify the EVTask which is the parent of the PSP task which
// contains this postmortem phase.
EVTask pspTask = onePmTask.getParent();
if (pspTask == null)
return;
EVTask parentOfPspTask = pspTask.getParent();
if (parentOfPspTask == null)
return;
int pspChildPos = parentOfPspTask.getChildIndex(pspTask);
if (pspChildPos == -1)
return;
// get a list of the official, acceptable phases in the controlling
// process definition.
ListData phaseListSpec = onePmTask.getAcceptableNodeTypes();
if (phaseListSpec == null || !phaseListSpec.test())
return;
List phaseList = phaseListSpec.asList();
int postmortemPos = phaseList.indexOf("Postmortem");
if (postmortemPos == -1)
return;
// find the tasks that immediately follow this postmortem task which
// are reordering candidates, and move them if applicable.
int planTaskOrdinal = pspTask.getChild(0).taskOrdinal;
int pmTaskOrdinal = onePmTask.taskOrdinal;
int lastTaskOrdinal = pmTaskOrdinal;
EVTask lastReorderedTask = null;
for (int i = pspChildPos; ++i < parentOfPspTask.getNumChildren(); ) {
// Examine each of the siblings that follows the PSP task.
EVTask oneSubsequentTask = parentOfPspTask.getChild(i);
int oneSubsequentTaskPos = evLeaves.indexOf(oneSubsequentTask);
// leaf task, break out of the reordering loop.
if (oneSubsequentTaskPos == -1)
break;
// stop searching for reorderable tasks.
if (oneSubsequentTask.taskOrdinal < planTaskOrdinal || oneSubsequentTask.taskOrdinal > pmTaskOrdinal)
break;
// keep looking at subsequent tasks to see if they need to be moved.
if (oneSubsequentTask.taskOrdinal == lastTaskOrdinal) {
// find the nominal position in the leaf list where this task
// should be inserted, based on its type.
int insertionPos = getInsertionPosWithinPspPhases(evLeaves, oneSubsequentTask, pmTaskPos, phaseList, lastReorderedTask);
// that we should stop searching for reorderable tasks.
if (insertionPos == -1)
break;
// If the task needs to be reordered, do it.
if (insertionPos != oneSubsequentTaskPos && insertionPos != oneSubsequentTaskPos + 1) {
evLeaves.remove(oneSubsequentTaskPos);
if (insertionPos > oneSubsequentTaskPos)
insertionPos--;
evLeaves.add(insertionPos, oneSubsequentTask);
pmTaskPos = evLeaves.indexOf(onePmTask);
}
}
// Keep track of the last task and ordinal we've seen.
lastReorderedTask = oneSubsequentTask;
lastTaskOrdinal = oneSubsequentTask.taskOrdinal;
}
}
use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.
the class ResultSet method getPrefixList.
/** Return the list of prefixes that would have been used to generate
* a result set.
*/
public static String[] getPrefixList(DataRepository data, Map queryParameters, String prefix) {
ListData list = getFilteredList(data, getForParam(queryParameters), getConditions(queryParameters), getOrderBy(queryParameters), prefix);
int i = list.size();
String[] result = new String[i];
while (i-- > 0) result[i] = asString(list.get(i));
return result;
}
Aggregations