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