It's all about the answers!

Ask a question

Get full path name for IVersionableHandle


Jeff Care (1.0k3733) | asked Mar 14 '11, 4:50 p.m.
edited Oct 12 '17, 1:24 p.m. by David Lafreniere (4.8k7)

Assume I have an IVersionableHandle <b:ab332a6966> and </b:ab332a6966> its associated IConfiguration context: what's when best way to determine the path name of the referenced IVersionable?

I'm currently walking the tree with getParent (see code below) but I'm wondering if there's a better way.

  private String getCanonicalName &#40;IVersionableHandle versionable, final IConfiguration context&#41; throws TeamRepositoryException &#123;


final Deque&lt;String&gt; path = new LinkedList&lt;String&gt; &#40;&#41;;

while &#40;versionable != null&#41; &#123;

final IVersionable currentItem = context.fetchCompleteItem &#40;versionable, getMonitor &#40;&#41;&#41;;

final String name = currentItem.getName &#40;&#41;;
if &#40;name.length &#40;&#41; &gt; 0&#41;
path.push &#40;name&#41;;

versionable = currentItem.getParent &#40;&#41;;
&#125;

final StringBuilder result = new StringBuilder &#40;&#41;;
for &#40;final Iterator&lt;String&gt; segment = path.iterator &#40;&#41;; segment.hasNext &#40;&#41;;&#41; &#123;

result.append &#40;segment.next &#40;&#41;&#41;;

if &#40;segment.hasNext &#40;&#41;&#41;
result.append &#40;'/'&#41;;
&#125;

return result.toString &#40;&#41;;
&#125;

Accepted answer


permanent link
Michael Valenta (3.7k3) | answered Mar 15 '11, 11:22 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
I think the IConfiguration#locateAncestors method will give you the path of the versionable.
Jeff Care selected this answer as the correct answer

Comments
Jeff Care commented Aug 17 '12, 10:10 a.m.

Awesome, that worked, thanks.

In our present SCM system "ancestor" has an entirely different meaning so I didn't even look at that method; that's what I get for viewing RTC through the lens of what we're already used to...

2 other answers



permanent link
Andrea Gabrielli (1111) | answered Apr 04 '11, 10:59 a.m.
Hi,
I'm trying to do the same on a postop delivery server-side plugin.
How can I obtain IConfiguration?

Thanks,
Andrea
_________________
Andrea Gabrielli

Nexen
Business Consultant


I think the IConfiguration#locateAncestors method will give you the path of the versionable.


Awesome, that worked, thanks.

In our present SCM system &quot;ancestor&quot; has an entirely different meaning so I didn't even look at that method; that's what I get for viewing RTC through the lens of what we're already used to...

permanent link
Andrea Gabrielli (1111) | answered Apr 05 '11, 7:04 a.m.
Hi,
the example

https://jazz.net/wiki/pub/Main/RTCSDK20_ProcessPreConditionExample/advisor-example.zip

resolved my problem.

Andrea
_________________
Andrea Gabrielli

Nexen
Business Consultant

Hi,
I'm trying to do the same on a postop delivery server-side plugin.
How can I obtain IConfiguration?

Thanks,
Andrea
_________________
Andrea Gabrielli

Nexen
Business Consultant


I think the IConfiguration#locateAncestors method will give you the path of the versionable.


Awesome, that worked, thanks.

In our present SCM system &quot;ancestor&quot; has an entirely different meaning so I didn't even look at that method; that's what I get for viewing RTC through the lens of what we're already used to...

Your answer


Register or to post your answer.