How to get the current TimePoint in an wiki?

Description
gcueppers
Posts: 16
Joined: Tue Feb 26, 2008 2:24 pm
Location: Aachen, Germany
Contact:

How to get the current TimePoint in an wiki?

Postby gcueppers » Wed Jan 15, 2014 12:21 pm

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.
kind regards,
Guido

hseifert
Posts: 21
Joined: Wed Apr 17, 2013 12:10 pm
Location: Böblingen, Baden-Württemberg, Germany
Contact:

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

Postby hseifert » Thu Apr 10, 2014 7:57 am

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
Kind regards.

Hagen

hseifert
Posts: 21
Joined: Wed Apr 17, 2013 12:10 pm
Location: Böblingen, Baden-Württemberg, Germany
Contact:

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

Postby hseifert » Fri Apr 11, 2014 7:22 am

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
Kind regards.

Hagen


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 7 guests