Search in sources :

Example 11 with DashHierarchy

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;
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 12 with DashHierarchy

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;
}
Also used : Enumeration(java.util.Enumeration) DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 13 with DashHierarchy

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;
}
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 14 with DashHierarchy

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");
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 15 with DashHierarchy

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);
        }
    }
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) SimpleData(net.sourceforge.processdash.data.SimpleData) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Aggregations

DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)56 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)40 ArrayList (java.util.ArrayList)7 ListData (net.sourceforge.processdash.data.ListData)6 List (java.util.List)5 HashMap (java.util.HashMap)4 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)4 Point (java.awt.Point)3 Iterator (java.util.Iterator)3 ProcessDashboard (net.sourceforge.processdash.ProcessDashboard)3 SimpleData (net.sourceforge.processdash.data.SimpleData)3 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)3 IOException (java.io.IOException)2 Enumeration (java.util.Enumeration)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 HierarchyAlterer (net.sourceforge.processdash.hier.HierarchyAlterer)2 Prop (net.sourceforge.processdash.hier.Prop)2 DefectLog (net.sourceforge.processdash.log.defects.DefectLog)2 DefectLogID (net.sourceforge.processdash.log.defects.DefectLogID)2