use of net.sourceforge.processdash.process.WorkflowInfo.Phase 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.Phase in project processdash by dtuma.
the class DefectDialog method checkSequence.
/** Check to see if the removal phase is before the injection phase.
*
* If they are out of order, display an error message to the user and
* return false; otherwise return true.
*/
private boolean checkSequence() {
if ("false".equalsIgnoreCase(Settings.getVal("defectDialog.restrictSequence")))
return true;
// retrieve the phases the defect was injected and removed.
DefectPhase injected = (DefectPhase) phase_injected.getSelectedItem();
DefectPhase removed = (DefectPhase) phase_removed.getSelectedItem();
if (injected == removed)
return true;
// in any meaningful way.
if (!NullSafeObjectUtils.EQ(injected.processName, removed.processName))
return true;
if (injected.phaseID != null) {
// if the phases came from a workflow, retrieve the rich phase data
// from the WorkflowInfo object.
Phase injPhase = getWorkflowInfoPhase(injected);
Phase remPhase = getWorkflowInfoPhase(removed);
if (injPhase == null || remPhase == null)
return true;
// compare the positions of the phases within the workflow
List<Phase> phases = injPhase.getWorkflow().getPhases();
int injPos = phases.indexOf(injPhase);
int remPos = phases.indexOf(remPhase);
// after all, and we can't compare them in any meaningful way.
if (injPos == -1 || remPos == -1)
return true;
// if the injection phase precedes the removal phase, it's good
if (injPos <= remPos)
return true;
// case by comparing the legacy process phases.
if (!injPhase.isPspPhase() && remPhase.isPspPhase()) {
injPos = getLegacyPhasePos(injPhase);
remPos = getLegacyPhasePos(remPhase);
if (injPos <= remPos || injPos == -1 || remPos == -1)
return true;
}
} else {
// if the phases are legacy process phases, compare their positions
// within the process.
int injPos = processPhases.indexOf(injected);
int remPos = processPhases.indexOf(removed);
if (injPos == -1 || remPos == -1)
return true;
// if the injection phase precedes the removal phase, it's good
if (injPos <= remPos)
return true;
}
JOptionPane.showMessageDialog(this, resources.getStrings("Sequence_Error_Message"), resources.getString("Sequence_Error_Title"), JOptionPane.ERROR_MESSAGE);
return false;
}
use of net.sourceforge.processdash.process.WorkflowInfo.Phase in project processdash by dtuma.
the class DefectUtil method scanForWorkflowTasks.
private static boolean scanForWorkflowTasks(DataContext data, DashHierarchy hier, PropertyKey parent, String parentWorkflowId, Set<String> developmentPhases, DefectPhaseList result, Set<Phase> phasesSeen, Map<String, DefectPhase> directPhases, String taskPath) {
// quick check to see if the parent node is a non-workflow PSP task
int numChildren = hier.getNumChildren(parent);
boolean parentIsPSP = numChildren > 5 && isPspTask(data, parent.path());
if (parentIsPSP && parentWorkflowId == null)
return false;
// scan the nodes that appear under the parent hierarchy node
for (int i = 0; i < numChildren; i++) {
// see if this node came from a workflow
PropertyKey node = hier.getChildKey(parent, i);
String path = node.path();
String workflowId;
if (parentIsPSP)
workflowId = parentWorkflowId + "/" + node.name();
else
workflowId = getWorkflowID(data, path);
Phase phase = result.workflowInfo.getPhase(workflowId);
// workflow to our result list yet, do that now.
if (phase != null && !phasesSeen.contains(phase)) {
for (Phase onePhase : phase.getWorkflow().getPhases()) {
DefectPhase dp = directPhases.get(onePhase.getPhaseId());
if (dp == null)
dp = new DefectPhase(onePhase);
if (!"Postmortem".equals(dp.legacyPhase))
result.add(dp);
phasesSeen.add(onePhase);
}
}
// recurse over children of this node
boolean nodeIsLeaf = parentIsPSP || scanForWorkflowTasks(data, hier, node, workflowId, developmentPhases, result, phasesSeen, directPhases, taskPath);
// possibly set the default injection and removal phases
if (result.defaultRemovalPhase == -1 && nodeIsLeaf && workflowId != null && phase != null) {
if (path.equals(taskPath))
result.defaultRemovalPhase = findStep(result, workflowId);
else if (developmentPhases.contains(phase.getMcfPhase()))
result.defaultInjectionPhase = findStep(result, workflowId);
}
}
return numChildren == 0;
}
use of net.sourceforge.processdash.process.WorkflowInfo.Phase in project processdash by dtuma.
the class DefectWorkflowPhaseUpdater method maybeFixPhase.
private boolean maybeFixPhase(String path, DefectPhase p) {
if (p == null || p.phaseID == null)
// this is not a workflow phase. Nothing to do
return false;
boolean needsSave = false;
Phase workflowPhase = null;
if (p.phaseID.indexOf(',') == -1) {
// Look up the phase specified by this phaseID.
workflowPhase = info.getPhase(p.phaseID);
} else {
// this phaseID field is multivalued, with comma-separated IDs
// specifying nested workflow phases. Scan these IDs to make
// sure they are still valid.
List idList = new ArrayList(Arrays.asList(p.phaseID.split(",")));
for (int i = idList.size(); i-- > 0; ) {
String oneID = (String) idList.get(i);
Phase onePhase = info.getPhase(oneID);
if (onePhase == null) {
idList.remove(i);
needsSave = true;
} else if (workflowPhase == null) {
workflowPhase = onePhase;
}
}
if (idList.isEmpty()) {
// if we scanned all of the items in the ID list and came
// up emptyhanded, don't discard the bad IDs.
needsSave = false;
} else if (needsSave) {
// if we modified the ID list without completely emptying
// it, save the new value into the DefectPhase object.
p.phaseID = StringUtils.join(idList, ",");
}
}
if (workflowPhase == null) {
// the workflow phase with this ID no longer exists in the
// project. See if we can find a phase with the same name; if
// so, update the phaseID to match what we found.
workflowPhase = info.getPhase(p.processName, p.phaseName.trim());
if (workflowPhase != null) {
p.phaseID = workflowPhase.getPhaseId();
needsSave = true;
}
}
if (workflowPhase == null) {
// the phase name.If that space isn't present, add it.
if (!p.phaseName.endsWith(" ")) {
p.phaseName += " ";
needsSave = saveInvalidPhases;
pathsWithNewInvalidPhases.add(path);
}
} else {
// names and MCF phase match; update them if needed.
if (p.updateFrom(workflowPhase))
needsSave = true;
}
return needsSave;
}
use of net.sourceforge.processdash.process.WorkflowInfo.Phase in project processdash by dtuma.
the class MorePhaseOptionsHandler method buildTree.
private JTree buildTree() {
// build a tree model to contain the phase options.
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
// Add all known workflows to the model.
for (Workflow workflow : workflowPhases.workflowInfo.getWorkflows()) {
DefaultMutableTreeNode workflowNode = new DefaultMutableTreeNode(workflow.getWorkflowName());
root.add(workflowNode);
for (Phase onePhase : workflow.getPhases()) {
DefectPhase dp = new DefectPhase(onePhase);
if (!"Postmortem".equals(dp.legacyPhase))
workflowNode.add(new DefaultMutableTreeNode(dp));
}
}
// Add MCF phases to the model.
if (processPhases != null && !processPhases.isEmpty()) {
String processName = processPhases.get(0).processName;
if (!StringUtils.hasValue(processName))
processName = resources.getString("More_Options.Process_Phases");
DefaultMutableTreeNode mcfNode = new DefaultMutableTreeNode(processName);
root.add(mcfNode);
for (DefectPhase onePhase : processPhases) mcfNode.add(new DefaultMutableTreeNode(onePhase));
}
// Create a JTree for this model.
JTree result = new JTree(root);
result.setRootVisible(false);
result.setShowsRootHandles(true);
result.setToggleClickCount(4);
result.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
result.setVisibleRowCount(10);
new JOptionPaneClickHandler().install(result);
return result;
}
Aggregations