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

Get the Attributes Value for a given WorkItem in Java Plain API

Hello, I have a simple question for you surely, but since I'm brand new I don't know how to do it.

How to get the value of any attribute of a WorkItem with Plain Java API?

I already have the workitem in my code with:

workItem = workItemClient.findWorkItemById(workItemNumber, IWorkItem.FULL_PROFILE, new SysoutProgressMonitor())

but now I want to show some of its attributes with its values and I don't know how to continue.

Thanks for the help.

0 votes


Accepted answer

Permanent link
see the second post here.. how to dump all the attributes via the plain java client api

https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes
Tiago Fernandez selected this answer as the correct answer

0 votes

Comments

Thanks for the reply, but as I mentioned at the begining, I am brand new and in that post there are plenty lines of code.

Could you specify a very simple example in a couple a lines on how to get the value of any attibute given a workItem?

Thank you.


3 other answers

Permanent link
I hear you, but there is no 'simple' few statement example.

the routine that does the attribute work is
<code>
  static void printAttributes(IWorkItem workItem,
            IAuditableClient auditableClient, IProjectArea projectArea,
            org.eclipse.core.runtime.IProgressMonitor monitor, ITeamRepository repository, String XML)
    { 
    }
</code>
it loops thru all the attributes and handles each one on the fly.

but you will need to have the project area and the AuditableClient  library handle.

0 votes

Comments

Yes, there is a simple way, I figured out myself.

It is in the next answer...


Permanent link

I figured out myself, thanks.

Following some examples (they are in Groovy since I am working on that lengauge, similar to Java):

// Getting the workItem
workItem = workItemClient.findWorkItemById(workItemNumber, IWorkItem.FULL_PROFILE, new SysoutProgressMonitor())
  println("WorkItem found: ["+workItem.getId()+"] "+workItem.getHTMLSummary().getPlainText())  

//Getting the WorkItem Owner
  owner = workItem.getOwner()
  def iContributor = (IContributor) repo.itemManager().fetchCompleteItem(owner, IItemManager.DEFAULT, null);
  def owner = iContributor.getName();
  println("Owner is: " + owner)


//Getting the WorkItem Project Area
  def projectArea = workItem.getProjectArea()
  def iProjectArea  = (IProjectArea) repo.itemManager().fetchCompleteItem(projectArea, IItemManager.DEFAULT, null);
  projectArea = iProjectArea.getName();
  println("Project Area is: " + projectArea)
  

//Geting the WorkItem State
  IWorkflowInfo info= workItemClient.findWorkflowInfo(workItem, new SysoutProgressMonitor());
  def status = info.getStateName(workItem.getState2());
  println("Status: " + status)  

0 votes


Permanent link
no problem.. same code as in my example.  I handle it by looking at the attribute type, then switching() based on the type to the right routine.

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,935
× 411

Question asked: Aug 12 '13, 4:57 p.m.

Question was seen: 7,099 times

Last updated: Aug 13 '13, 2:59 p.m.

Confirmation Cancel Confirm