[英]Using the Java StarTeam API, how can I find which revisions of a StarTeam Item have a certain label?
I'm using the StarTeam java API (v10.4). 我正在使用StarTeam Java API(v10.4)。
I am having a heckuva time trying to find which specific revisions a Label is applied to. 我正在忙着找一个标签应用于哪些特定修订的时间。 What makes this tricky is that there seems to be no method on the Label object which provides a list of what that label is applied to.
造成这一棘手的原因是,在Label对象上似乎没有任何方法可以提供该标签所应用的内容的列表。
So you (seemingly) need to go backwards and find a list of items that you want to check for a particular Label, eg 因此,您(貌似)需要倒退并找到要检查特定标签的项目列表,例如
int[] check_these_items = new int[]{ item_to_check.getID() };
int[] labelledItems = myLabel.getLabeledItemIDs(check_these_items)
First, that's kind of convoluted because you need to have a Label in the first place when really what I wanted was to get a list of labels attached to a single revision. 首先,这有点令人费解,因为当我真正想要的是获取附加到单个修订版的标签列表时,首先需要有一个Label。 But ok, let's go with that for now.
但是,现在让我们开始吧。 So now I need to find a single revision from the history.
因此,现在我需要从历史记录中查找一个修订。 Let's make this simple and say I want to get the third (or fourth) revision:
让我们简化一下,说我想获得第三版(或第四版):
Item specific_child = item_to_check.getHistory()[3];
Now the problem is that this new child from history has the same ID (via getID()
) as the parent so using getLabeledItemIds(check_these_items)
will return the same labels and essentially, we haven't gotten anywhere. 现在的问题是,历史记录中的这个新子代与父代具有相同的ID(通过
getID()
),因此使用getLabeledItemIds(check_these_items)
将返回相同的标签,并且从本质getLabeledItemIds(check_these_items)
,我们还没有到过任何地方。
I did find a question related to finding past revisions but it wasn't pertaining to finding labels on past revisions. 我发现一个问题,涉及到寻找过去的版本,但它不属于过去的修订发现标签。
Of course, I checked Borland 's API documentation but have not come up with the solution. 当然,我检查了Borland的API文档,但没有提出解决方案。
I know the UI can do it so certainly there is way, I'm just having a time finding it. 我知道UI可以做到,所以肯定有办法,我只是有时间找到它。
Any suggestions even at a high-level would be greatly appreciated! 任何建议,即使是高水平的,也将不胜感激!
Once you have the Item and the Label at hand, use getFromHistoryByLabelID(int) 拥有项目和标签后,请使用getFromHistoryByLabelID(int)
to "Returns the specified version of this item based on the given label ID" 为“根据给定的标签ID返回此项目的指定版本”
This still doesn't seem like the right answer, but eventually I had to move on and ended up using a workaround of finding the revision date/time of the label I wanted and then comparing the item revision to that. 这似乎仍然不是正确的答案,但是最终我不得不继续前进,最终使用一种变通方法来找到我想要的标签的修订日期/时间,然后将项目修订与此进行比较。 So by that type of reverse logic, I was able to check each label attached to the element and find which revisions had that label.
因此,通过这种反向逻辑,我能够检查附加到元素的每个标签,并找到具有该标签的修订。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.