Search in sources :

Example 16 with DashHierarchy

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;
}
Also used : DashboardContext(net.sourceforge.processdash.DashboardContext) DashboardTimeLog(net.sourceforge.processdash.log.time.DashboardTimeLog) TimeLoggingModel(net.sourceforge.processdash.log.time.TimeLoggingModel) DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 17 with DashHierarchy

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;
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) Point(java.awt.Point) PropertyKey(net.sourceforge.processdash.hier.PropertyKey) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 18 with DashHierarchy

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;
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) Point(java.awt.Point) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 19 with DashHierarchy

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));
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) Iterator(java.util.Iterator) XMLDepthFirstIterator(net.sourceforge.processdash.util.XMLDepthFirstIterator) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List)

Example 20 with DashHierarchy

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;
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) DataRepository(net.sourceforge.processdash.data.repository.DataRepository) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Aggregations

DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)56 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)40 ArrayList (java.util.ArrayList)7 ListData (net.sourceforge.processdash.data.ListData)6 List (java.util.List)5 HashMap (java.util.HashMap)4 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)4 Point (java.awt.Point)3 Iterator (java.util.Iterator)3 ProcessDashboard (net.sourceforge.processdash.ProcessDashboard)3 SimpleData (net.sourceforge.processdash.data.SimpleData)3 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)3 IOException (java.io.IOException)2 Enumeration (java.util.Enumeration)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 HierarchyAlterer (net.sourceforge.processdash.hier.HierarchyAlterer)2 Prop (net.sourceforge.processdash.hier.Prop)2 DefectLog (net.sourceforge.processdash.log.defects.DefectLog)2 DefectLogID (net.sourceforge.processdash.log.defects.DefectLogID)2