It's all about the answers!

Ask a question

how to use getCreator()??


Paul Jansen (2111) | asked Jan 10 '12, 4:43 a.m.
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?

8 answers



permanent link
Michele Pegoraro (1.8k12114101) | answered Jan 24 '12, 7:44 a.m.
.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.

permanent link
sam detweiler (12.5k6184201) | answered Jan 11 '12, 9:27 a.m.
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).

permanent link
sam detweiler (12.5k6184201) | answered Jan 10 '12, 8:27 a.m.
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

permanent link
Paul Jansen (2111) | answered Jan 10 '12, 9:46 p.m.
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..

permanent link
Paul Jansen (2111) | answered Jan 12 '12, 1:17 a.m.
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.

permanent link
sam detweiler (12.5k6184201) | answered Jan 12 '12, 9:26 a.m.
see com.ibm.team.workitem.common.IAuditableCommon.resolveAuditable(IAuditableHandle, ItemProfile<T>, IProgressMonitor)

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

permanent link
Paul Jansen (2111) | answered Jan 15 '12, 7:08 a.m.
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??

permanent link
Paul Jansen (2111) | answered Jan 20 '12, 1:46 a.m.
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?

Your answer


Register or to post your answer.