It's all about the answers!

Ask a question

Get the owner and visibility of Component through API

Yung-Hsiang Chan (34913) | asked Nov 20 '14, 12:13 a.m.
edited Nov 20 '14, 12:16 a.m.
Hi, I want to get the owner and visibility of Component through API.

There is a api for setting the owner and visibility for Component like below.

workspaceManager.setComponentOwnerAndVisibility(IComponentHandle ch, IAuditableHandle ah, IReadScope pscope, monitor);

But there is no API for querying.

I've found there is a class ComponentOwner  and ComponentOwnerQueryModel in

I tried like below.

ComponentOwnerQueryModel componentOwnerQueryModel = ComponentOwnerQueryModel.ROOT;

// create a query for ComponentOwner
IItemQuery query = IItemQuery.FACTORY
// allocate space for the parameter
IItemHandleInputArg[] itemHandleArgs = new IItemHandleInputArg[] { query
.newItemHandleArg() };
// the query filter
IPredicate filter = ((ComponentOwnerQueryModel) componentOwnerQueryModel)

// 1 parameter required
IItemQueryPage queryPage = RTCService
new Object[] { iComponent },

if (queryPage.getResultSize() == 1) {
ComponentOwner componentOwner = (ComponentOwner) RTCService
(ComponentOwnerHandle) queryPage
IItemManager.DEFAULT, null);

But I got an error message: Remote queries are not allowed for the application-managed item type ""

how can i get this object?


Accepted answer

permanent link
SEC Servizi (97123760) | answered Nov 20 '14, 4:02 a.m.
You should use the repo service
IScmService scmService = ...
IRepositoryItemService itemService = ...
IComponentHandle componentH = ...
ComponentOwnerHandle componentOwnerH = scmService.getComponentOwnerRecord((ComponentHandle) componentH);
ComponentOwner componentOwner = (ComponentOwner) itemService.fetchItem(componentOwnerH, IRepositoryItemService.COMPLETE);
IAuditableHandle ownerH = componentOwner.getOwner();
Yung-Hsiang Chan selected this answer as the correct answer

One other answer

permanent link
Yung-Hsiang Chan (34913) | answered Nov 20 '14, 4:14 a.m.
edited Nov 20 '14, 4:15 a.m.
 I then found another way to do this.

List<IAuditableHandle> iAuditableHandles = RTCService.workspaceManager().findOwnersForComponents(components, null);
But I am not sure that the order of this list whether is equal to the list returned by getComponents().

Maybe the above solutions is better. 

SEC Servizi commented Nov 20 '14, 11:00 a.m.

According to, used as implementor for, the owners list will get the same order of the components list.

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.