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

how to use getCreator()??

Hi all,

I need ur help, how to get creator by RTC API?


if (data instanceof ISaveParameter) {
ISaveParameter param = (ISaveParameter) data;
IAuditable auditable = param.getNewState();
if (auditable instanceof IWorkItem) {
IWorkItem sourceworkItem = (IWorkItem) auditable;
System.out.println("CREATOR:"+ sourceworkItem.getCreator());
}
}


The output is..

CREATOR:com.ibm.team.repository.common.model.impl.ContributorHandleImpl@5cef5cef
(stateId: , itemId: , origin: <unset>, immutable: <unset>)

any idea?

0 votes



8 answers

Permanent link
.getCreator returns an IAuditableHandle. It could be an instance of IContributorHandle, ITeamAreaHandle or IProjectAreaHandle (it depends on what you're looking for).

Once you have it, you can use IRepositoryItemService.fetchItem in order to get the Item from an Handle. When you got the Item (i suppose you want an IContributor) than you can get the property you need (name, email etc...).

Best Regards,
Michele.

2 votes


Permanent link
in one of my server plugins (which extends AbstractService) I use



IContributor rtcUser = (IContributor) itemService().fetchItem(
rtcUserHandle, IRepositoryItemService.COMPLETE);


private static IRepositoryItemService itemService=null;
private IRepositoryItemService itemService()
{
if(itemService==null)
itemService=getService(IRepositoryItemService.class);
return itemService;
}



basically you need to 'load' the object from the repository, using its handle. note that in my case I am loading the COMPLETE object.
(thanks for making me took at this, I only need a small portion of the data and could help the system out by reducing the size of the object load, as it will be discarded almost immediately).

1 vote


Permanent link
RTC stores links to other objects as 'handles' which is a persistant linkage to the object in question. as it will be loaded into memory in many different locations over its lifetime by many parts of the system.

So, People (users) are 'contrubutors', and reference to a user is a ContributorHandle.

you must use some function to convert the handle to an object.

Sam

0 votes


Permanent link
RTC stores links to other objects as 'handles' which is a persistant linkage to the object in question. as it will be loaded into memory in many different locations over its lifetime by many parts of the system.

So, People are 'contrubutors', and reference to a user is a ContributorHandle.

you must use some function to convert the handle to an object.

Sam


Hi Sam,
How to convert the handle to an object? sample code please..

0 votes


Permanent link
This is my code:

public class HelloWorldProhibitSave implements
IOperationAdvisor {
...
public void run(AdvisableOperation operation,
IProcessConfigurationElement advisorConfiguration,
IAdvisorInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {

Object data = operation.getOperationData();

if (data instanceof ISaveParameter) {
ISaveParameter param = (ISaveParameter) data;
IAuditable auditable = param.getNewState();
if (auditable instanceof IWorkItem) {
IWorkItem sourceworkItem = (IWorkItem) auditable;


System.out.println("CREATOR:"
+ sourceworkItem.getCreator().toString());
System.out.println("This work item is of type: "
+ sourceworkItem.getWorkItemType());


}
}
}
...

how to implement your code?? because my code not extends AbstractService. Thanks.

0 votes


Permanent link
see com.ibm.team.workitem.common.IAuditableCommon.resolveAuditable(IAuditableHandle, ItemProfile<T>, IProgressMonitor)

you have to look thru the classes to find this stuff.

0 votes


Permanent link
see com.ibm.team.workitem.common.IAuditableCommon.resolveAuditable(IAuditableHandle, ItemProfile<T>, IProgressMonitor)

you have to look thru the classes to find this stuff.


still confuse.. can you explain to me how to get the stuff??

0 votes


Permanent link
see com.ibm.team.workitem.common.IAuditableCommon.resolveAuditable(IAuditableHandle, ItemProfile<T>, IProgressMonitor)

you have to look thru the classes to find this stuff.


still confuse.. can you explain to me how to get the stuff??

anyone can help me?

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,937

Question asked: Jan 10 '12, 4:43 a.m.

Question was seen: 8,545 times

Last updated: Jan 10 '12, 4:43 a.m.

Confirmation Cancel Confirm