Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Get full path name for IVersionableHandle

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;

0 votes


Accepted answer

Permanent link
I think the IConfiguration#locateAncestors method will give you the path of the versionable.
Jeff Care selected this answer as the correct answer

1 vote

Comments

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

0 votes


Permanent link
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...

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,940
× 169

Question asked: Mar 14 '11, 4:50 p.m.

Question was seen: 7,929 times

Last updated: Oct 12 '17, 1:24 p.m.

Confirmation Cancel Confirm