java - RallyRestAPI 查询 ScopedAttributeDefinition 类型

标签 java rest rally agile

使用 RallyRestAPI,有没有办法查询 ScopedAttributeDefinition 类型?这似乎是在 Rally 中定义自定义数据类型。我正在尝试构建我们在 Rally 中使用的自定义类型的数据字典,并将这些自定义类型与它们所属的对象相关联。 (如果这没有意义,这里有一个示例:我们在 Rally PortfolioItems 上有一个名为 Enabler Lead 的自定义字段。我想在 Rally 中查询 PortfolioItem 的所有自定义字段,并从 Rally REST API 获取 Enabler 字段及其元数据。)

我正在使用 Java 客户端。

最佳答案

我提交了一个 github 问题来添加对 ScopedAttributeDefinition 的支持:https://github.com/RallyTools/RallyRestToolkitForJava/issues/19

与此同时,您可以通过直接使用底层 http 客户端来解决这个问题。此代码查询工作区中的所有项目,然后找到组合项的类型定义,然后为每个项目通过scopedattributeddefinition端点获取所有自定义属性定义并打印出它们的隐藏/必需状态。

    QueryRequest projectQuery = new QueryRequest("project");
    projectQuery.setLimit(Integer.MAX_VALUE);
    QueryResponse projectResponse = restApi.query(projectQuery);

    QueryRequest typeDefQuery = new QueryRequest("typedefinition");
    typeDefQuery.setQueryFilter(new QueryFilter("Name", "=", "Portfolio Item"));
    QueryResponse typeDefResponse = restApi.query(typeDefQuery);
    JsonObject piTypeDef = typeDefResponse.getResults().get(0).getAsJsonObject();

    for(JsonElement projectResult : projectResponse.getResults()) {
        JsonObject project = projectResult.getAsJsonObject();
        System.out.println("Project: " + project.get("Name").getAsString());

        //Begin hackery (note we're not handling multiple pages-
        // if you have more than 200 custom attributes you'll have to page
        String scopedAttributeDefUrl = "/project/" + project.get("ObjectID").getAsLong() +
            "/typedefinition/" + piTypeDef.get("ObjectID").getAsLong() + "/scopedattributedefinition" +
            "?fetch=Hidden,Required,Name&query=" + URLEncoder.encode("(Custom = true)", "utf-8");
        String attributes = restApi.getClient().doGet(scopedAttributeDefUrl);
        QueryResponse attributeResponse = new QueryResponse(attributes);
        //End hackery

        for(JsonElement customAttributeResult : attributeResponse.getResults()) {
            JsonObject customAttribute = customAttributeResult.getAsJsonObject();
            System.out.print("\tAttribute: " + customAttribute.get("Name").getAsString());
            System.out.print(", Hidden: " + customAttribute.get("Hidden").getAsBoolean());
            System.out.println(", Required: " + customAttribute.get("Required").getAsBoolean());
        }
        System.out.println();
    }

您想要的每个自定义字段的任何其他信息都应该可以通过从 piTypeDef 查询 Attributes 集合来访问。

关于java - RallyRestAPI 查询 ScopedAttributeDefinition 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33812317/

相关文章:

javascript - 使用APP SDK 2.1获取迭代的用户故事集合

java - Eclipse 间歇性无法创建 Java 虚拟机

java - 使用 Netbeans 8.0.2 并希望使用 org.apache.commons.io.FileUtils;如何?

ios - 从 Swift 函数中的异步调用返回数据

java - 未调用自定义注释

javascript - 拉力赛应用程序 SDK 2.0 : Call to validate() by managed listener in rallymultiobjectpicker re-filters store

java - 对于在静态哈希表上同步的 java.util.Calendar 构造函数,我们可以做些什么?

java - 有效用户的 Tomcat 安全约束

java - 网络服务+安卓

javascript - Rally 自定义应用程序复选框过滤器不起作用