Search in sources :

Example 1 with TinyCGIException

use of net.sourceforge.processdash.net.http.TinyCGIException in project processdash by dtuma.

the class EVWeekReport method writeContents.

/** Generate CGI output. */
protected void writeContents() throws IOException {
    EVReportSettings settings = new EVReportSettings(getDataRepository(), parameters, getPrefix());
    // Get the name of the earned value model to report on.
    String taskListName = settings.getTaskListName();
    if (taskListName == null)
        throw new IOException("No EV task list specified.");
    // Load and recalculate the named earned value model.
    EVTaskList evModel = EVTaskList.openExisting(taskListName, getDataRepository(), getPSPProperties(), getObjectCache(), // change notification not required
    false);
    if (evModel == null)
        throw new TinyCGIException(404, "Not Found", "No such task/schedule");
    UserFilter f = settings.getUserGroupFilter();
    if (f != null && !UserGroup.isEveryone(f) && evModel instanceof EVTaskListRollup)
        ((EVTaskListRollup) evModel).applyTaskListFilter(new EVTaskListGroupFilter(f));
    EVTaskFilter taskFilter = settings.getEffectiveFilter(evModel);
    EVTaskListFilter privacyFilter = null;
    UserFilter pf = GroupPermission.getGrantedMembers(EVPermissions.PERSONAL_WEEK);
    if (!UserGroup.isEveryone(pf))
        privacyFilter = new EVTaskListGroupFilter(pf);
    EVDependencyCalculator depCalc = new EVDependencyCalculator(getDataRepository(), getPSPProperties(), getObjectCache());
    evModel.setDependencyCalculator(depCalc);
    evModel.setTaskLabeler(new DefaultTaskLabeler(getDashboardContext()));
    evModel.recalc();
    EVSchedule schedule = evModel.getSchedule();
    String effDateParam = getParameter(EFF_DATE_PARAM);
    Date effDate = null;
    if (effDateParam != null)
        try {
            effDate = new Date(Long.parseLong(effDateParam));
        } catch (Exception e) {
        }
    boolean monthly = isMonthly(settings);
    if (effDate == null || parameters.containsKey(ADJ_EFF_DATE_PARAM)) {
        // if the user hasn't specified an effective date, then use the
        // current time to round the effective date to the nearest week.
        // With a Sunday - Saturday schedule, the following line will show
        // the report for the previous week through Tuesday, and will
        // start showing the next week's report on Wednesday.
        Date now = effDate;
        if (now == null)
            now = EVCalculator.getFixedEffectiveDate();
        if (now == null)
            now = new Date();
        int dayOffset = (monthly ? 0 : (effDate == null ? 3 : 7));
        Date effDateTime = new Date(now.getTime() + EVSchedule.WEEK_MILLIS * dayOffset / 7);
        // now, identify the schedule boundary that precedes the effective
        // date and time; use that as the effective date.
        Date scheduleEnd = schedule.getLast().getEndDate();
        Date firstPeriodEnd = schedule.get(1).getEndDate();
        if (effDateTime.compareTo(scheduleEnd) >= 0) {
            if (effDate == null)
                effDate = maybeRoundToMonthEnd(monthly, scheduleEnd);
            else if (monthly)
                effDate = roundToMonthEnd(effDate);
            else
                effDate = extrapolateWeekAfterScheduleEnd(effDateTime, scheduleEnd);
        } else if (monthly) {
            Date scheduleStart = schedule.get(1).getBeginDate();
            if (effDateTime.before(scheduleStart))
                effDateTime = scheduleStart;
            effDate = roundToMonthEnd(effDateTime);
        } else if (effDateTime.compareTo(firstPeriodEnd) <= 0)
            effDate = firstPeriodEnd;
        else
            effDate = schedule.getPeriodStart(effDateTime);
        // make certain we have an effective date to proceed with.
        if (effDate == null)
            effDate = maybeRoundToMonthEnd(monthly, new Date());
    }
    int purpose = PLAIN_REPORT;
    if (evModel instanceof EVTaskListRollup && parameters.containsKey(SPLIT_PARAM))
        purpose = SPLIT_REPORT;
    writeReport(taskListName, evModel, effDate, settings, taskFilter, privacyFilter, purpose);
}
Also used : EVTaskListGroupFilter(net.sourceforge.processdash.ev.EVTaskListGroupFilter) EVSchedule(net.sourceforge.processdash.ev.EVSchedule) EVTaskFilter(net.sourceforge.processdash.ev.EVTaskFilter) EVTaskListRollup(net.sourceforge.processdash.ev.EVTaskListRollup) UserFilter(net.sourceforge.processdash.team.group.UserFilter) IOException(java.io.IOException) DefaultTaskLabeler(net.sourceforge.processdash.ev.DefaultTaskLabeler) Date(java.util.Date) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException) IOException(java.io.IOException) EVTaskListFilter(net.sourceforge.processdash.ev.EVTaskListFilter) EVDependencyCalculator(net.sourceforge.processdash.ev.EVDependencyCalculator) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Example 2 with TinyCGIException

use of net.sourceforge.processdash.net.http.TinyCGIException in project processdash by dtuma.

the class EditSubprojectList method ensureMasterProject.

private void ensureMasterProject() throws TinyCGIException {
    DashHierarchy hierarchy = getPSPProperties();
    PropertyKey key = hierarchy.findExistingKey(getPrefix());
    String templateID = hierarchy.getID(key);
    if (templateID == null || !templateID.endsWith(MASTER_ROOT))
        throw new TinyCGIException(403, "Not a Master Project");
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Example 3 with TinyCGIException

use of net.sourceforge.processdash.net.http.TinyCGIException in project processdash by dtuma.

the class WorkflowPlanSummary method writeContents.

@Override
protected void writeContents() throws IOException {
    ChartData chartData = AnalysisPage.getChartData((HttpServletRequest) env.get(HttpServletRequest.class), true);
    WorkflowHistDataHelper hist = chartData.histData;
    if (hist.getWorkflowName() == null)
        throw new TinyCGIException(404, "The requested workflow was not found.");
    String title = resources.getString("Workflow.Analysis.Title") + " - " + hist.getWorkflowName();
    out.print("<html><head><title>");
    out.print(esc(title));
    out.print("</title>\n");
    out.print(cssLinkHTML());
    if (hist.isFiltering())
        out.write("<link rel='stylesheet' type='text/css' href='filter-style.css'>\n");
    out.print(HTMLUtils.scriptLinkHtml("/lib/overlib.js"));
    out.print("<style>\n");
    out.print(" .rowLabel { padding-right: 10px }\n");
    out.print(" th.plan, th.act { width: 70px; }\n");
    out.print(" td.plan, td.act { padding-right: 4px; border: 1px solid gray; text-align: right }\n");
    out.print(" #filter.collapsed .filterItem { display: none }\n");
    out.print(" #filter.expanded .filterLink { display: none }\n");
    out.print(" #defects th.plan, #defects td.plan { display: none }\n");
    out.print("</style>\n");
    out.print("<script>\n");
    out.print("    function showFilter() {\n");
    out.print("      document.getElementById('filter').className = 'expanded';\n");
    out.print("    }\n");
    out.print("</script>\n");
    out.print("</head>\n");
    out.print("<body><h1>");
    out.print(esc(title));
    out.print("</h1>\n");
    out.write("<table><tr>\n<td style='vertical-align:baseline'><h2>");
    out.print(esc(res("Summary.Title")));
    out.write("&nbsp;</td>\n");
    if (!isExporting())
        writePageSubtitle(hist);
    out.write("</tr></table>\n");
    Map<String, DataPair> sizes = hist.getAddedAndModifiedSizes();
    Map<String, DataPair> timeInPhase = hist.getTotalTimeInPhase();
    Map<String, DataPair>[] defectsByPhase = hist.getDefectsByPhase();
    for (Iterator<String> i = sizes.keySet().iterator(); i.hasNext(); ) {
        if (AnalysisPage.isTimeUnits(i.next()))
            i.remove();
    }
    writeOverallMetrics(sizes, timeInPhase, hist.getPhaseTypes());
    printTable("Size", "Added_&_Modified", sizes, Format.Number, false);
    printTable("Time_in_Phase", null, timeInPhase, Format.Time, true);
    printTimeInPhaseCharts(timeInPhase);
    if (defectsByPhase[1].get(TOTAL_KEY).actual > 0) {
        out.print("<div id=\"defects\">\n");
        setBeforeAndAfterRowLabels(timeInPhase);
        printTable("Defects_Injected", null, defectsByPhase[0], Format.Number, true);
        printTable("Defects_Removed", null, defectsByPhase[1], Format.Number, true);
        printDefectsByPhaseCharts(defectsByPhase);
        writeAdvancedDefectMetrics(hist, defectsByPhase, timeInPhase);
        out.print("</div>\n");
    }
    if (!isExportingToExcel()) {
        out.print("<hr>\n");
        out.print("<a href=\"excel.iqy?fullPage\">");
        out.print(resources.getHTML("Export_to_Excel"));
        out.print("</a>");
    }
    out.print("</body></html>\n");
    if (parameters.containsKey("debug"))
        hist.debugPrintEnactments();
}
Also used : WorkflowHistDataHelper(net.sourceforge.processdash.tool.db.WorkflowHistDataHelper) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException) DataPair(net.sourceforge.processdash.util.DataPair)

Example 4 with TinyCGIException

use of net.sourceforge.processdash.net.http.TinyCGIException in project processdash by dtuma.

the class CmsContentDispatcher method loadPersistedPageContent.

private PageContentTO loadPersistedPageContent(String filename) throws IOException {
    // retrieve the contents of the named file from the persistence service
    InputStream content = CmsDefaultConfig.getPersistence().open(filename);
    if (content == null)
        throw new TinyCGIException(404, "Not Found");
    // parse the contents
    PageContentTO page = CmsDefaultConfig.getSerializer().parse(content);
    return page;
}
Also used : InputStream(java.io.InputStream) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Example 5 with TinyCGIException

use of net.sourceforge.processdash.net.http.TinyCGIException in project processdash by dtuma.

the class RequireEditingPermission method writeContents.

@Override
protected void writeContents() throws IOException {
    // if we are being called from the nested export, print nothing
    String referer = (String) env.get("HTTP_REFERER");
    if (referer != null && referer.endsWith("/reports/form2html.class"))
        return;
    // get the ID of the required parameter
    String perm = getParameter("perm");
    if (perm == null)
        throw new TinyCGIException(400, "Missing perm parameter");
    // if the user has the parameter in question, write nothing
    if (PermissionsManager.getInstance().hasPermission(perm))
        return;
    // redirect to a page that will export to HTML
    out.print("window.location.replace('/reports/form2html.class');");
    out.flush();
}
Also used : TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Aggregations

TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)22 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Date (java.util.Date)3 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)3 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)3 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)3 Map (java.util.Map)2 DefaultTaskLabeler (net.sourceforge.processdash.ev.DefaultTaskLabeler)2 EVDependencyCalculator (net.sourceforge.processdash.ev.EVDependencyCalculator)2 EVTaskListGroupFilter (net.sourceforge.processdash.ev.EVTaskListGroupFilter)2 EVTaskListRollup (net.sourceforge.processdash.ev.EVTaskListRollup)2 UserFilter (net.sourceforge.processdash.team.group.UserFilter)2 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 OutputStream (java.io.OutputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 MalformedURLException (java.net.MalformedURLException)1 URLConnection (java.net.URLConnection)1 ArrayList (java.util.ArrayList)1