【发布时间】:2018-10-15 16:49:12
【问题描述】:
如何在 TFS java sdk 中查询链接的工作项。 下面是从 tfs 查询正常工作项的代码:
public static void main(final String[] args) {
final TFSTeamProjectCollection tpc = SnippetSettings.connectToTFS();
final Project project = tpc.getWorkItemClient().getProjects().get(SnippetSettings.PROJECT_NAME);
final WorkItemClient workItemClient = project.getWorkItemClient();
// Define the WIQL query.
final String wiqlQuery = "Select ID, Title from WorkItems where (State = 'Active') order by Title"; //$NON-NLS-1$
// Run the query and get the results.
final WorkItemCollection workItems = workItemClient.query(wiqlQuery);
System.out.println("Found " + workItems.size() + " work items."); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println();
// Write out the heading.
System.out.println("Query: " + wiqlQuery); //$NON-NLS-1$
System.out.println();
System.out.println("ID\tTitle"); //$NON-NLS-1$
// Output the results of the query.
final int maxToPrint = 20;
for (int i = 0; i < workItems.size(); i++) {
if (i >= maxToPrint) {
System.out.println("[...]"); //$NON-NLS-1$
break;
}
final WorkItem workItem = workItems.getWorkItem(i);
System.out.println(workItem.getID() + "\t" + workItem.getTitle()); //$NON-NLS-1$
}
}
在使用上述代码运行链接的工作项查询时,我收到一条错误消息:
com.microsoft.tfs.core.clients.workitem.exceptions.ValidationException: TF248021: You have specified a query string that is not valid when you use the query method for a flat list of work items. You cannot specify a parameterized query or a query string for linked work items with the query method you specified.
【问题讨论】: