Search in sources :

Example 1 with DefaultTaskLabeler

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

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

the class DataExtractionScaffold method getEVTaskLists.

private List<EVTaskList> getEVTaskLists(boolean includePersonal, boolean includeRollups) {
    String[] taskListNames = EVTaskList.findTaskLists(data);
    List<EVTaskList> result = new ArrayList<EVTaskList>(taskListNames.length);
    TaskLabeler taskLabeler = null;
    for (String taskListName : taskListNames) {
        EVTaskList tl = EVTaskList.openExisting(taskListName, data, hierarchy, null, false);
        if (tl instanceof EVTaskListData && !includePersonal)
            continue;
        if (tl instanceof EVTaskListRollup && !includeRollups)
            continue;
        tl.recalc();
        tl = new EVTaskListMerged(tl, false, true, null);
        if (taskLabeler == null) {
            taskLabeler = new DefaultTaskLabeler(this);
            taskLabeler.recalculate();
        }
        tl.setTaskLabeler(taskLabeler);
        result.add(tl);
    }
    return result;
}
Also used : DefaultTaskLabeler(net.sourceforge.processdash.ev.DefaultTaskLabeler) TaskLabeler(net.sourceforge.processdash.ev.TaskLabeler) EVTaskListData(net.sourceforge.processdash.ev.EVTaskListData) EVTaskListRollup(net.sourceforge.processdash.ev.EVTaskListRollup) ArrayList(java.util.ArrayList) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) EVTaskListMerged(net.sourceforge.processdash.ev.EVTaskListMerged) DefaultTaskLabeler(net.sourceforge.processdash.ev.DefaultTaskLabeler)

Example 3 with DefaultTaskLabeler

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

the class EVReport method getEVModel.

private void getEVModel() throws TinyCGIException {
    taskListName = settings.getTaskListName();
    if (taskListName == null)
        throw new TinyCGIException(400, "schedule name missing");
    else if (FAKE_MODEL_NAME.equals(taskListName)) {
        evModel = null;
        return;
    }
    long now = System.currentTimeMillis();
    synchronized (EVReport.class) {
        if (drawingChart && (now - lastRecalcTime < MAX_DELAY) && taskListName.equals(lastTaskListName)) {
            evModel = lastEVModel.get();
            if (evModel != null)
                return;
        }
    }
    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 rollup = (EVTaskListRollup) evModel;
        rollup.applyTaskListFilter(new EVTaskListGroupFilter(f));
        String permID = (parameters.containsKey(CHARTS_PARAM) ? EVPermissions.PERSONAL_CHARTS : EVPermissions.PERSONAL_REPORT);
        settings.checkPersonalDataPermission(rollup, permID);
    }
    EVDependencyCalculator depCalc = new EVDependencyCalculator(getDataRepository(), getPSPProperties(), getObjectCache());
    evModel.setDependencyCalculator(depCalc);
    evModel.setTaskLabeler(new DefaultTaskLabeler(getDashboardContext()));
    if (settings.getBool(CUSTOMIZE_HIDE_BASELINE))
        evModel.disableBaselineData();
    evModel.recalc();
    synchronized (EVReport.class) {
        lastTaskListName = taskListName;
        lastRecalcTime = now;
        lastEVModel = new WeakReference<EVTaskList>(evModel);
    }
}
Also used : EVTaskListGroupFilter(net.sourceforge.processdash.ev.EVTaskListGroupFilter) EVDependencyCalculator(net.sourceforge.processdash.ev.EVDependencyCalculator) EVTaskListRollup(net.sourceforge.processdash.ev.EVTaskListRollup) UserFilter(net.sourceforge.processdash.team.group.UserFilter) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) DefaultTaskLabeler(net.sourceforge.processdash.ev.DefaultTaskLabeler) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Aggregations

DefaultTaskLabeler (net.sourceforge.processdash.ev.DefaultTaskLabeler)3 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)3 EVTaskListRollup (net.sourceforge.processdash.ev.EVTaskListRollup)3 EVDependencyCalculator (net.sourceforge.processdash.ev.EVDependencyCalculator)2 EVTaskListGroupFilter (net.sourceforge.processdash.ev.EVTaskListGroupFilter)2 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)2 UserFilter (net.sourceforge.processdash.team.group.UserFilter)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 EVSchedule (net.sourceforge.processdash.ev.EVSchedule)1 EVTaskFilter (net.sourceforge.processdash.ev.EVTaskFilter)1 EVTaskListData (net.sourceforge.processdash.ev.EVTaskListData)1 EVTaskListFilter (net.sourceforge.processdash.ev.EVTaskListFilter)1 EVTaskListMerged (net.sourceforge.processdash.ev.EVTaskListMerged)1 TaskLabeler (net.sourceforge.processdash.ev.TaskLabeler)1