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);
}
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");
}
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;
}
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;
}
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());
}
}
}
Aggregations