It's all about the answers!

Ask a question

How to set a work item's QA Team and Phase Found using RTC Plain Java API?


cheng yingying (324) | asked Nov 28 '14, 2:58 a.m.
edited Nov 28 '14, 3:50 a.m.

According to posts in this forum, I should use following code to set QA Team and Phase Found.

IAttribute qaAttribute = workItemClient.findAttribute(projectArea, "qa_team", null);

IAttribute phaseAttribute = workItemClient.findAttribute(projectArea, "howfound", null);

workItem.setValue(IAttribute, Object);

But My Question is:

If I have known the QA Team's name(For example, FVT), and PhaseFound's name(For example, Phase 1), how to get those objects which would be used by workItem.setValue(...)?

Which class and method should I use to get the corresponding objects. I want to know how to write the code as below:

IAttribute foundInAttribute = workItemClient.findAttribute(projectArea, "foundIn", null);
IDeliverable foundIN = workItemClient.findDeliverableByName(projectArea, foundIn,
     IDeliverable.SMALL_PROFILE, null);

Of course, other implementation is welcome.

Thanks in advance.

----------------------

These two attributes might be customized attributes:

displayName: QA Team
attributetype: test_team
identifier: qa_team

displayName: Phase Found
attributetype: HowFound
identifier: howfound

Accepted answer


permanent link
Ralph Schoon (63.1k33646) | answered Nov 28 '14, 4:24 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
It is unclear what type is used for these attributes. I assume it is an enumeration. If this is the case, look here https://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/
cheng yingying selected this answer as the correct answer

Comments
cheng yingying commented Nov 30 '14, 10:28 p.m.


Thanks for your help, Ralph. It really helps!

3 other answers



permanent link
cheng yingying (324) | answered Dec 01 '14, 12:47 a.m.
edited Dec 07 '14, 8:57 p.m.
Thank you, Sam.

I believe I'm saving a work item(defect), don't know why it triggered the saveProjectArea. Following is the related code. And I have used the similar code to save a work item(task) successfully. Confused.

private static class WorkItemInitialization extends WorkItemOperation {
private String fSummary;
private ICategoryHandle fCategory;
private IIterationHandle fIteration;
HashMap<IAttribute, Object> fAttributes;
public WorkItemInitialization(String summary, ICategoryHandle category, IIterationHandle iteration, HashMap attributes) {
super("Initializing Work Item");
fSummary= summary;
fCategory= category;
fAttributes = attributes;
fIteration = iteration;
}
@Override
protected void execute(WorkItemWorkingCopy workingCopy, IProgressMonitor monitor) throws TeamRepositoryException {
IWorkItem workItem= workingCopy.getWorkItem();
workItem.setHTMLSummary(XMLString.createFromPlainText(fSummary));
workItem.setCategory(fCategory);

workItem.setTarget(fIteration); 
Iterator keys = fAttributes.keySet().iterator();
while(keys.hasNext()){
IAttribute key = (IAttribute)keys.next();
Object value = fAttributes.get(key);
workItem.setValue(key, value);
}
}
}
.....


String repositoryURI= "https://xx.ibm.com:8001/jazz/";//    
String userId= "XXX";
String password= "XXX";
String projectAreaName= "Lotus Connections";
String typeIdentifier= "defect";

String summary = "Post install bvt";
String categoryName= "Web/Cross Functional/Automation";//args[6];//filedAgainst
String plannedFor = "Main development/Release Backlog/2014 Development";//required by task, defect
String foundIn = "Automated BVT";//required by defect
String qaTeam = "Functional (FVT)";//required by defect
String phaseFound = "Functional (FVT)";//required by defect
...
 
IWorkItemType workItemType= workItemClient.findWorkItemType(projectArea, typeIdentifier, null);
if (workItemType == null) {
System.out.println("Work item type not found.");
return false;
}
....

IAttribute phaseAttribute = workItemClient.findAttribute(projectArea, "howfound", null);
Identifier literalID_phase = null;
IEnumeration enumeration_phase =workItemClient.resolveEnumeration(phaseAttribute, null);
List literals_phase = enumeration_phase.getEnumerationLiterals();
for (Iterator iterator = literals.iterator(); iterator.hasNext();) {
ILiteral iLiteral = (ILiteral) iterator.next();
if (iLiteral.getName().equals(phaseFound)) {
literalID_phase = iLiteral.getIdentifier2();
System.out.println("You found phase!!");
break;
}
}
if(literalID_phase==null){
System.out.println("not found phase");
return false;
}
attributes.put(foundInAttribute, foundIN);
attributes.put(qaAttribute, literalID);
attributes.put(phaseAttribute, literalID_phase);
...

WorkItemInitialization operation= new WorkItemInitialization(summary, category, cih, attributes);
IWorkItemHandle handle= operation.run(workItemType, null);
IWorkItem workItem= auditableClient.resolveAuditable(handle, IWorkItem.FULL_PROFILE, null);
System.out.println("Created work item " + workItem.getId() + ".");

permanent link
sam detweiler (12.5k6195201) | answered Nov 30 '14, 10:57 p.m.
Looks like you are trying to save the project area.. not just the workitem

ID: com.ibm.team.process.server.saveProjectArea

permanent link
cheng yingying (324) | answered Nov 30 '14, 10:28 p.m.
  
And I have a subsequent question. I've got following error when I have set values and save a defect work item. I have the permission to create a defect from UI. Does the following error mean I don't have the permission to create a defect by API? Thanks.

com.ibm.team.process.common.advice.TeamOperationCanceledException : CRJAZ6053E The 'Save Work Item' operation cannot be completed. Permission is required to complete the operation.
      at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.advise( OperationAdviceManager.java:387 )
...

Name: Save Work Item
      ID: com.ibm.team.workitem.operation.workItemSave
      Severity: ERROR
            Name: Required Properties
            ID: com.ibm.team.workitem.advisor.requiredProperties
            Severity: OK
            Name: Required Approvals
            ID: com.ibm.team.workitem.advisor.requiredApprovals
            Severity: OK
            Name: All Children Resolved
            ID: com.ibm.team.workitem.advisor.allChildrenClosed
            Severity: OK
            Name: Save Project Area
            ID: com.ibm.team.process.server.saveProjectArea
            Severity: ERROR
                  Summary: Permission Denied
                  Description: You don't have permission to perform the following actions:
  Modify the process specification (modify/specification)
                  Severity: ERROR
                  Name: Avoid saving private roles
                  ID: com.ibm.ics.scm.rtc.privateroles.project
                  Severity: OK

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.