use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.
the class CycleSummaryForm method getCycleList.
/** Get the list of PSP3 cycle names under the current PSP3 task. */
private String[] getCycleList() {
String prefix = (String) env.get("PATH_TRANSLATED");
DashHierarchy props = getPSPProperties();
PropertyKey self = props.findExistingKey(prefix);
// WARNING: the "4" on the next line is a magic number which
// depends on the structure of the PSP3 template.
int numCycles = props.getNumChildren(self) - 4;
if (numCycles < 0)
numCycles = 0;
String[] result = new String[numCycles];
while (numCycles-- > 0) // WARNING: the "3" on the next line is a magic number which
// depends on the structure of the PSP3 template.
result[numCycles] = props.getChildKey(self, numCycles + 3).name();
return result;
}
use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.
the class DefectUtil method getDefectPhases.
/** Return the list of phases that should be displayed in a drop-down
* list for selection as defect injection and removal phases.
*
* @param defectPath the path to a task in the dashboard hierarchy
* @param context the dashboard context
* @return a list of phases
*/
public static List getDefectPhases(String defectPath, DashboardContext context) {
int prefixLength = 0;
List result = new ArrayList();
Enumeration leafNames = getInheritedPhaseList(defectPath, context.getData());
if (leafNames == null) {
DashHierarchy hier = context.getHierarchy();
PropertyKey defectPathKey = hier.findExistingKey(defectPath);
if (defectPathKey == null)
return result;
leafNames = hier.getLeafNames(defectPathKey);
prefixLength = defectPath.length() + 1;
}
while (leafNames.hasMoreElements()) {
String item = (String) leafNames.nextElement();
if (item == null || item.length() <= prefixLength)
continue;
item = item.substring(prefixLength);
// forbid defects could set their flag to false. But this will work...
if (item.endsWith("Postmortem") || item.endsWith("Reassessment"))
// don't add to the list.
continue;
result.add(item);
}
return result;
}
use of net.sourceforge.processdash.hier.DashHierarchy 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.hier.DashHierarchy in project processdash by dtuma.
the class MigrateTeamProject 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() throws MigrationException {
DashHierarchy hierarchy = getPSPProperties();
PropertyKey key = hierarchy.findExistingKey(getPrefix());
while (key != null) {
String templateID = hierarchy.getID(key);
if (templateID != null && templateID.endsWith(MASTER_ROOT)) {
throw new MigrationException("notNeededMaster");
}
if (templateID != null && templateID.endsWith(TEAM_ROOT)) {
projectRoot = key.path();
processID = templateID.substring(0, templateID.length() - TEAM_ROOT.length());
isTeam = true;
convertToProcessID = null;
if (getBooleanValue("Team_Project_Migration_Complete"))
throw new MigrationException("alreadyUpgraded");
if (getBooleanValue("Individuals_Using_Stubless_Phases"))
throw new MigrationException("upgradeNotNeeded");
return;
}
if (templateID != null && templateID.endsWith(INDIV_ROOT)) {
projectRoot = key.path();
processID = templateID.substring(0, templateID.length() - INDIV_ROOT.length());
convertToProcessID = getStringValue(CONVERT_DATA_NAME);
isTeam = false;
return;
}
if (templateID != null && templateID.endsWith(INDIV2_ROOT)) {
projectRoot = key.path();
processID = templateID.substring(0, templateID.length() - INDIV2_ROOT.length());
convertToProcessID = getStringValue(CONVERT_DATA_NAME);
if (StringUtils.hasValue(convertToProcessID))
return;
if (getBooleanValue("Team_Project_Migration_Complete"))
throw new MigrationException("alreadyUpgraded");
else
throw new MigrationException("upgradeNotNeeded");
}
key = key.getParent();
}
throw new MigrationException("notTeamProject");
}
use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.
the class TeamStartNotifier method checkAlreadyJoined.
private static void checkAlreadyJoined(DashboardContext ctx, PropertyKey key, String projectID) {
String dataName = DataRepository.createDataName(key.path(), PROJECT_ID);
SimpleData sd = ctx.getData().getSimpleValue(dataName);
if (sd != null && projectID.equals(sd.format())) {
throw new AlreadyJoinedException();
} else {
DashHierarchy hier = ctx.getHierarchy();
int i = hier.getNumChildren(key);
while (i-- > 0) {
PropertyKey childKey = hier.getChildKey(key, i);
checkAlreadyJoined(ctx, childKey, projectID);
}
}
}
Aggregations