use of net.sourceforge.processdash.ev.EVTaskFilter 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.EVTaskFilter in project processdash by dtuma.
the class EVReport method writeMSProjXml.
/** Generate an XML document in Microsoft Project mspdi format.
*/
public void writeMSProjXml() throws IOException {
MSProjectXmlWriter writer = new MSProjectXmlWriter();
EVTaskFilter taskFilter = settings.getEffectiveFilter(evModel);
EVTaskListMerged mergedModel = new EVTaskListMerged(evModel, false, true, taskFilter);
writer.setTaskList(mergedModel);
String taskListID = evModel.getID();
String metadataPrefix = "/Task-Schedule-MS-Project/" + taskListID;
writer.setMetadata(getDataRepository().getSubcontext(metadataPrefix));
if (parameters.containsKey("dateStyle"))
writer.setDateStyle(getParameter("dateStyle"));
if (parameters.containsKey("showSaveAs"))
writeContentDispositionHeader(".xml");
outStream.write("Content-type: application/xml\r\n\r\n".getBytes(HTTPUtils.DEFAULT_CHARSET));
writer.write(outStream);
outStream.flush();
}
use of net.sourceforge.processdash.ev.EVTaskFilter in project processdash by dtuma.
the class EVReport method writeHTML.
/** Generate a page of HTML displaying the Task and Schedule templates,
* and including img tags referencing charts.
*/
public void writeHTML() throws IOException {
isSnippet = (env.containsKey(SnippetEnvironment.SNIPPET_ID));
String namespace = (isSnippet ? "$$$_" : "");
String taskListDisplayName = EVTaskList.cleanupName(taskListName);
String taskListHTML = HTMLUtils.escapeEntities(taskListDisplayName);
String title = resources.format("Report.Title_FMT", taskListHTML);
EVTaskFilter taskFilter = settings.getEffectiveFilter(evModel);
EVSchedule s = getEvSchedule(taskFilter);
EVTaskDataWriter taskDataWriter = getEffectiveTaskDataWriter();
StringBuffer header = new StringBuffer(HEADER_HTML);
StringUtils.findAndReplace(header, TITLE_VAR, title);
if (taskFilter != null && isSnippet == false)
header.append(FILTER_HEADER_HTML);
out.print(header);
out.print(taskDataWriter.getHeaderItems());
out.print("</head><body>");
out.print(isSnippet ? "<h2>" : "<h1>");
out.print(title);
if (!exportingToExcel()) {
interpOutLink(SHOW_WEEK_LINK, EVReportSettings.PURPOSE_WEEK);
interpOutLink(SHOW_MONTH_LINK, EVReportSettings.PURPOSE_WEEK);
printAlternateViewLinks();
interpOutLink(SHOW_CHARTS_LINK, EVReportSettings.PURPOSE_OTHER);
}
printCustomizationLink();
out.print(isSnippet ? "</h2>" : "</h1>");
if (!isSnippet)
printFilterInfo(out, taskFilter, settings, isExporting(), exportingToExcel());
if (!exportingToExcel()) {
writeImageHtml(taskFilter != null);
out.print("<div style='clear:both'></div>");
writeCharts(evModel, s, taskFilter, settings.getBool(CUSTOMIZE_HIDE_NAMES), 350, 300, ChartListPurpose.ReportMain, null, null);
out.print("<div style='clear:both'> </div>");
out.print(HTMLTreeTableWriter.TREE_ICON_HEADER);
}
EVMetrics m = s.getMetrics();
printScheduleErrors(out, m.getErrors());
boolean hidePlan = settings.getBool(CUSTOMIZE_HIDE_PLAN_LINE);
boolean hideReplan = settings.getBool(CUSTOMIZE_HIDE_REPLAN_LINE);
boolean hideForecast = settings.getBool(CUSTOMIZE_HIDE_FORECAST_LINE);
out.print("<table name='STATS'>");
for (int i = 0; i < m.getRowCount(); i++) writeMetric(m, i, hidePlan, hideReplan, hideForecast);
out.print("</table>");
out.print("<h2><a name='" + namespace + "tasks'></a>" + getResource("TaskList.Title"));
printTaskStyleLinks(taskDataWriter, namespace);
out.print("</h2>\n");
taskDataWriter.write(out, evModel, taskFilter, settings, namespace);
out.print("<h2>" + getResource("Schedule.Title") + "</h2>\n");
writeScheduleTable(s);
if (isExporting() && !isSnippet)
writeExportFooter(out);
out.print("<p class='doNotPrint'>");
if (!isSnippet && !exportingToExcel())
interpOutLink(EXPORT_TEXT_LINK);
if (!parameters.containsKey("EXPORT")) {
if (taskFilter == null) {
interpOutLink(EXPORT_CHARTS_LINK);
interpOutLink(EXPORT_MSPROJ_LINK);
}
if (!isSnippet) {
String link = EXPORT_ARCHIVE_LINK;
String filenamePat = HTMLUtils.urlEncode(resources.getString("Report.Archive_Filename"));
link = StringUtils.findAndReplace(link, "FILENAME", filenamePat);
interpOutLink(link);
}
}
out.print("</p>");
out.print("</body></html>");
}
use of net.sourceforge.processdash.ev.EVTaskFilter in project processdash by dtuma.
the class EVReportSettings method getEffectiveFilter.
/** Build a task filter object that should be used to display the report.
*/
public EVTaskFilter getEffectiveFilter(EVTaskList evModel) {
EVTaskFilter result = null;
isRollup = evModel instanceof EVTaskListRollup;
// first, look up any applicable label filter
String labelFilter = null;
if (parameters.containsKey(LABEL_FILTER_PARAM))
labelFilter = getParameter(LABEL_FILTER_PARAM);
else if (usingCustomizationSettings) {
SimpleData val = getValue("settings//" + LABEL_FILTER_PARAM);
labelFilter = (val == null ? null : val.format());
}
// if we found a label filter, apply it.
if (StringUtils.hasValue(labelFilter)) {
try {
result = new EVLabelFilter(evModel, labelFilter, data);
} catch (Exception e) {
}
}
// next, look up any applicable path filter
String pathFilter = null;
if (parameters.containsKey(PATH_FILTER_PARAM))
pathFilter = getParameter(PATH_FILTER_PARAM);
else if (usingCustomizationSettings) {
SimpleData val = getValue("settings//" + PATH_FILTER_PARAM);
pathFilter = (val == null ? null : val.format());
}
// if we found a path filter, apply it
if (StringUtils.hasValue(pathFilter)) {
EVHierarchicalFilter hf = EVHierarchicalFilter.getFilter(evModel, pathFilter);
if (hf != null)
result = hf.appendFilter(result);
} else {
// next, look for a merged path filter
String mergedPathFilter = null;
if (parameters.containsKey(MERGED_PATH_FILTER_PARAM))
mergedPathFilter = getParameter(MERGED_PATH_FILTER_PARAM);
else if (usingCustomizationSettings) {
SimpleData val = getValue("settings//" + MERGED_PATH_FILTER_PARAM);
mergedPathFilter = (val == null ? null : val.format());
}
// if we found a merged path filter, apply it
if (StringUtils.hasValue(mergedPathFilter)) {
EVHierarchicalFilter hf = EVHierarchicalFilter.getFilterForMerged(evModel, mergedPathFilter);
if (hf != null)
result = hf.appendFilter(result);
}
}
if (result != null)
evModel.disableBaselineData();
return result;
}
use of net.sourceforge.processdash.ev.EVTaskFilter in project processdash by dtuma.
the class TaskScheduleChart method evRecalculated.
public void evRecalculated(EventObject e) {
if (schedule instanceof EVScheduleFiltered) {
EVScheduleFiltered filtSched = (EVScheduleFiltered) schedule;
EVTaskFilter filter = filtSched.getFilter();
String valid = filter.getAttribute(EVTaskFilter.IS_INVALID);
if (valid == null)
filtSched.recalculate();
else
dispose();
}
}
Aggregations