use of net.sourceforge.processdash.process.WorkflowInfo in project processdash by dtuma.
the class DefectUtil method getWorkflowDefectPhases.
/**
* If the given path is part of a team workflow, return a list of phases
* that are appropriate for defect injection/removal.
*
* @param taskPath
* the path of a task within the dashboard
* @param context
* the dashboard context
* @return a list of phases appropriate for the containing workflow.
*/
public static DefectPhaseList getWorkflowDefectPhases(String taskPath, DashboardContext context) {
// retrieve the workflow info for the current project. If no workflow
// info is found, return null.
DataRepository data = context.getData();
WorkflowInfo workflowInfo = WorkflowInfoFactory.get(data, taskPath);
if (workflowInfo == null || workflowInfo.isEmpty())
return null;
// check to see if this is a PSP task.
String path = taskPath;
String parentPath = DataRepository.chopPath(taskPath);
String phaseSuffix = null;
if (isPspTask(data, parentPath)) {
phaseSuffix = taskPath.substring(parentPath.length());
path = parentPath;
} else if (isPspTask(data, taskPath)) {
phaseSuffix = "/Code";
taskPath += "/Code";
}
// see if the current task came from a (potentially nested) workflow.
// If so, create (potentially nested) workflow phase objects to
// represent all of the enclosing workflow tasks.
Map<String, DefectPhase> enclosingPhases = new HashMap();
while (path != null) {
// see if this task represents a phase in a workflow.
String workflowId = getWorkflowID(data, path);
if (workflowId != null && phaseSuffix != null)
workflowId += phaseSuffix;
Phase phase = workflowInfo.getPhase(workflowId);
if (phase == null)
// not a workflow phase. We are done.
break;
// represent subdivided tasks.)
if (!enclosingPhases.containsKey(phase.getPhaseId())) {
// task. Update their phase IDs to document this relationship.
for (DefectPhase dp : enclosingPhases.values()) dp.phaseID = phase.getPhaseId() + "," + dp.phaseID;
// enclosing phases
for (Phase onePhase : phase.getWorkflow().getPhases()) {
DefectPhase dp = new DefectPhase(onePhase);
enclosingPhases.put(onePhase.getPhaseId(), dp);
}
}
// step up to the parent and look for enclosing phases there, too
path = DataRepository.chopPath(path);
phaseSuffix = null;
}
// now that we have found the root of this enactment, scan all tasks
// underneath to find any other workflows that are represented. Add
// them to our result in the order they appear.
DefectPhaseList result = new DefectPhaseList();
result.workflowInfo = workflowInfo;
if (!enclosingPhases.isEmpty()) {
DashHierarchy hier = context.getHierarchy();
result.workflowRoot = hier.findExistingKey(path);
scanForWorkflowTasks(data, hier, result.workflowRoot, null, getDevelopmentPhases(data, path), result, new HashSet(), enclosingPhases, taskPath);
// set the default injection phase, if necessary
if (result.defaultRemovalPhase == -1)
result.defaultInjectionPhase = -1;
else if (result.defaultInjectionPhase == -1)
result.defaultInjectionPhase = result.defaultRemovalPhase - 1;
}
return result;
}
use of net.sourceforge.processdash.process.WorkflowInfo in project processdash by dtuma.
the class HierarchySynchronizer method updateWorkflowPhasesInDefects.
private void updateWorkflowPhasesInDefects() {
if (workflowXml != null) {
DefectWorkflowPhaseUpdater u = new DefectWorkflowPhaseUpdater(new WorkflowInfo(workflowXml), !whatIfMode) {
public void defectNeedsSave(String path, Defect d) {
saveDefect(path, d);
}
};
DefectAnalyzer.run(hierarchy, projectKey, true, u);
// Log a "sync change" to tell the user about invalid phases.
for (String path : u.getPathsWithNewInvalidPhases()) {
String msg = resources.format("Bad_Defect_Phase_FMT", path);
if (!changes.contains(msg))
changes.add(msg);
}
}
}
Aggregations