- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试编写一个 Java 程序,从 Polarion 获取工作记录信息并将其写入 DAT 文件以供以后使用。
我已成功连接到我们的服务器并检索了 WorkItem
对象,但所有 getter 方法(除了 getUri()
之外)似乎都不起作用,这造成了问题,因为我需要使用 WorkItem
类的 getWorkRecords()
方法来满足项目的要求。
我已经在我们的主 Polarion 服务器和“临时”服务器上尝试了该类的所有 getter 方法,我们将其用作诸如我正在尝试编写的程序及其上的程序之类的测试区域我有完全权限。
无论权限如何,我只是查询我创建并分配给自己的一些虚拟工作项,因此不应该有任何权限问题,因为我只是尝试查看我自己的工作项。
以下是该程序的代码:
package test;
//stg= 10.4.1.50
//main= 10.4.1.10
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import javax.xml.rpc.ServiceException;
import com.polarion.alm.ws.client.WebServiceFactory;
import com.polarion.alm.ws.client.session.SessionWebService;
import com.polarion.alm.ws.client.tracker.TrackerWebService;
import com.polarion.alm.ws.client.types.tracker.WorkItem;
import com.polarion.alm.ws.client.types.tracker.WorkRecord;
public class WorkrecordImporter {
private WebServiceFactory factory;
private TrackerWebService trackerService;
private SessionWebService sessionService;
private WorkItem[] workItems;
private ArrayList<WorkRecord> workRecords;
private String password = //insertpasswordhere;//no peaking
public WorkrecordImporter()throws ServiceException, IOException, ClassNotFoundException{
initializeFields();//initializes all of the Web Services and arrays
//step one
getWorkItems();
//readDATFile();
//step two
getWorkRecords();
//$$$
printWorkRecords();
//$$$$$
writeDATFile();
}
//you know what this does.
public void printWorkRecords(){
for(int temp = 0; temp < workItems.length; temp++){
System.out.println(workItems[temp].getUri().toString());
}
}
public void writeDATFile() throws IOException{
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("C:\\Users\\sweidenkopf\\workspace\\test\\filename.dat"));
try {
out.writeObject(workRecords);
} finally {
// Make sure to close the file when done
out.close();
}
}
/**
* This method sets up the WebServiceFactory at the specified URL. It then initializes the web services, logs in the
* session service, and initializes the arrays.
* @throws MalformedURLException
* @throws ServiceException
* @throws RemoteException
*/
public void initializeFields() throws MalformedURLException, ServiceException, RemoteException{
factory = new WebServiceFactory("//insert url here");
trackerService = factory.getTrackerService();
sessionService = factory.getSessionService();
sessionService.logIn("sweidenkopf", password);
workRecords = new ArrayList<>();
}
public void getWorkItems()throws MalformedURLException, ServiceException, RemoteException{
sessionService.beginTransaction();
workItems = trackerService.queryWorkItems("workRecords.user.id:sweidenkopf", null, null);
sessionService.endTransaction(false);
}
public void getWorkRecords()throws MalformedURLException, ServiceException, RemoteException{
sessionService.beginTransaction();
for(int k = 0; k < workItems.length; k++)
{System.out.println("This is working");
try{//not every work item has work records
System.out.println(workItems[k].getWorkRecords());
WorkRecord[] temp;
temp = workItems[k].getWorkRecords();
for(int x = 0; x < temp.length; x++){
System.out.println("This is working fine");
workRecords.add(temp[x]);
}
}catch(NullPointerException e){
System.out.println("I must regretfully inform you that I have grave news; your endeavors have not been successfull.");
continue;
}
}
System.out.println(workRecords.toString());
sessionService.endTransaction(false);
}
public void readDATFile() throws FileNotFoundException, IOException, ClassNotFoundException{
ObjectInputStream in = new ObjectInputStream(new FileInputStream("C:\\Users\\sweidenkopf\\workspace\\test\\filename.dat"));
try{
Object temp = in.readObject();
workRecords = (ArrayList) temp;
}
finally{
in.close();
}
}
}
最重要的部分当然是我的代码中的getWorkRecords()
方法。如您所见,它包含我用于调试目的的语句 System.out.println(workItems[k].getWorkRecords());
。此语句返回 null
,而在该语句中替换时唯一不返回 null 的 WorkItem
方法是 getUri()
。此外,该方法中的 try-catch block 始终捕获 NullPointerException
,因为 for
循环包含 temp.length
,temp 是一个变量,应包含 getWorkRecords()
方法的返回值。
总结这里的主要问题是我无法从 getWorkRecords()
或 WorkItem
的任何其他 getter 方法返回任何内容类(class)。这令人费解,因为 getUri()
方法正在成功执行,因为我的代码中的 printWorkRecords()
方法成功打印了所有 WorkItem
的 URI code> 从我的查询中返回对象。
有没有任何 Polarion 专家以前遇到过这个问题?有谁知道我做错了什么?根据具体情况,我倾向于认为这是一个错误。
最佳答案
如果您查看我对 queryWorkItems()
方法的调用,您会注意到在查询参数之后我指定了两个空参数。第一个指定您希望如何对返回的工作项进行排序(目前这无关紧要),但第二个是一个名为 fields
的 String
数组,用于指定哪个您希望与 WorkItems
本身一起返回的 WorkItem
字段。显然,如果您像我一样将其设置为 null
,它默认只返回 URI。对于其他内容,例如作者、工作记录和类型,您必须将它们放入 String
数组中,并在调用该方法时传递该数组。
关于java - Polarion WorkItem 类 getter 方法返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17821417/
有没有办法修改当前在任务工作项的事件下拉列表中的值?这是当前列表: 部署 设计 发展 文档 测试 需求 最佳答案 当然,您必须编辑要更改的现有团队项目的流程模板或工作项类型。 This article
我正在使用 MSF Agile 5.0 项目模板。 我希望修改 Product Backlog 查询以包含没有父级的任务。该查询当前仅显示用户故事。 我没有看到要查询的字段,例如父项 ID 或类似字段
WorkItem.Save 保存了什么?更改/添加/删除的所有内容,包括添加的新附件等? 我正在尝试确定它在内部是如何工作的。假设由于某种原因无法设置一项或无法添加一个附件等失败,调用 Save 或尝
我想在工作项的讨论区中的 tfs 项目中添加指向特定 wiki 页面 url 的链接。 我只是得到文本: http://tfs.xxxx.com:8080/tfs/DefaultCollection/
是否可以将工作项从一个项目移动到 TFS 内的另一个项目?我看到了复制选项,但没有移动。此外,如果可能的话,对任何 WI 历史有什么影响? 我找到了这个 article从 2008 年开始,似乎说它不
我可以通过以下方式成功创建迭代路径: var commonservice = collection.GetService(); // create new area path and iteratio
我打开一个工作项并进入附件选项卡。我双击一个 .doc 附件。它不是在 Word 中打开文件,而是启动浏览器,从而关闭文件。 有没有办法让 TFS 直接在 Word 中运行附件? 最佳答案 通过给定的
在 MS Team Foundation Server 2010 中是否可以更新与 checkin 关联的工作项?我昨天工作到很晚,检查了错误的项目,想重新关联正确的工作项目。 最佳答案 工作项通过将
我正在使用 TFS 2010。 我有一个包含允许值列表的字符串字段。当我查看工作项时,列表按字母顺序排序(原始列表未按字母顺序排序)。 有什么方法可以显示与工作项模板中给出的相同的值顺序。 有没有办法
如果我这样做: RelatedLink newLink = new RelatedLink(linkTypeEnd, id); if (workItem.Links.Contains(newLink)
我创建了一个新的工作项类型,我正在尝试将它导入到我的 tfs 2012 项目中,但我收到错误 TF237090:不存在或访问被拒绝。我可以在更改后成功导入现有工作项,但不能成功导入新工作项。 最佳答案
我的项目要求我以编程方式访问我们不管理的 TFS 服务器,并获取有关 WorkItemTypes 中字段的实时信息。通过查看 WorkItemType 的 FieldDefinitions 集合中的
我必须在主线程上执行类似 NSProgressIndicator.stopAnimation 的操作。但是我想在分配给后台线程的 workItem 结束时执行此操作。 NSProgressIndica
我想以编程方式将工作项链接到变更集。 目前我已经从我的 C# 代码创建工作项并将它们保存到 TFS。代码如下所示: WorkItem item = new WorkItem(project.WorkI
如何从 RTC workItem 中读取历史记录。我想在更改表单历史记录之前和之后检查一些属性更改及其值。通过爵士 API。这怎么可能?请帮忙 。 最佳答案 Ragarding属性,你可以在“Work
获取https://dev.azure.com/{organization}/_apis/work/processes/{processId}/workItemTypes/{witRefName}/l
获取https://dev.azure.com/{organization}/_apis/work/processes/{processId}/workItemTypes/{witRefName}/l
我们有一个适用于 TFS(Team Fondation Server)的应用程序。此应用程序部分离线,它正在将 WorkItems 同步到本地库。为了同步 WorkItem 更改,我们使用“Chang
无论出于何种原因,ThreadPool 的 QueueWorkItem 不会返回 IAsyncResult 或工作项的其他一些句柄,这将允许等到它完成。有 RegisterWait... 方法,但您必
运行下面的脚本后我收到此错误。我想通过此脚本中生成的结果创建一个 json 文件。我可以做什么来解决这个问题? 我尝试通过 API 执行此操作,但无法从此 DevOps 表中获取所需的字段。 from
我是一名优秀的程序员,十分优秀!