i havse problem about query workitem having condition state
i havse problem about query defect workitem having condition state.
status name is "resloved".
blew code is plain java api.
result count is "0".
i don't know help me, please...
status name is "resloved".
blew code is plain java api.
result count is "0".
i don't know help me, please...
findWorkItemsState(repo,"JUnit Project",monitor);
@SuppressWarnings("unchecked")
public static void findWorkItemsState(ITeamRepository repo, String projectAreaName, IProgressMonitor monitor) throws TeamRepositoryException {
System.out.println("condition Attribute List");
IAuditableClient auditableClient= (IAuditableClient)repo.getClientLibrary(IAuditableClient.class);
IProcessClientService processClient= (IProcessClientService) repo.getClientLibrary(IProcessClientService.class);
URI uri= URI.create(projectAreaName.replaceAll(" ", "%20"));
IProjectArea projectArea= (IProjectArea) processClient.findProcessArea(uri, null, null);
IProjectAreaHandle prjAreaHandle = (IProjectAreaHandle)projectArea.getItemHandle();
if (projectArea == null) {
System.out.println("Project area not found.");
}
IItemManager itm = repo.itemManager();
IWorkItemClient service = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
ICombinedWorkflowInfos wfInfo = service.findCombinedWorkflowInfos(projectArea, monitor);
Identifier<IState>[] stateIds = wfInfo.getAllStateIds();
Identifier<IState> selectedState = null;
for(Identifier<IState> s :stateIds){
if(wfInfo.getStateName(s).equalsIgnoreCase("Resolved") && s.getStringIdentifier().equals("3")) {
System.out.println("getStateName:" + wfInfo.getStateName(s));
System.out.println("getStringIdentifier:" + s.getStringIdentifier());
selectedState = s;
break;
}
}
// State = Resolved
// Identifier<IState> stateIdentifier = null;
// stateIdentifier = Identifier.create(IState.class, "Resolved");
// System.out.println(stateIdentifier.toString());
IQueryResult<IResolvedResult<IWorkItem>> result = null;
IQueryableAttributeFactory factory= QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);
IQueryableAttribute projectAreaAttribute= factory.findAttribute(prjAreaHandle, IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, monitor);
IQueryableAttribute stateAttribute = factory.findAttribute(prjAreaHandle,IWorkItem.STATE_PROPERTY, auditableClient, monitor);
if (projectAreaAttribute== null || stateAttribute==null){
System.out.println("");
//return Collections.emptyList();
}
AttributeExpression projectAreaExpression= new AttributeExpression(projectAreaAttribute, AttributeOperation.EQUALS, projectArea);
AttributeExpression stateExpression = new AttributeExpression(stateAttribute, AttributeOperation.EQUALS, selectedState);
Term term = new Term(Operator.AND);
term.add(projectAreaExpression);
term.add(stateExpression);
IQueryCommon queryService= (IQueryCommon) repo.getClientLibrary(IQueryCommon.class);
result = queryService.getResolvedExpressionResults(prjAreaHandle, (Expression)term, IWorkItem.FULL_PROFILE);
System.out.println("This is total number: "+ result.getResultSize(monitor).getTotal()+"\n");
List<IWorkItem> matchingWorkItems= new ArrayList<IWorkItem>(result.getResultSize(monitor).getTotalAvailable());
while (result.hasNext(monitor)) {
matchingWorkItems.add(result.next(monitor).getItem());
}
for(int y=0; y < matchingWorkItems.size();y++)
{
showWorkItems(itm, matchingWorkItems.get(y), projectArea,service, monitor);
System.out.println("---------------------------------------------------");
}
}
4 answers
The following is sample for default Story workflow...
IQueryableAttribute stateAttribute = attFactory.findAttribute(prjAreaHandle, IWorkItem.STATE_PROPERTY, auditableClient, null);
AttributeExpression inProgressStateExpression = new AttributeExpression(stateAttribute, AttributeOperation.EQUALS, "com.ibm.team.apt.story.defined");
IQueryableAttribute stateAttribute = attFactory.findAttribute(prjAreaHandle, IWorkItem.STATE_PROPERTY, auditableClient, null);
AttributeExpression inProgressStateExpression = new AttributeExpression(stateAttribute, AttributeOperation.EQUALS, "com.ibm.team.apt.story.defined");
Hi,
so do I have to use the String identifier for the state and not an Identifier<IState> object?
If correct it is a different behaviour from other property used in expressions. The javadoc in IWorkItem.STATE_PROPERTY says to use the getState2 returned object which is the Identifier, not its string conversion.
Thanks,
Michele.
so do I have to use the String identifier for the state and not an Identifier<IState> object?
If correct it is a different behaviour from other property used in expressions. The javadoc in IWorkItem.STATE_PROPERTY says to use the getState2 returned object which is the Identifier, not its string conversion.
Thanks,
Michele.
The following is sample for default Story workflow...
IQueryableAttribute stateAttribute = attFactory.findAttribute(prjAreaHandle, IWorkItem.STATE_PROPERTY, auditableClient, null);
AttributeExpression inProgressStateExpression = new AttributeExpression(stateAttribute, AttributeOperation.EQUALS, "com.ibm.team.apt.story.defined");
The following is sample for default Story workflow...
IQueryableAttribute stateAttribute = attFactory.findAttribute(prjAreaHandle, IWorkItem.STATE_PROPERTY, auditableClient, null);
AttributeExpression inProgressStateExpression = new AttributeExpression(stateAttribute, AttributeOperation.EQUALS, "com.ibm.team.apt.story.defined");
thank you ^^*
this problem is resolved for your help.
i apply for defect workflow.
AttributeExpression workItemTypeExpression = new AttributeExpression(workItemAttribute, AttributeOperation.EQUALS, new String("defect"));
AttributeExpression projectAreaExpression= new AttributeExpression(projectAreaAttribute, AttributeOperation.EQUALS, projectArea);
AttributeExpression stateExpression = new AttributeExpression(stateAttribute, AttributeOperation.EQUALS, "3");
Hi,
so do I have to use the String identifier for the state and not an Identifier<IState> object?
If correct it is a different behaviour from other property used in expressions. The javadoc in IWorkItem.STATE_PROPERTY says to use the getState2 returned object which is the Identifier, not its string conversion.
Thanks,
Michele.
The following is sample for default Story workflow...
IQueryableAttribute stateAttribute = attFactory.findAttribute(prjAreaHandle, IWorkItem.STATE_PROPERTY, auditableClient, null);
AttributeExpression inProgressStateExpression = new AttributeExpression(stateAttribute, AttributeOperation.EQUALS, "com.ibm.team.apt.story.defined");
Thank you for your opinion.
I referde to below code. to get StringIdentifier of state object.
/////////////// Get name, getStringIdentifier of state object.
ICombinedWorkflowInfos wfInfo = service.findCombinedWorkflowInfos(projectArea, monitor);
//IWorkflowInfo wfInfo = service.findWorkflowInfo(workItem, monitor);
Identifier<IState>[] stateIds = wfInfo.getAllStateIds();
Identifier<IState> selectedState = null;
for(Identifier<IState> s :stateIds){
System.out.println("getStateName:" + wfInfo.getStateName(s));
System.out.println("getStringIdentifier:" + s.getStringIdentifier());
System.out.println("getToString:" + s.toString());
System.out.println("--------------------------------------");
}
getStateName:Abandoned
getStringIdentifier:com.ibm.team.workitem.buildTrackingWorkflow.state.s7
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.workitem.buildTrackingWorkflow.state.s7
--------------------------------------
getStateName:Done
getStringIdentifier:com.ibm.team.workitem.buildTrackingWorkflow.state.s3
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.workitem.buildTrackingWorkflow.state.s3
--------------------------------------
getStateName:In Progress
getStringIdentifier:com.ibm.team.workitem.buildTrackingWorkflow.state.s2
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.workitem.buildTrackingWorkflow.state.s2
--------------------------------------
getStateName:In Progress
getStringIdentifier:2
getToString:com.ibm.team.workitem.common.model.IState:2
--------------------------------------
getStateName:New
getStringIdentifier:1
getToString:com.ibm.team.workitem.common.model.IState:1
--------------------------------------
getStateName:Reopened
getStringIdentifier:6
getToString:com.ibm.team.workitem.common.model.IState:6
--------------------------------------
getStateName:Resolved
getStringIdentifier:3
getToString:com.ibm.team.workitem.common.model.IState:3
--------------------------------------
getStateName:Verified
getStringIdentifier:4
getToString:com.ibm.team.workitem.common.model.IState:4
--------------------------------------
getStateName:Approved
getStringIdentifier:com.ibm.team.rtc.workflow.adoption.state.s2
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.rtc.workflow.adoption.state.s2
--------------------------------------
getStateName:Completed
getStringIdentifier:com.ibm.team.rtc.workflow.adoption.state.s4
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.rtc.workflow.adoption.state.s4
--------------------------------------
getStateName:Proposed
getStringIdentifier:com.ibm.team.rtc.workflow.adoption.state.s1
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.rtc.workflow.adoption.state.s1
--------------------------------------
getStateName:Rejected
getStringIdentifier:com.ibm.team.rtc.workflow.adoption.state.s3
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.rtc.workflow.adoption.state.s3
--------------------------------------
getStateName:Done
getStringIdentifier:com.ibm.team.workitem.retrospectiveWorkflow.state.finished
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.workitem.retrospectiveWorkflow.state.finished
--------------------------------------
getStateName:In Progress
getStringIdentifier:com.ibm.team.workitem.retrospectiveWorkflow.state.inprogress
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.workitem.retrospectiveWorkflow.state.inprogress
--------------------------------------
getStateName:Invalid
getStringIdentifier:com.ibm.team.workitem.retrospectiveWorkflow.state.s1
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.workitem.retrospectiveWorkflow.state.s1
--------------------------------------
getStateName:New
getStringIdentifier:com.ibm.team.workitem.retrospectiveWorkflow.state.new
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.workitem.retrospectiveWorkflow.state.new
--------------------------------------
getStateName:Invalid
getStringIdentifier:com.ibm.team.workitem.taskWorkflow.state.s4
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.workitem.taskWorkflow.state.s4
--------------------------------------
getStateName:Deferred
getStringIdentifier:com.ibm.team.apt.epic.workflow.state.s5
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.apt.epic.workflow.state.s5
--------------------------------------
getStateName:Done
getStringIdentifier:com.ibm.team.apt.epic.workflow.state.s3
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.apt.epic.workflow.state.s3
--------------------------------------
getStateName:In Progress
getStringIdentifier:com.ibm.team.apt.epic.workflow.state.s2
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.apt.epic.workflow.state.s2
--------------------------------------
getStateName:Invalid
getStringIdentifier:com.ibm.team.apt.epic.workflow.state.s6
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.apt.epic.workflow.state.s6
--------------------------------------
getStateName:New
getStringIdentifier:com.ibm.team.apt.epic.workflow.state.s1
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.apt.epic.workflow.state.s1
--------------------------------------
getStateName:Invalid
getStringIdentifier:com.ibm.team.workitem.impedimentWorkflow.state.s3
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.workitem.impedimentWorkflow.state.s3
--------------------------------------
getStateName:New
getStringIdentifier:com.ibm.team.workitem.impedimentWorkflow.state.s1
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.workitem.impedimentWorkflow.state.s1
--------------------------------------
getStateName:Resolved
getStringIdentifier:com.ibm.team.workitem.impedimentWorkflow.state.s2
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.workitem.impedimentWorkflow.state.s2
--------------------------------------
getStateName:Deferred
getStringIdentifier:com.ibm.team.apt.storyWorkflow.state.s1
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.apt.storyWorkflow.state.s1
--------------------------------------
getStateName:Done
getStringIdentifier:com.ibm.team.apt.story.verified
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.apt.story.verified
--------------------------------------
getStateName:Implemented
getStringIdentifier:com.ibm.team.apt.story.tested
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.apt.story.tested
--------------------------------------
getStateName:In Progress
getStringIdentifier:com.ibm.team.apt.story.defined
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.apt.story.defined
--------------------------------------
getStateName:New
getStringIdentifier:com.ibm.team.apt.story.idea
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.apt.story.idea
--------------------------------------
getStateName:Invalid
getStringIdentifier:com.ibm.team.apt.storyWorkflow.state.s2
getToString:com.ibm.team.workitem.common.model.IState:com.ibm.team.apt.storyWorkflow.state.s2
--------------------------------------