从Rally API 1.43迁移到2.0-对象模型 [英] Migrating from Rally API 1.43 to 2.0 - Object Model

查看:116
本文介绍了从Rally API 1.43迁移到2.0-对象模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一些自定义Java代码,该代码使用Rally Java API v1.43查询Rally,创建和更新故事.据我了解,我们使用wsdl2java为Rally Object模型创建了Java类,其描述如下这里.我们的代码在整个过程中都大量使用这些类.

I have inherited some custom java code that uses the Rally Java API v1.43 to query Rally, create and update stories. As I understand it, we created Java classes for the Rally Object model using wsdl2java that is described Here. Our code heavily uses these classes throughout.

现在我必须升级到Rally v2.0 API,我不明白我是否可以轻松地利用基于这些具体类的已有代码,或者是否需要重写所有内容以直接使用JSON使用JsonObject之类的东西从Rally中返回,或者按照v2.0 API文档中的描述直接生成JSON有效负载.

Now that I have to upgrade to Rally v2.0 API, I do not understand whether I can easily leverage the code we already have based on these concrete classes or if I need to re-write everything to directly work with the JSON returned from Rally using something like JsonObject, or generating the JSON payloads directly as described in the v2.0 API documentation.

我已经找到了许多有关如何使用v2.0 REST API进行操作的示例,如果我从头开始,这可能会有所帮助.从v1.43过渡到v2.0有更好的方法吗?

I've found plenty of examples on how to do things with v2.0 REST API which might be helpful if I were starting from scratch. Is there a better way to transition from v1.43 to v2.0?

谢谢

推荐答案

这里有两个问题:

  1. 从SOAP到REST的过渡
  2. 从旧版WS API过渡到v2.0.

从SOAP到REST的过渡:

Transitioning from SOAP to REST:

实际上,我们不再支持SOAP和xml,并且v2.0没有WSDL.

Indeed we no longer support SOAP and xml, and there is no WSDL for v2.0.

没有标准的重构路径:使用SOAP接口的旧代码通常需要从头开始使用REST接口重写.我们有一个Rally Java REST工具包,可在此github存储库中使用.

There is no standard refactoring path: the old code that used SOAP interface needs to be re-written using REST interface, often from scratch. We have a Rally Java REST Toolkit, available in this github repository.

从旧版WS API过渡到v2.0:

Transitioning from from older versions of WS API to v2.0:

从1.43过渡到v2.0的主要区别在于如何处理集合.

As far as transition from 1.43 to v2.0, a main difference is in how collections are handled.

在v2.0中,出于性能原因,我们删除了以相同响应返回子集合的功能.在v2.0中,获取集合将返回一个对象,该对象带有从中获取集合数据的count和url. AppSDK2rc1可与WS API的v2.0一起使用.

In v2.0 we removed the ability to return child collections in the same response for performance reasons. In v2.0 fetching a collection will return an object with the count and the url from which to get the collection data. AppSDK2rc1 works with v2.0 of WS API.

在WS API的旧版本中,某些提取列表会创建很多递归调用,并且提取中包含的所有集合使调用变得非常昂贵.在WS API v2.0中,不会发生这种情况,因为必须进行单独的调用才能获取集合的对象.

In the older versions of WS API certain fetch lists create a lot recursive calls, and all the collections included in the fetch make the call quite expensive. In WS API v2.0 this will not happen, since a separate call will have to be made in order to get objects of the collections.

下面的代码片段都是REST示例,但是显示了如何重构代码以升级到v2.0.

The code fragments below are both REST examples, but show how to refactor code to upgrade to v2.0.

假设您要检索与测试集关联的测试用例.

Let's say you want to retrieve Test Cases associated with the Test Set.

代替此操作(在1.43中有效,因为返回了集合):

Instead of this (which works in 1.43 because the collection is returned):

int numberOfTestCases = testSetJsonObject.get("TestCases").getAsJsonArray().size();
if(numberOfTestCases>0) {
    for (int j=0;j<numberOfTestCases;j++) {
       System.out.println(testSetJsonObject.get("TestCases").getAsJsonArray().get(j).getAsJsonObject().get("FormattedID"));
    }
}

执行此操作:

//TestCases is an object with a Count and a ref to load the collection
int numberOfTestCases = testSetJsonObject.getAsJsonObject("TestCases").get("Count").getAsInt();

if(numberOfTestCases > 0) {
    QueryRequest testCaseRequest = new QueryRequest(testSetJsonObject.getAsJsonObject("TestCases"));
    testCaseRequest.setFetch(new Fetch("FormattedID"));
    //load the collection
    JsonArray testCases = restApi.query(testCaseRequest).getResults();
    for (int j=0;j<numberOfTestCases;j++){
        System.out.println(testCases.get(j).getAsJsonObject().get("FormattedID").getAsString());
    }
}

另一个常见的区别是在v.2.0中,自定义字段以c_开头. WS API v2.0中将自定义KanabanState字段引用为c_KanbanState.

Another common difference is that in v.2.0 custom fields are prepended with c_. A custom KanabanState field is referenced in WS API v2.0 as c_KanbanState.

最后,在v2.0中更新和创建请求需要额外的身份验证层.但是,只要您使用Rally Java REST Toolkit,就不必担心它.被占领者在后台进行操作,您无需编写请求安全令牌并维护会话的代码.

Finally, update and create requests in v2.0 requre an extra layer of authentication. However as long as you use Rally Java REST Toolkit, you do not need to be concerned about it. The tookit does it behind the scene, and you do not need to write the code that requests a security token and maintains the session.

这篇关于从Rally API 1.43迁移到2.0-对象模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆