use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.
the class TaskStatusApi method getTargetPath.
/** Retrieve the target path from the incoming HTTP request */
private String getTargetPath() {
// use the prefix, if one was supplied in the request
String result = getPrefix();
// selected task
if (!StringUtils.hasValue(result)) {
DashboardContext ctx = getDashboardContext();
DashboardTimeLog tl = (DashboardTimeLog) ctx.getTimeLog();
TimeLoggingModel tlm = tl.getTimeLoggingModel();
result = tlm.getActiveTaskModel().getPath();
}
// verify that the named path exists and is a leaf task
DashHierarchy hier = getPSPProperties();
PropertyKey key = hier.findExistingKey(result);
if (key == null)
throw new WebApiException("no-such-task", 404, "The task '" + result + "' was not found.");
else if (hier.getNumChildren(key) != 0)
throw new WebApiException("not-leaf-task", 400, "The item '" + result + "' is not a leaf task.");
return result;
}
use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.
the class TimeLoggingSimulation method getPathFor.
private int[] getPathFor(String path) {
DashHierarchy hier = harness.getDashboard().getHierarchy();
for (int a = 0; a < 3; a++) {
PropertyKey aKey = hier.getChildKey(PropertyKey.ROOT, a);
for (int b = 0; b < 3; b++) {
PropertyKey bKey = hier.getChildKey(aKey, b);
for (int c = 0; c < 3; c++) {
PropertyKey cKey = hier.getChildKey(bKey, c);
if (path.equals(cKey.path()))
return new int[] { a, b, c };
}
}
}
new Exception("no node found for path " + path).printStackTrace();
System.exit(0);
// unreachable
return null;
}
use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.
the class TimeLoggingSimulation method checkValues.
private boolean checkValues() {
boolean foundErr = false;
boolean loggingModelIsTiming = !getTimeLoggingModel().isPaused();
if (loggingModelIsTiming != isTiming) {
printErr("We disagree with the logging model on whether or not the timer is running.");
foundErr = true;
}
DashHierarchy hier = harness.getDashboard().getHierarchy();
for (int a = 0; a < 3; a++) {
PropertyKey aKey = hier.getChildKey(PropertyKey.ROOT, a);
for (int b = 0; b < 3; b++) {
PropertyKey bKey = hier.getChildKey(aKey, b);
for (int c = 0; c < 3; c++) {
PropertyKey cKey = hier.getChildKey(bKey, c);
if (!checkTimeData(cKey.path(), expectedTimes[a][b][c]))
foundErr = true;
}
}
}
if (foundErr)
printErr("data check complete");
return !foundErr;
}
use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.
the class EVTaskDependencyResolver method findTasksInHierarchy.
private void findTasksInHierarchy(Map newCache, PropertyKey key) {
String path = key.path();
List taskIDs = EVTaskDependency.getTaskIDs(context.getData(), path);
if (taskIDs != null) {
int pref = 100;
String templateID = context.getHierarchy().getID(key);
if (isTemplateIDType(templateID, "/Master"))
pref += 3000;
else if (isTemplateIDType(templateID, "/Team"))
pref += 2000;
else if (isTemplateIDType(templateID, "/Indiv"))
pref += 1000;
for (Iterator i = taskIDs.iterator(); i.hasNext(); ) {
String taskID = (String) i.next();
TaskNameInfo info = new TaskNameInfo(path, pref--);
addToCache(newCache, taskID, info);
}
}
DashHierarchy hierarchy = context.getHierarchy();
for (int i = hierarchy.getNumChildren(key); i-- > 0; ) findTasksInHierarchy(newCache, hierarchy.getChildKey(key, i));
}
use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.
the class OpenTimeLogEditor method getAugmentedHierarchy.
private DashHierarchy getAugmentedHierarchy() {
// create a copy of the standard hierarchy
DashHierarchy result = new DashHierarchy(getPSPProperties().dataPath);
result.copy(getPSPProperties());
// find the leaves in the hierarchy, and augment each leaf with
// supplementary children provided from data element specifications
DataRepository data = getDataRepository();
Enumeration<PropertyKey> leaves = result.getLeaves(PropertyKey.ROOT);
while (leaves.hasMoreElements()) {
PropertyKey leaf = leaves.nextElement();
augmentHierarchy(result, leaf, data);
}
return result;
}
Aggregations