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

How can i update the status and priority and severity and iteration of a workitem?

I am able to set the summary and description. I need to set the priority bt it gives me:

ERRORS:
org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
at com.ibm.team.workitem.common.internal.EnumerationManager.getEnumerationAttributeType(EnumerationManager.java:129)
at com.ibm.team.workitem.common.internal.EnumerationManager.resolve(EnumerationManager.java:70)
at com.ibm.team.workitem.common.internal.WorkItemCommon.resolveEnumeration(WorkItemCommon.java:538)
at login.WorkitemUpdate.IterationRecursiveLiteral(WorkitemUpdate.java:223)
at login.WorkitemUpdate.IterationRecursiveLiteral(WorkitemUpdate.java:148)
at login.WorkitemUpdate.getIterationLiteral(WorkitemUpdate.java:112)
at login.Login.main(Login.java:121)


ALso i cannot typecast it to literal to i attribute type.
please help me



if(workItem.getId()==xxxxx){
List allAttributeHandles = workItemClient.findAttributes(area, null);  
for (Iterator iterator = allAttributeHandles .iterator(); iterator.hasNext();) {
 IAttributeHandle iAttributeHandle = (IAttributeHandle) iterator.next();
 iAttribute = (IAttribute) teamRepository.itemManager().fetchCompleteItem(  iAttributeHandle, IItemManager.DEFAULT ,null);
 Identifier literalID = null;
IEnumeration<? extends ILiteral> enumeration = (IEnumeration<? extends ILiteral>) workItemClient.resolveEnumeration(iAttributeHandle, null); 
List literals = enumeration.getEnumerationLiterals();
for(Iterator iterator1 = literals.iterator(); iterator1.hasNext();) {
ILiteral iLiteral = (ILiteral) iterator1.next();
if (((IPriority) iLiteral).getName().equals("High")) {
literalID = ((IPriority) iLiteral).getIdentifier2();
target=((IPriority) iLiteral).getName();
//System.out.println(literalID);
IWorkItem workItem1 = workItemClient.findWorkItemById(1468485,IWorkItem.FULL_PROFILE,null);
}
}
}  
IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();         
wcm.connect(workItem, IWorkItem.FULL_PROFILE, null); 
try { 
 WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItem);
IWorkItem wcopy=wc.getWorkItem();
wcopy.setValue(iAttribute, target);

 //updating description--working
String description=workItem.getHTMLDescription().getPlainText();
          //wc.getWorkItem().setHTMLDescription(XMLString.createFromPlainText(description + "My description"));   

//updating summary--working
String summary=workItem.getHTMLSummary().getPlainText();
          //wc.getWorkItem().setHTMLSummary(XMLString.createFromPlainText(summary + "My Summary"));
 //updating status--
IWorkflowInfo info= workItemClient.findWorkflowInfo(workItem,null); 
 // IAttribute at=(com.ibm.team.workitem.common.model.IAttribute)workItem.getState2();
// String status = info.getStateName(workItem.getState2());
// String value=new String("Start Working");
// if(value instanceof String)
{

workItem.setValue(at,value);
}
 
workItem.setState2((Identifier<IState>)com.ibm.team.workitem.taskWorkflow.action.a2);
// System.out.println("Status: " + status) ;
  IDetailedStatus s = wc.save(null); 
 if (!s.isOK()) { throw new TeamRepositoryException("Error saving work item", 
  s.getException());                        
          
 }
  }         
finally { wcm.disconnect(workItem); 
}
System.out.println("Modified work item: " + workItem.getId() + "."); }
else{
break;
}

0 votes



2 answers

Permanent link

 The code is pretty unreadable.


You seem iterate all work item attributes and try to access that as an enumeration? That will not work. You will have to check if they are actually enumerations or something else.

Since you are a beginner, provide the attribute ID where you know it is an enumeration, same for the a
other attributes you look for. Also focus on one attribute first to get working code as described in https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ . Use instanceof to test for types/interfaes
    Object value = workItem.getValue(customString);
    if (value instanceof String) {
        String attributeValue = (String) value;
        // do something with the value
    }

    </pre>
</div>

PS: you have to look up the attribute ID's for the internal attributes in the Web Admin UI, and not in the Eclipse UI.

0 votes

Comments

i am bale to get all the priorities but i am not able to type cast it from com.ibm.team.workitem.common.internal.model.Priority to com.ibm.team.repository.common.query.ast.ILiteral.Moreover setting the value also shows error.please help me





 



Permanent link

 List builtInAttributeHandles = workItemClient.findAttributes(area, null);

             for (Iterator iterator = builtInAttributeHandles .iterator(); iterator.hasNext();) {
                 IAttributeHandle iAttributeHandle = (IAttributeHandle) iterator.next();
                  iAttribute = (IAttribute) teamRepository
                     .itemManager().fetchCompleteItem(
                     iAttributeHandle, IItemManager.DEFAULT ,null);
                 Identifier literalID = null;
                 if(iAttribute.getDisplayName().equals("Priority")){
                 IEnumeration<? extends ILiteral> enumeration = (IEnumeration<? extends ILiteral>) workItemClient.resolveEnumeration(iAttributeHandle, null); 
//List literals = enumeration.getEnumerationLiterals();
for(ILiteral ilteral:enumeration.getEnumerationLiterals())
{
if((boolean)ilteral.equals("priority.literal.l11"))
target=((IPriority) ilteral).getName();
//IWorkItem workItem1 = workItemClient.findWorkItemById(1468485,IWorkItem.FULL_PROFILE,null);
IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();         

        wcm.connect(workItem, IWorkItem.FULL_PROFILE, null); 
        
        try { 
            WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItem);
            IWorkItem wcopy=wc.getWorkItem();
            wcopy.setValue(iAttribute,target);

0 votes

Comments

 i am able to get all the priorities while debuggingin the list but i am not able to type cast it from com.ibm.team.workitem.common.internal.model.Priority to com.ibm.team.repository.common.query.ast.ILiteral.Moreover setting the value also shows error.please help me


I think you should do some reading instead of creating code. I already provided you with https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ which also links to:  https://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/

Most links I provided you have downloadable code that works (for me at least) to deal with enumerations. 

My code does not use the WorkingCopyManager but a WorkItem Operation as explained in https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ .

So I would suggest to do some downloading, reading and experimenting with existent code. 

The work item command line code deals with all the problems you are facing too, but it is more complex and maybe looking into to special blog posts might be more effective.

 Hi Ralph,

I have read these documents.but still not able to update the status.Can u please help me with code how to update the status and type of a particular workitem

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

Question asked: Jun 19 '17, 7:15 a.m.

Question was seen: 2,592 times

Last updated: Jun 21 '17, 3:05 a.m.

Confirmation Cancel Confirm