Search in sources :

Example 1 with DataContext

use of net.sourceforge.processdash.data.DataContext 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 DataContext

use of net.sourceforge.processdash.data.DataContext in project processdash by dtuma.

the class AddNewSnippet method getSortedSnippets.

private TreeSet getSortedSnippets() {
    DataContext ctx = getDataContext();
    String[] deny = (String[]) parameters.get("deny_ALL");
    Set allSnippets = SnippetDefinitionManager.getAllSnippets();
    TreeSet snippets = new TreeSet();
    for (Iterator i = allSnippets.iterator(); i.hasNext(); ) {
        SnippetDefinition d = (SnippetDefinition) i.next();
        if (!d.shouldHide() && !denied(d, deny) && d.matchesContext(ctx))
            snippets.add(new SnipData(d));
    }
    return snippets;
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext) Set(java.util.Set) TreeSet(java.util.TreeSet) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) SnippetDefinition(net.sourceforge.processdash.ui.snippet.SnippetDefinition)

Example 3 with DataContext

use of net.sourceforge.processdash.data.DataContext in project processdash by dtuma.

the class MobileSetupWizard method doPost.

@Override
protected void doPost() throws IOException {
    // make certain the request is coming from the local computer
    DashController.checkIP(env.get("REMOTE_ADDR"));
    // check for improper operating modes
    if (Settings.isReadOnly()) {
        printRedirect("mobileError.shtm?readOnly");
        return;
    } else if (CompressedInstanceLauncher.isRunningFromCompressedData()) {
        printRedirect("mobileError.shtm?quickLaunch");
        return;
    }
    // get the URL of our bridged working directory
    ProcessDashboard dash = (ProcessDashboard) getDashboardContext();
    WorkingDirectory workingDirectory = dash.getWorkingDirectory();
    String location = workingDirectory.getDescription();
    if (!location.startsWith("http")) {
        printRedirect("mobileError.shtm?notBridged");
        return;
    }
    // check for connectivity to the PDES
    try {
        URL u = new URL(location);
        FileUtils.slurpContents(u.openStream(), true);
    } catch (IOException ioe) {
        storePdesLocation(location);
        printRedirect("mobileError.shtm?noNetwork");
        return;
    }
    // ask the PDES for a data token for our directory
    String dataToken;
    try {
        dataToken = getDataToken(location);
    } catch (IOException ioe) {
        printRedirect("mobileError.shtm?upgradePdes");
        return;
    }
    // if we received the token "-", mobile support is disabled by the PDES
    if ("-".equals(dataToken)) {
        storePdesLocation(location);
        printRedirect("mobileError.shtm?pdesMobileDisabled");
        return;
    }
    // retrieve the username we are using for our data
    String username = HttpAuthenticator.getLastUsername();
    // prepare the dashboard for use with the mobile REST APIs
    try {
        DashController.assignHierarchyNodeIDs();
    } catch (IllegalStateException ise) {
        printRedirect("mobileError.shtm?hierEditor");
        return;
    }
    dash.flushWorkingData();
    // write information to the repository, and print a success page
    DataContext ctx = getDataRepository();
    ctx.putValue("/mobile//Data_Token", StringData.create(dataToken));
    if (username != null)
        ctx.putValue("/mobile//Username", StringData.create(username));
    printRedirect("mobileSuccess.shtm");
}
Also used : WorkingDirectory(net.sourceforge.processdash.tool.bridge.client.WorkingDirectory) DataContext(net.sourceforge.processdash.data.DataContext) ProcessDashboard(net.sourceforge.processdash.ProcessDashboard) IOException(java.io.IOException) URL(java.net.URL)

Example 4 with DataContext

use of net.sourceforge.processdash.data.DataContext in project processdash by dtuma.

the class StudentProfileValidator method checkValues.

private boolean checkValues() {
    String owner = getOwner();
    if (owner == null || owner.trim().length() == 0)
        return false;
    DataContext c = getDataContext();
    for (String name : NAMES_TO_CHECK) {
        SimpleData sd = c.getSimpleValue(name);
        if (sd == null || !sd.test() || sd.format().trim().length() == 0)
            return false;
    }
    c.putValue("../Student_Profile_Complete", ImmutableDoubleData.TRUE);
    if (c.getSimpleValue("Completed") == null)
        c.putValue("Completed", new DateData());
    return true;
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext) DateData(net.sourceforge.processdash.data.DateData) SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 5 with DataContext

use of net.sourceforge.processdash.data.DataContext in project processdash by dtuma.

the class Program2SizeReminder method writeContents.

@Override
protected void writeContents() throws IOException {
    // First, look at the project which is invoking this script, and see
    // if it is preceded by a PSP0 program. If not, print nothing and exit.
    DataContext data = getDataContext();
    SimpleData prevProgramVal = data.getSimpleValue("Previous_Program");
    if (!hasValue(prevProgramVal))
        return;
    String prevProgram = prevProgramVal.format();
    SimpleData psp0tag = data.getSimpleValue(prevProgram + "/PSP0");
    if (!hasValue(psp0tag))
        return;
    // Next, check to see if size data has been entered for the preceding
    // PSP0 program. If it has, print nothing and exit.
    SimpleData psp0size = data.getSimpleValue(prevProgram + "/New & Changed LOC");
    if (hasValue(psp0size))
        return;
    // phase of this project.
    if (hasValue(data.getSimpleValue("Test/Time")) || hasValue(data.getSimpleValue("Postmortem/Time")) || hasValue(data.getSimpleValue("New & Changed LOC"))) {
        printSizeWarningBlock(prevProgram);
    }
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext) SimpleData(net.sourceforge.processdash.data.SimpleData)

Aggregations

DataContext (net.sourceforge.processdash.data.DataContext)18 SimpleData (net.sourceforge.processdash.data.SimpleData)5 ArrayList (java.util.ArrayList)4 Iterator (java.util.Iterator)4 List (java.util.List)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ProcessDashboard (net.sourceforge.processdash.ProcessDashboard)2 DateData (net.sourceforge.processdash.data.DateData)2 ListData (net.sourceforge.processdash.data.ListData)2 ProcessUtil (net.sourceforge.processdash.process.ProcessUtil)2 BufferedOutputStream (java.io.BufferedOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 URL (java.net.URL)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 DoubleData (net.sourceforge.processdash.data.DoubleData)1