Search in sources :

Example 36 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class SyncWBS method findProject.

/** Locates the enclosing team project, and sets the values of the
     * {@link #projectRoot} and {@link #processID} fields accordingly.
     * If there is no enclosing team project, both will be set to null.
     */
private void findProject() {
    DashHierarchy hierarchy = getPSPProperties();
    PropertyKey key = hierarchy.findExistingKey(getPrefix());
    while (key != null) {
        String templateID = hierarchy.getID(key);
        if (templateID != null && templateID.endsWith(MASTER_ROOT)) {
            projectRoot = key.path();
            processID = templateID.substring(0, templateID.length() - MASTER_ROOT.length());
            isTeam = isMaster = true;
            return;
        }
        if (templateID != null && templateID.endsWith(TEAM_ROOT)) {
            projectRoot = key.path();
            processID = templateID.substring(0, templateID.length() - TEAM_ROOT.length());
            isTeam = true;
            isMaster = false;
            return;
        }
        if (templateID != null && templateID.endsWith(INDIV_ROOT)) {
            projectRoot = key.path();
            processID = templateID.substring(0, templateID.length() - INDIV_ROOT.length());
            isTeam = isMaster = false;
            return;
        }
        if (templateID != null && templateID.endsWith(INDIV2_ROOT)) {
            projectRoot = key.path();
            processID = templateID.substring(0, templateID.length() - INDIV2_ROOT.length());
            isTeam = isMaster = false;
            return;
        }
        key = key.getParent();
    }
    projectRoot = processID = null;
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 37 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class TimingMetricsRecorderTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    data = new MockDataContext();
    baseTimeLog = new MockBaseTimeLog();
    timeLog = new TimeLogModifications(baseTimeLog);
    approver = new MockApprover();
    hierarchy = new DashHierarchy(null);
    hierarchy.loadXML(openFile("hier3.xml"), new DashHierarchy(null));
    recorder = new TimingMetricsRecorder(timeLog, data, hierarchy, approver);
    recorder.refreshMetrics();
    expectedTimes = new HashMap();
    for (int i = 0; i < TIMELOG3_CONTENTS.length; i++) {
        String path = (String) TIMELOG3_CONTENTS[i][0];
        Integer elapsed = (Integer) TIMELOG3_CONTENTS[i][2];
        expectedTimes.put(path, elapsed);
    }
}
Also used : HashMap(java.util.HashMap) DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy)

Example 38 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class TimeLoggingSimulation method getPathStr.

private String getPathStr(int[] newPath) {
    DashHierarchy hier = harness.getDashboard().getHierarchy();
    PropertyKey key = PropertyKey.ROOT;
    for (int i = 0; i < newPath.length; i++) key = hier.getChildKey(key, newPath[i]);
    return key.path();
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey) Point(java.awt.Point)

Example 39 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class DefectUtil method guessRemovalPhase.

/** Make an educated guess about which removal phase might correspond to
     * a particular dashboard task
     */
private static String guessRemovalPhase(String defectPath, String taskPath, DashboardContext context) {
    // first, check to see if this task has registered an effective phase
    ProcessUtil pu = new ProcessUtil(context.getData());
    String effectivePhase = pu.getEffectivePhase(taskPath, false);
    if (effectivePhase != null)
        return effectivePhase;
    // if no effective phase was registered, infer it from the path.  We
    // don't use the path inference provided by ProcessUtil because we
    // need to preserve more than just the final path segment. For example,
    // in the case of a PSP3 project, we need to keep both the cycle name
    // and the phase name.
    int prefixLength = defectPath.length() + 1;
    if (taskPath.length() > prefixLength && Filter.pathMatches(taskPath, defectPath))
        return taskPath.substring(prefixLength);
    // no luck so far.  Look at the task in question, and see if it only
    // includes a single phase child (typical for old-style team projects
    // with phase stubs).
    DashHierarchy hier = context.getHierarchy();
    PropertyKey defectPathKey = hier.findExistingKey(defectPath);
    if (defectPathKey != null) {
        Enumeration leafNames = hier.getLeafNames(defectPathKey);
        List possibleMatches = new ArrayList();
        while (leafNames.hasMoreElements()) {
            String oneLeaf = (String) leafNames.nextElement();
            if (oneLeaf.length() > prefixLength) {
                String leafTail = oneLeaf.substring(prefixLength);
                if (leafTail.indexOf('/') == -1)
                    possibleMatches.add(leafTail);
            }
        }
        if (possibleMatches.size() == 1)
            return (String) possibleMatches.get(0);
    }
    return null;
}
Also used : Enumeration(java.util.Enumeration) DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ProcessUtil(net.sourceforge.processdash.process.ProcessUtil) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 40 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class JoinTeamProject method maybeReroot.

/** If the current prefix doesn't name the root of a team project,
     * search upward through the hierarchy to find the project root,
     * and change the active prefix to name that node. */
protected void maybeReroot() throws TinyCGIException {
    DashHierarchy hierarchy = getPSPProperties();
    PropertyKey key = hierarchy.findExistingKey(getPrefix());
    boolean rerooted = false;
    String projectRoot = null;
    do {
        String templateID = hierarchy.getID(key);
        if (templateID != null && templateID.endsWith("/TeamRoot")) {
            projectRoot = key.path();
            break;
        }
        rerooted = true;
        key = key.getParent();
    } while (key != null);
    if (rerooted) {
        if (projectRoot != null)
            parameters.put("hierarchyPath", projectRoot);
        else
            throw new TinyCGIException(404, "Not Fount");
    }
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

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