Search in sources :

Example 1 with WorkflowInfo

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;
}
Also used : Phase(net.sourceforge.processdash.process.WorkflowInfo.Phase) HashMap(java.util.HashMap) WorkflowInfo(net.sourceforge.processdash.process.WorkflowInfo) DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) DataRepository(net.sourceforge.processdash.data.repository.DataRepository) HashSet(java.util.HashSet)

Example 2 with WorkflowInfo

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);
        }
    }
}
Also used : DefectWorkflowPhaseUpdater(net.sourceforge.processdash.log.defects.DefectWorkflowPhaseUpdater) WorkflowInfo(net.sourceforge.processdash.process.WorkflowInfo) Defect(net.sourceforge.processdash.log.defects.Defect)

Aggregations

WorkflowInfo (net.sourceforge.processdash.process.WorkflowInfo)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)1 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)1 Defect (net.sourceforge.processdash.log.defects.Defect)1 DefectWorkflowPhaseUpdater (net.sourceforge.processdash.log.defects.DefectWorkflowPhaseUpdater)1 Phase (net.sourceforge.processdash.process.WorkflowInfo.Phase)1