It's all about the answers!

Ask a question

how to get all the IResource by current login user


Jingwen Ou (5610) | asked Aug 03 '08, 5:27 p.m.
hi,

Question 1: I would like to get all the IResource last modified by current login user?

I know how to get the author of a certain IResource by adapting to it: SCMPlatform.getWorkspaceManager(repo).versionableManager
().fetchCompleteState(shareable.getRemote(), monitor).getModifiedBy();

But I am not sure how to get the other way around (all IResource last modified by current login user).

Question 2: are there any listeners that I can use to keep track of the behavior of loading code from the server, e.g. I get notified every time the user check in new code or apply a patch from the work item. Please specify how.

Thanks for any info,
Owen

6 answers



permanent link
Jingwen Ou (5610) | answered Aug 06 '08, 11:15 p.m.
You would have to get a list of all shareable.getRemote() currently
loaded per repo, and then fetchCompleteStates() on them.


fetchCompleteStates() only returns a list of states (IVersionable) which I cannot get any local information from them, e.g. the local IPath of a IVersionalble.

To put it simple, the procedure is: 1. a list of IShareable -> 2. fetchCompleteStates() -> 3. a list of IVersionalble -> 4. a list of IResource by current login user.

Right now I can filter a list of IVersionable by current login user (step 3). But I can't get any local info such as IPath from it. Does anyone know get the IPath out of a IVersionable.

I also tried to adapt IVersionable back to IShareable/IResource but failed.

permanent link
Jingwen Ou (5610) | answered Aug 05 '08, 1:55 p.m.

No, rather you would gather a list of all IResources, then figure out who
was the last user that modified them and then keep only those that were
modified by the user returned in repo.loggedInContributor().


Do you know how to get all the IResources that are shared in the Jazz repository? I mean how to get a list of IResources that have Jazz properties. Are there any APIs I can use?

permanent link
Dmitry Karasik (1.8k11) | answered Aug 05 '08, 10:33 a.m.
JAZZ DEVELOPER
On Tue, 05 Aug 2008 17:57:57 +0000, jingweno wrote:


Do you know how to get all the IResource that are shared in the Jazz
repository? Are there any APIs I can use?

final List<IResource> sharedResources = new ArrayList<IResource>();
ResourcesPlugin.getWorkspace().getRoot().accept(new IResourceVisitor() {
public boolean visit(IResource resource) throws CoreException {
IShareable s = (IShareable)resource.getAdapter(IShareable.class);
if (s != null && s.getRemote() != null) {
sharedResources.add(resource);
}
return true;
}
});

- Dmitry

permanent link
Dmitry Karasik (1.8k11) | answered Aug 05 '08, 4:08 a.m.
JAZZ DEVELOPER
On Tue, 05 Aug 2008 01:57:52 +0000, jingweno wrote:

I expect
the procedure would be: getting current login user -> asking the server
for results by criteria -> adapting the results back to IResource.

No, rather you would gather a list of all IResources, then figure out who
was the last user that modified them and then keep only those that were
modified by the user returned in repo.loggedInContributor().

- Dmitry

permanent link
Jingwen Ou (5610) | answered Aug 04 '08, 9:56 p.m.
On Sun, 03 Aug 2008 21:27:55 +0000, jingweno wrote:

Question 1: I would like to get all the IResource last modified by
current login user?

I know how to get the author of a certain IResource:
SCMPlatform.getWorkspaceManager(repo).versionableManager
().fetchCompleteState(shareable.getRemote(), monitor).getModifiedBy();

You would have to get a list of all shareable.getRemote() currently
loaded per repo, and then fetchCompleteStates() on them.

could you be more specific by giving me a code snippet ? I am looking for a list of IResource last modified by current login user. I expect the procedure would be: getting current login user -> asking the server for results by criteria -> adapting the results back to IResource.

I am not familiar with the APIs and not sure whether its possible the results can be adapted back to IResource. And I don't how to get a list of all shareable.getRemote() either.

Thanks for any hints,
Owen

permanent link
Dmitry Karasik (1.8k11) | answered Aug 03 '08, 7:43 p.m.
JAZZ DEVELOPER
On Sun, 03 Aug 2008 21:27:55 +0000, jingweno wrote:

Question 1: I would like to get all the IResource last modified by
current login user?

I know how to get the author of a certain IResource:
SCMPlatform.getWorkspaceManager(repo).versionableManager
().fetchCompleteState(shareable.getRemote(), monitor).getModifiedBy();

You would have to get a list of all shareable.getRemote() currently
loaded per repo, and then fetchCompleteStates() on them.


Question 2: are there any listeners that I can use to keep track of the
check in behavior, e.g. I get notified every time the user check in new
code or apply a patch from the work item.

On checkin the IWorkspaceConnection sends ICommitEvent.COMMIT. As for
apply patch, I am not sure, there might be events the ComponentSyncModel
sends.

- Dmitry

Your answer


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