Search in sources :

Example 1 with WorkflowEnactmentHelper

use of net.sourceforge.processdash.tool.db.WorkflowEnactmentHelper in project processdash by dtuma.

the class WorkflowTaskPlanSummary method doGet.

@Override
protected void doGet() throws IOException {
    // retrieve information about the workflow this task is a part of.
    DataContext data = getDataContext();
    WorkflowEnactmentHelper workflow = new WorkflowEnactmentHelper(data, getPrefix());
    Map<String, String> tasks = workflow.getEnactmentTasks(TaskMapType.PhaseID);
    if (tasks == null || tasks.isEmpty()) {
        out.write("Location: probeSummaryNA.shtm\r\n\r\n");
        return;
    }
    String rootPath = workflow.getRootItemPath();
    tasks.remove(rootPath);
    String workflowName = workflow.getWorkflowProcessName();
    String workflowID = workflow.getWorkflowProcessID();
    // Gather up information about the tasks in this workflow enactment.
    StringBuffer uri = new StringBuffer().append(env.get("SCRIPT_PATH")).append(".shtm");
    ListData fullPaths = new ListData();
    ListData orphanedTimePaths = new ListData();
    Map<String, ListData> coqLists = new HashMap();
    for (String coqType : COQ_TYPES) coqLists.put(coqType, new ListData());
    int phaseNum = 0;
    for (Entry<String, String> e : tasks.entrySet()) {
        String taskPath = e.getKey();
        TaskNodeType nodeType = workflow.getNodeType(taskPath);
        if (nodeType == TaskNodeType.Leaf || nodeType == TaskNodeType.PSP)
            fullPaths.add(taskPath);
        if (nodeType != TaskNodeType.Parent || hasOrphanedTime(data, taskPath)) {
            String shortName = taskPath.substring(rootPath.length() + 1);
            HTMLUtils.appendQuery(uri, "phases", Integer.toString(phaseNum));
            HTMLUtils.appendQuery(uri, phaseNum + "_Rel_Path", shortName);
            HTMLUtils.appendQuery(uri, phaseNum + "_Abs_Path", taskPath);
            if (nodeType == TaskNodeType.Parent) {
                orphanedTimePaths.add(taskPath);
                HTMLUtils.appendQuery(uri, phaseNum + "_Orphan", "t");
            }
            phaseNum++;
        }
        String phaseID = e.getValue();
        String phaseType = workflow.getWorkflowPhaseTypes().get(phaseID);
        if (phaseType != null && !"PSP".equals(phaseType)) {
            ListData coqList = coqLists.get(phaseType);
            if (coqList == null)
                coqList = coqLists.get("Failure");
            coqList.add(taskPath);
        }
    }
    // Write data into the repository for use by the plan summary form
    data.putValue("Workflow_Root_Path", StringData.create(rootPath));
    data.putValue("Workflow_Name", StringData.create(workflowName));
    data.putValue("Workflow_ID", StringData.create(workflowID));
    data.putValue("Workflow_Task_Paths", fullPaths);
    data.putValue("Workflow_Orphaned_Time_Paths", orphanedTimePaths);
    for (String coqType : COQ_TYPES) data.putValue("Workflow_Task_Paths/" + coqType, coqLists.get(coqType));
    String html = getRequestAsString(uri.toString());
    writeHeader();
    out.write(html);
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext) TaskNodeType(net.sourceforge.processdash.tool.db.WorkflowEnactmentHelper.TaskNodeType) HashMap(java.util.HashMap) WorkflowEnactmentHelper(net.sourceforge.processdash.tool.db.WorkflowEnactmentHelper) ListData(net.sourceforge.processdash.data.ListData)

Example 2 with WorkflowEnactmentHelper

use of net.sourceforge.processdash.tool.db.WorkflowEnactmentHelper in project processdash by dtuma.

the class ProbeDatabaseUtil method spreadEstimatedTime.

/**
     * Use historical time-in-phase data to spread a time estimate across the
     * tasks in the current process enactment
     * 
     * @param histData
     *            historical data
     * @param estimate
     *            the new total time estimate
     */
public void spreadEstimatedTime(ProbeData histData, double estimate) {
    // get a list of the tasks in the current process enactment
    WorkflowEnactmentHelper tasks = new WorkflowEnactmentHelper(data, prefix);
    Map<String, String> targetTasks = tasks.getEnactmentTasks(TaskMapType.PhaseName, TaskNodeType.Leaf);
    if (targetTasks == null)
        // null indicates that the database queries failed. Abort.
        return;
    Map<String, String> pspTasks = tasks.getEnactmentTasks(TaskMapType.PhaseName, TaskNodeType.PSP);
    targetTasks.putAll(pspTasks);
    Set<String> workflowPspSteps = new HashSet(pspTasks.values());
    // time estimate across those tasks using historical time-in-phase data.
    if (!targetTasks.isEmpty()) {
        Map timeInPhase = ((ProbeDatabaseResultSet) histData.getResultSet()).getTimeInPhase();
        spreadTimeUsingWeights(targetTasks, workflowPspSteps, timeInPhase, estimate);
    }
}
Also used : WorkflowEnactmentHelper(net.sourceforge.processdash.tool.db.WorkflowEnactmentHelper) Map(java.util.Map) HashSet(java.util.HashSet)

Example 3 with WorkflowEnactmentHelper

use of net.sourceforge.processdash.tool.db.WorkflowEnactmentHelper in project processdash by dtuma.

the class ProbeDatabaseUtil method getCurrentEstimatedWorkflowTime.

/**
     * Retrieve the total estimated time (in minutes) for the tasks in the
     * current process enactment
     */
public double getCurrentEstimatedWorkflowTime() {
    // get a list of the tasks in the current process enactment
    WorkflowEnactmentHelper tasks = new WorkflowEnactmentHelper(data, prefix);
    Map<String, String> targetTasks = tasks.getEnactmentTasks(TaskMapType.PhaseName, TaskNodeType.Leaf, TaskNodeType.PSP);
    if (targetTasks == null)
        // null indicates that the database queries failed. Abort.
        return Double.NaN;
    // sum up the estimated time of the tasks in this enactment
    double result = 0;
    for (Iterator i = targetTasks.keySet().iterator(); i.hasNext(); ) {
        String oneTask = (String) i.next();
        result += getEstimate(oneTask);
    }
    return result;
}
Also used : WorkflowEnactmentHelper(net.sourceforge.processdash.tool.db.WorkflowEnactmentHelper) Iterator(java.util.Iterator)

Aggregations

WorkflowEnactmentHelper (net.sourceforge.processdash.tool.db.WorkflowEnactmentHelper)3 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 DataContext (net.sourceforge.processdash.data.DataContext)1 ListData (net.sourceforge.processdash.data.ListData)1 TaskNodeType (net.sourceforge.processdash.tool.db.WorkflowEnactmentHelper.TaskNodeType)1