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

How to resolve path of item in change

 I have a:

  1.  list of changes List<IChange>
  2. IWorkspaceConnection
  3. IConfiguration

I searching for a way to find the 'remote path' of the item in IChange. But the path relevant to the change.
From the 
I tried to use 'IConfiguration.fetchCompleteItem' applied on 'IChange.item()'

But i case item already deleted from the component, all I got is null.
In other cases I get the current path in the component, not the path in the change. For example, If the change was move/rename then the path in the change is different than the current exists one.

Thank
Boaz


0 votes



3 answers

Permanent link
Hi, I suggest you to use IChange.beforeState() and IChange.afterState() instead of item(). The first could be used in case of deletion and both should reflect move/rename changes.
And you can use configuration.determineAncestorsInHistory

0 votes

Comments

 Thank for the reply.


As i mentioned, I tried all the three item/before/after
Maybe I shouldn't use 'IConfiguration' ?

Thx
Boaz


Permanent link
Please see if

Getting your stuff - using the RTC SDK to zip a repository workspace helps.

0 votes

Comments

 Not sure you even bothered to read my question.

It is OK. I know every one is so busy.

I am not superman that knows all, and I can't tell you. I would have to do the programming myself, spending maybe a day or so to be able to give you a valid answer. So all I can do in a case like this is to point you to examples I know work.

I know this has likely been discussed here already. Please try https://www.google.com/search?q=path+item+changeset+site:jazz.net and look into some of the questions and answers as well.


Permanent link
Well, the code below will find the full remote path of IChange.beforeState() and  IChange.afterState()


And it works even in case item already deleted from the component.
Reading the documents, I didn't understand why 'determineAncestorsInHistory' does the trick.



  /**
 * @param itemOfState item with valid state like {@link IChange#beforeState()} or {@link IChange#afterState()}
* @return Full state IVersionable and path in repository. Null if not found.
*/
@Nullable
Pair<IVersionable, Path> getItemFullState(IVersionableManager versionableManager,
IConfiguration configuration,
IVersionableHandle itemOfState,
IProgressMonitor monitor) throws TeamRepositoryException {


IVersionable versionable;
try {
versionable = versionableManager.fetchCompleteState(itemOfState, monitor);
} catch (ItemNotFoundException e) {
return null;

}


if (versionable == null) {
return null;
}


List<IAncestorReport> list =
configuration.determineAncestorsInHistory(Collections.singletonList(itemOfState), getMonitor());

// more check need here list.size() == 1
IAncestorReport ancestorReport = list.get(0);

Path path = null;

for (Object o : ancestorReport.getNameItemPairs()) {

INameItemPair nameItemPair = (INameItemPair)o;

String name = nameItemPair.getName();

if (name != null) {
if (path == null) {
path = Paths.get(name);
} else {
path = path.resolve(name);
}
}
}

return new Pair<>(versionable, path);
}

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,949
× 51

Question asked: Feb 04 '16, 11:01 a.m.

Question was seen: 3,873 times

Last updated: Feb 05 '16, 4:09 a.m.

Confirmation Cancel Confirm