How to retrieve the project area of a java file?
Hi all!
I have implemented it with Jazz 1.x version. But in 2.0 version some of the interfaces have been changed, my former code doesn't work now. Here is my former code.
In RTC 2.0, there is no getOwner() method. So, my plugin couldn't find out the project area of a java file. Could anyone tell me how to modify the code to get the project area in RTC 2.0. |
11 answers
The owner of a component wasn't necessarily the workspace in any case in 1.0 (e.g. it could have been the stream, or some other workspace).
ISharingDescriptor has: public IContextHandle getConnectionHandle() the result of which can be cast down to IWorkspaceHandle. IBaselineHandle also extends IContextHandle, but we don't currently allow loading directly from a baseline or baseline set (aka snapshot). This still doesn't give you the project area though. Workspaces aren't necessarily tied to a particular project area -- they're owned by individuals, and may load components from various streams. Streams are typically scoped to a project or team area, though. A workspace may flow to/from multiple streams, though, possibly in different project areas. A workspace may also have no flow targets. It would help to know more about what you're trying to do. Regards, Nick Edgar RTC Build component lead |
The owner of a component wasn't necessarily the workspace in any case in 1.0 (e.g. it could have been the stream, or some other workspace). What i am trying to do is to relate a source code file to a work item, just like the Jazz check-in & deliver. First of all, I am trying to get the file's related project area, so I can create work item in this area. Can the IFile--IShareable--IWorkspace--Stream--IProjcetArea be a possible solution? Best regards! |
Yes, that's possible. But note that users may change their current flow target to some other stream than their main development stream (for example, someone in the release engineer role delivering changes to a weekly integration stream). Also, the current flow target may be another workspace, not a stream, or it may have no flow targets.
|
I have tried this way.
the getOwner() returns an IContributorHandle(not ITeamAreaHandle), so I still can't get the project area... |
Have you tried with IWorkspace.getProcessAreaScope()?
It gives you an IAuditableHandle which I think could be a IProjectAreaHandle or an IProcessAreaHandle. In this case you can fetch the item and than use IProcessArea->getProjectArea(). The only thing is that you have to debug on the IAuditableHandle to see what it could be. |
Yaoben, in your code snippet you're fetching the owner of the workspace, which will always be an IContributorHandle. You should instead look up the current flow target from the workspace's flow table, check that the target is a stream, and get the owner from it.
Try:
Regards, Nick Edgar RTC Build component lead |
It is really nice to see both of your replies. I have tried both ways you offered.
To Michele: I have debuged on the IAuditable object, unfortunately I find it is null. So there is no way to get access to the project area via it. So I wonder if there is anything wrong with my invoking. IWorkspace workspace = (IWorkspace) im.fetchCompleteItem(workspaceHandle, IItemManager.DEFAULT, null); Anyway, I really appreciate you offer. To Nick: I copy your code into my code, right after IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandle, null); But the getOwner() still returns an IContributorHandle(). I am confused... |
Hi Nick,
your solution works, but there is a little mistake in your code, it should be IAuditableHandle ownerHandle = targetConnection.getOwner(); So it didn't work at first! Thanks Nikc and Michele~~ |
Ah, sorry about the confusion. You're right, it should be targetConnection.getOwner().
|
We are trying to do a similar controll: we would check if the change-set was associated to a work-item of the same project area.
Our snippet code is:
ITeamRepository repo = ...
Such a method "IComponent#getOwner()" does not exist, but the information there is as an internal... How can we get the value?
Thanks in advance.
|
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.