Search in sources :

Example 1 with EVTaskListRollup

use of net.sourceforge.processdash.ev.EVTaskListRollup 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 EVTaskListRollup

use of net.sourceforge.processdash.ev.EVTaskListRollup in project processdash by dtuma.

the class EditSubprojectList method updateEVSchedule.

private void updateEVSchedule(Map subprojects) {
    String teamScheduleName = getValue("Project_Schedule_Name");
    logger.log(Level.FINE, "Master project {0} updating master schedule \"{1}\"", new Object[] { getPrefix(), teamScheduleName });
    // open the master schedule
    EVTaskList schedule = EVTaskList.openExisting(teamScheduleName, getDataRepository(), getPSPProperties(), getObjectCache(), false);
    if (!(schedule instanceof EVTaskListRollup)) {
        logger.log(Level.WARNING, "could not find a rollup schedule named \"{0}\"", teamScheduleName);
        return;
    }
    // empty all the children from the current master schedule.
    EVTaskListRollup master = (EVTaskListRollup) schedule;
    for (int i = master.getChildCount(master.getRoot()); i-- > 0; ) {
        EVTask task = (EVTask) master.getChild(master.getRoot(), i);
        master.removeTask(new TreePath(task.getPath()));
    }
    // now add the schedules of all the subprojects.
    for (Iterator i = subprojects.values().iterator(); i.hasNext(); ) {
        Subproject proj = (Subproject) i.next();
        String dataName = DataRepository.createDataName(proj.path, "Project_Schedule_Name");
        SimpleData d = getDataRepository().getSimpleValue(dataName);
        if (d == null) {
            logger.warning("Could not find schedule for subproject " + proj.path);
            continue;
        }
        String subscheduleName = d.format();
        if (!master.addTask(subscheduleName, getDataRepository(), getPSPProperties(), getObjectCache(), false)) {
            logger.warning("Could not add schedule for subproject " + proj.path);
        }
    }
    master.save();
    logger.fine("saved changed task list");
}
Also used : TreePath(javax.swing.tree.TreePath) EVTaskListRollup(net.sourceforge.processdash.ev.EVTaskListRollup) EVTask(net.sourceforge.processdash.ev.EVTask) Iterator(java.util.Iterator) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 3 with EVTaskListRollup

use of net.sourceforge.processdash.ev.EVTaskListRollup in project processdash by dtuma.

the class EVReport method writeCharts.

protected List<ChartItem> writeCharts(EVTaskList evModel, EVSchedule schedule, EVTaskFilter filter, boolean hideNames, int width, int height, ChartListPurpose p, String singleChartId, Map<String, String> chartHelpMap) {
    DashboardContext ctx = getDashboardContext();
    Object exportMarker = parameters.get("EXPORT");
    boolean filterInEffect = (filter != null);
    boolean isRollup = (evModel instanceof EVTaskListRollup);
    List<ChartItem> chartList = TaskScheduleChartUtil.getChartsForTaskList(evModel.getID(), getDataRepository(), filterInEffect, isRollup, hideNames, p);
    for (Iterator i = chartList.iterator(); i.hasNext(); ) {
        ChartItem chart = (ChartItem) i.next();
        if (chart == null) {
            i.remove();
            continue;
        }
        try {
            SnippetWidget w = chart.snip.getWidget("view", null);
            if (w instanceof HtmlEvChart) {
                String chartId = getChartId(chart);
                if (chartHelpMap != null && w instanceof HelpAwareEvChart) {
                    String helpUri = ((HelpAwareEvChart) w).getHelpUri();
                    if (StringUtils.hasValue(helpUri))
                        chartHelpMap.put(chartId, helpUri);
                }
                if (singleChartId != null && !singleChartId.equals(chartId))
                    continue;
                Map environment = TaskScheduleChartUtil.getEnvironment(evModel, schedule, filter, chart.snip, ctx);
                Map params = TaskScheduleChartUtil.getParameters(chart.settings);
                params.put("title", chart.name);
                params.put("width", Integer.toString(width));
                params.put("height", Integer.toString(height));
                params.put("noBorder", "t");
                if (hideNames)
                    params.put(CUSTOMIZE_HIDE_NAMES, "t");
                if (exportMarker != null)
                    params.put("EXPORT", exportMarker);
                else if (singleChartId == null)
                    params.put("href", getChartDrillDownUrl(chartId));
                // write the chart to an in-memory buffer. If any errors
                // occur, we will fall out to the exception handler.
                StringWriter buf = new StringWriter();
                ((HtmlEvChart) w).writeChartAsHtml(buf, environment, params);
                // The generation of the chart was successful.  Write out
                // the chart, surrounded by a DIV to control layout.
                out.write("<div class='evChartItem' style='width:" + width + "px; height:" + height + "px'>");
                out.write(buf.toString());
                out.write("</div>");
            } else {
                i.remove();
            }
            out.write(" ");
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Unexpected error when displaying " + "EV snippet widget with id '" + chart.snip.getId() + "'", e);
        }
    }
    return chartList;
}
Also used : DashboardContext(net.sourceforge.processdash.DashboardContext) SnippetWidget(net.sourceforge.processdash.ui.snippet.SnippetWidget) HtmlEvChart(net.sourceforge.processdash.ev.ui.chart.HtmlEvChart) HelpAwareEvChart(net.sourceforge.processdash.ev.ui.chart.HelpAwareEvChart) EVTaskListRollup(net.sourceforge.processdash.ev.EVTaskListRollup) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException) IOException(java.io.IOException) StringWriter(java.io.StringWriter) Iterator(java.util.Iterator) CachedURLObject(net.sourceforge.processdash.net.cache.CachedURLObject) ChartItem(net.sourceforge.processdash.ev.ui.TaskScheduleChartUtil.ChartItem) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 4 with EVTaskListRollup

use of net.sourceforge.processdash.ev.EVTaskListRollup in project processdash by dtuma.

the class EVReport method customizeTaskTableWriter.

private static TableModel customizeTaskTableWriter(HTMLTableWriter writer, EVTaskList taskList, EVTaskFilter filter, EVReportSettings settings, boolean showTimingIcons) {
    TableModel table = taskList.getSimpleTableModel(filter);
    boolean hidePlan = settings.getBool(CUSTOMIZE_HIDE_PLAN_LINE);
    boolean hideReplan = settings.getBool(CUSTOMIZE_HIDE_REPLAN_LINE);
    boolean hideForecast = settings.getBool(CUSTOMIZE_HIDE_FORECAST_LINE);
    boolean hideNames = settings.getBool(CUSTOMIZE_HIDE_NAMES);
    customizeTableWriter(writer, table, EVTaskList.toolTips);
    writer.setTableName("TASK");
    writer.setSkipColumn(EVTaskList.PLAN_CUM_TIME_COLUMN, true);
    writer.setSkipColumn(EVTaskList.PLAN_CUM_VALUE_COLUMN, true);
    writer.setSkipColumn(EVTaskList.NOTES_COLUMN, true);
    setupTaskTableRenderers(writer, showTimingIcons, settings.exportingToExcel(), hideNames, taskList.getNodeTypeSpecs());
    if (!(taskList instanceof EVTaskListRollup) || hideNames)
        writer.setSkipColumn(EVTaskList.ASSIGNED_TO_COLUMN, true);
    if (hidePlan)
        writer.setSkipColumn(EVTaskList.PLAN_DATE_COLUMN, true);
    if (hideReplan)
        writer.setSkipColumn(EVTaskList.REPLAN_DATE_COLUMN, true);
    if (hideForecast)
        writer.setSkipColumn(EVTaskList.FORECAST_DATE_COLUMN, true);
    return table;
}
Also used : EVTaskListRollup(net.sourceforge.processdash.ev.EVTaskListRollup) TreeTableModel(net.sourceforge.processdash.ui.lib.TreeTableModel) TableModel(javax.swing.table.TableModel)

Example 5 with EVTaskListRollup

use of net.sourceforge.processdash.ev.EVTaskListRollup in project processdash by dtuma.

the class EVTimeErrConfidenceInterval method getUniqueSchedules.

private static void getUniqueSchedules(Collection<EVTaskList> taskLists, Map<String, EVSchedule> results) {
    for (EVTaskList taskList : taskLists) {
        if (taskList instanceof EVTaskListRollup) {
            EVTaskListRollup rollup = (EVTaskListRollup) taskList;
            Collection<EVTaskList> subTaskLists = rollup.getSubSchedules();
            getUniqueSchedules(subTaskLists, results);
        } else {
            String key = taskList.getID();
            if (!StringUtils.hasValue(key))
                key = taskList.getTaskListName();
            results.put(key, taskList.getSchedule());
        }
    }
}
Also used : EVTaskListRollup(net.sourceforge.processdash.ev.EVTaskListRollup) EVTaskList(net.sourceforge.processdash.ev.EVTaskList)

Aggregations

EVTaskListRollup (net.sourceforge.processdash.ev.EVTaskListRollup)13 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)8 ArrayList (java.util.ArrayList)3 DefaultTaskLabeler (net.sourceforge.processdash.ev.DefaultTaskLabeler)3 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)3 IOException (java.io.IOException)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 TableModel (javax.swing.table.TableModel)2 SimpleData (net.sourceforge.processdash.data.SimpleData)2 EVDependencyCalculator (net.sourceforge.processdash.ev.EVDependencyCalculator)2 EVSchedule (net.sourceforge.processdash.ev.EVSchedule)2 EVTaskFilter (net.sourceforge.processdash.ev.EVTaskFilter)2 EVTaskListData (net.sourceforge.processdash.ev.EVTaskListData)2 EVTaskListGroupFilter (net.sourceforge.processdash.ev.EVTaskListGroupFilter)2 EVTaskListMerged (net.sourceforge.processdash.ev.EVTaskListMerged)2 UserFilter (net.sourceforge.processdash.team.group.UserFilter)2 StringWriter (java.io.StringWriter)1