Page 1 of 1

How to get the current TimePoint in an wiki?

Posted: Wed Jan 15, 2014 12:21 pm
by gcueppers
Hello,

the ITimePointsManager offers functions to get the "nearest TimePoint", "open TimePoints" and "closed TimePoints". Nevertheless I want to identify the "current TimePoint".
For Examples:

Code: Select all

#set($projectId = $doc.getProject($doc.space))
#set($project = $trackerService.getTrackerProject("$projectId"))
#set ($allTPs = $trackerService.timePointsManager.getTimePoints($project.getContextId(),null,false))
#set ($openTPs = $trackerService.timePointsManager.getNotClosedTimePoints($project.getContextId(),null,false))
#set ($closedTPs = $trackerService.timePointsManager.getClosedTimePoints($project.getContextId(),null,false))
#set ($nearestTP = $trackerService.timePointsManager.getNearestTimePoint($project.getContextId(),null,false))


When using the {parameters} macros I get the hint for the actual release in the dropdown box:

Code: Select all

    {parameter:TPparam|type=timePoint|value=@current}

    {parameter-form}
    selected Release: {parameter-editor:TPparam}
    {parameter-form-submit}
    {parameter-form}


Unfortunately their is no function for it to be used in wiki pages ? How to handle this?

Thanks in advance.

Re: How to get the current TimePoint in an wiki?

Posted: Thu Apr 10, 2014 7:57 am
by hseifert
Hello Guido.

The shortcut @current doesn't work for time points. The reason is easy. First, a time point isn't a time range, it's a point. The start date for time points in Polarion seems to be only a workaround for the live plan.

Second, it's not clear what do you want, if you say @current. All time points with start date before and end date after today? Or all time points with end date in the future? Or only the time points with the nearest end date?

I think you have to write your own function to handle this. I can search our wiki pages for some code. We had the same problem...
Or you use the new "plan" feature from Polarion 2014.

Kind regards,
Hagen

Re: How to get the current TimePoint in an wiki?

Posted: Fri Apr 11, 2014 7:22 am
by hseifert
Hello Guido.

I found the wiki page code. Please note the following things:

1. We are using Time Points as duration (eg. sprint) or timepoint (eg. general availability of a Release)
2. All our sprint time points have the string "Sprint" in their names
3. In the second part we count all possible sprints. We show an error message if we got more then one.
4. This code has a little weakness: If the method "getNearestTimePoint" returns a time point, we are not checking if there are more current "active" time points.

Code: Select all

## GETTING HELPER AND SETTING CONSTANTS
#set($trackerProjectId = $doc.getProject($doc.space))
#set($trackerProject = $trackerService.getTrackerProject("$trackerProjectId"))
#set($contextId = $trackerProject.getContextId())
#set($timePointsManager = $trackerService.getTimePointsManager())

## GETTING THE CURRENT SPRINT
## First we try if the nearest time point is a sprint, if so, we have the sprint
#set($sprintCount = 0)
#set($missingStartDate = false)

#set($sprint = $timePointsManager.getNearestTimePoint($contextId, false))
#if($sprint.name.indexOf("Sprint") > -1)
   #set($sprintCount = 1)
#end

## Ok, we have no luck, now we must try to find one by hand
#if($sprintCount == 0)
   #set($timePoints = $timepointsManager.getNotClosedTimePoints($contextId, "time", false))
   #set($cal = $calendarTool.getCalendarInstance())

   #foreach($timePoint in $timePoints)
      #set($tpStart = $calendarTool.getCalendar($timePoint.getEarliestPlannedStart()))
      #set($tpEnd = $calendarTool.getCalendar($timePoint.time))
      #if($timePoint.name.indexOf("Sprint") > -1 && $cal.after($tpStart) && $cal.before($tpEnd))
         #set($sprintCount = $sprintCount + 1)
         #set($sprint = $timePoint)
      #end
   #end
#end