It's all about the answers!

Ask a question

item from handle,,,again, and still difficult


sam detweiler (12.5k6195201) | asked Nov 07 '11, 8:23 a.m.
I am working on a server side OperationAdvisor, and need to get the state of the workitem at the far end of a link.

I've got the IWorkItemHandle.

this brings up a constant problem.. how do you get from handle to object?

I've found samples thru the forums, but in every case some data item is missing from the context I'm in, with no clear way to find it.

why is this so hard? I've looked up and down the object and method tree, but don't find anything that seems reasonable.

----

Additionally, there is the abstraction between values and the UI representation of same..

like workitem state.. I don't see a clear way to get the label of the numeric value.. I don't care about the numeric.. makes no sense in a useful application..

you would think there would be a decent method from the item itself back thru whatever to get the label. I don't KNOW the workflow process this workitem is in, and don't CARE.. I just want to determine if this workitem new state is transitioning to 'Resolve'..

all ideas welcomed.. cause I'm completely lost.. about 10 hours of digging thru objects and methods hasn't produced a single usable option.
I NEED this done today..

            Identifier<IState> is = workItem.getState2();

// TODO: how to get WorkflowInfo from where i am
// or something else that make this logical.
//IWorkflowInfo x =null;
//x.getStateName(is);
System.out.println("the workitem state is "+ is.getStringIdentifier());
if(is.getStringIdentifier().equalsIgnoreCase("3"))


Sam

4 answers



permanent link
sam detweiler (12.5k6195201) | answered Nov 07 '11, 11:34 a.m.
anyone?

Sam

permanent link
David Murray (11612) | answered Nov 07 '11, 1:13 p.m.
JAZZ DEVELOPER
Hi Sam,

I'm a developer who's new-ish to the Jazz Foundation Process team, so this isn't quite my area of expertise. Regarding your first question, about getting an object from an IWorkItemHandle, you might find the following page useful:

https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation

In the 'Plain-Java Client' section is a complete sample that gets an IWorkItem from an IWorkItemHandle:

IAuditableClient auditableClient= (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);
...
IWorkItem workItem= auditableClient.resolveAuditable(handle, IWorkItem.FULL_PROFILE, monitor);

The second part of your post is specific to the RTC Work Items component. I've sent an email to alert them to this post if they haven't seen it already.

Take care.

permanent link
sam detweiler (12.5k6195201) | answered Nov 07 '11, 1:47 p.m.
thanks..

two things..

1. I believe this code, installed on the server, is running in server context, so a clientlibrary seems the wrong approach..

2. I don't have a repository reference.. this is one of the places where if I NEED that, the reference should be supplied as part of the execution context I am in, not ME having to go FIND the right approach to get the context..

sorry, my OO background is railing against some of the hard to follow model here.

also, I am not running in a workitem client.. I am in an OperationAdvisor precondition 'exit' running in the server.

I have a workitem client in another solution, my development of that also suffered from this same abstraction problem.

this really isn't a lot of code, and shouldn't be this hard..
this is our local implementation of enhancement
https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/182769

to support blocking for Depends On links, which isn't supported today

so,
when THIS workitem is transitioning to Resolve(d) state, I need to check for closure of the depended on links.
so I need to find the depends on links (got that)
then I need to look at the status of the workitem on the other end of the link.

stuck at the ********


public class WorkItemFailAdvisor implements IOperationAdvisor{

public void run(AdvisableOperation operation, IProcessConfigurationElement advisorConfiguration, IAdvisorInfoCollector collector, IProgressMonitor monitor) throws TeamRepositoryException {
System.out.println("in operation advisor");
Object data= operation.getOperationData();
if (data instanceof ISaveParameter) {
IAuditable auditable = ((ISaveParameter) data).getNewState();
if (auditable instanceof IWorkItem)
{
IWorkItem workItem = (IWorkItem) auditable;
Identifier<IState> is = workItem.getState2();
//IWorkflowInfo x =null;
//x.getStateName(is);
System.out.println("the workitem state is "+ is.getStringIdentifier());
if(is.getStringIdentifier().equalsIgnoreCase("3"))
{
IWorkItemReferences iwr = ((ISaveParameter) data).getNewReferences();
List<IEndPointDescriptor> epdl = iwr.getTypes();
for(int i=0;i<epdl.size();i++)
{
ILinkType lt = epdl.get(i).getLinkType();
System.out.println("link type = "+ lt.getLinkTypeId()+ " name="+epdl.get(i).getDisplayName());
if(lt.getLinkTypeId().endsWith("blocksworkitem"))
{
System.out.println(" this is a blocking link type");
if(epdl.get(i).getDisplayName().equalsIgnoreCase("Depends on"))
{
System.out.println(" this is a depends on link type");
if(iwr.hasReferences(epdl.get(i)))
{
System.out.println("endpoint has references");
List<IReference> wir = iwr.getReferences(epdl.get(i));
for(int j=0;j<wir.size();j++)
{
System.out.println("looping thru references");
if(wir.get(j).isItemReference())
{
IWorkItemHandle rh = (IWorkItemHandle)wir.get(j).resolve();
********* IItem ff = rh.getFullState();
//IWorkItemServer itemServer= getService(IWorkItemServer.class);
//IItem item = itemServer.findWorkItemById(, IWorkItem.FULL_PROFILE, null);
//IWorkItem itemCopy= (IWorkItem)item.getWorkingCopy();
//IAuditable auditablewi = (IAuditable) repo.itemManager().fetchCompleteItem(rh, IItemManager.DEFAULT, monitor);

//if (ff instanceof IWorkItem)
//{
IWorkItem r = (IWorkItem) ff;
String summary = workItem.getHTMLSummary().getPlainText();
System.out.println("Work Item Name: " + summary);

//IWorkItem r = (IWorkItem)rh.getFullState();
// TODO: we need to find state of the far endpoint
// and if not closed, then error this one
System.out.println("the target workitem state is "+r.getState2().getStringIdentifier());
if(r.getState2().getStringIdentifier()!="3")
{
IAdvisorInfo info = collector.createProblemInfo("Dependency not resolved", "The Dependent Workitem "+ r.getId()+ " is not closed", "error");
collector.addInfo(info);
}
//}
}
}
}


as an example of the complexity I/we face, the verb and Noun names are obtuse and mixed up all over the place,
IAuditable auditable = ((ISaveParameter) data).getNewState();

why should I expect a 'State' to turn into an complete object?
and when should I expect it to be a discrete value for the same Noun and verb?
Identifier<IState> is = workItem.getState2();

permanent link
sam detweiler (12.5k6195201) | answered Nov 08 '11, 11:17 a.m.
Ok, I got it..

the data passed to the OperationAdvisor, during a save operation (ISaveParameter)

has a two object removed class IAuditableCommon

private static String ResolvedState = "resolved";
IAuditableCommon iac = ((ISaveParameter) data).getSaveOperationParameter().getAuditableCommon();

WorkflowManager wfm = new WorkflowManager(iac);


which can be used to locate the other classes required.

or get (resolveAuditable) the object from the handle retrieved (resolve) from the link object reference (wir)

IWorkItem r = iac.resolveAuditable((IWorkItemHandle)wir.get(j).resolve(),IWorkItem.FULL_PROFILE, null);
IWorkflowInfo y =wfm.getWorkflowInfo(r, null);
if(y.getStateName(r.getState2()).equalsIgnoreCase(ResolvedState))

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.