简体   繁体   English

从jira soap api迁移到jira rest api:getCustomFieldValues的问题

[英]migrating from jira soap api to jira rest api: issues with getCustomFieldValues

I am working on migrating some code from Jira Soap Api to Jira Rest API. 我正在将一些代码从Jira Soap Api迁移到Jira Rest API。 I have a line of the legacy code that looks like: 我有一排旧代码看起来像:

String estimationTypes = issue.getCustomFieldValues().find{it.customfieldId == SOME_STRING_VALUE_HERE}?.values.toString()

The issue variable is of type com.atlassian.jira.rpc.soap.beans.RemoteIssue and I am trying to migrate it and use an implementation of the new Issue interface ( com.atlassian.jira.issue.Issue ), and so I am looking for an equivalent of the getCustomFieldValues() method that is defined as issue变量的类型为com.atlassian.jira.rpc.soap.beans.RemoteIssue ,我正尝试对其进行迁移并使用新的Issue接口的实现( com.atlassian.jira.issue.Issue ),因此我正在寻找等效的getCustomFieldValues()方法,该方法定义为

public RemoteCustomFieldValue[] getCustomFieldValues() {
        return this.customFieldValues;
    } 

But I did not find it. 但是我没有找到它。 the Issue interface defines the Object getCustomFieldValue(CustomField customField) which is not the same. Issue接口定义的Object getCustomFieldValue(CustomField customField)是不相同的。 So how could I use a method equivalent to getCustomFieldValues ? 那么,如何使用与getCustomFieldValues等效的方法呢?

I guess if I had a method like 我想我是否有类似的方法

List<CustomField> getCustomFields() then I would be able to create a method: something like List<CustomField> getCustomFields()然后我将能够创建一个方法:

public List<Object> getCustomFieldValues() {
   List<Object> result = new ArrayList<>()
   List<CustomField> customFields = getCustomFields()
   for(CustomField cs: customFields) {
      result.add(issue.getCustomFieldValue(cs))
   }
   return result       
}

My goal is to make the migration with the minimum possible impact on the legacy code. 我的目标是使迁移对旧代码的影响降到最低。 There I would like to be able to mimic the behavior of the legacy code as much as possible. 我希望在那里能够尽可能地模仿遗留代码的行为。 Any help or indication is highly appreciated. 任何帮助或表示高度赞赏。

After a lot of research and curling in one of the most interesting APIs I ever used, I find some very usefull informations on Atlassian knowledge base here . 经过大量研究和对我曾经使用过的最有趣的API的研究,我在这里找到了有关Atlassian知识库的一些非常有用的信息。 The text is targeting a multi - select custom field but is usefull for other types of custom fields as well. 文本针对多个选择自定义字段,但对其他类型的自定义字段也很有用。

It mentions clearly that JIRA's REST API doesn't provide a method to simply retrieve all the options available to a multi-option custom field . 它清楚地提到JIRA的REST API没有提供一种方法来简单地检索可用于多选项自定义字段的所有选项 The approach used here is therefore considered a workaround. 因此,此处使用的方法被认为是一种解决方法。 So we can use 所以我们可以使用

  • The create issue meta api ( here ) 创建问题元API( 此处
  • Or the edit issue meta api ( here ) 或编辑问题元API( 此处

显示自定义字段允许的值

Following the two meta apis links, the parameters from the create meta api are simple but in the case of the edit meta api there is one request parameter called overrideScreenSecurity that is related to add-on users and a direct access to the add-ons market place from the web interface, but does is not relevant in my case and the default (false) value is fine for me. 通过这两个meta api链接,来自create meta api的参数很简单,但是在edit meta api的情况下,有一个名为overrideScreenSecurity请求参数,该参数与附加用户和直接访问附加市场有关从Web界面放置,但与我的情况无关,默认(false)值对我来说很好。

From here I can parse the json to get the values 从这里我可以解析json以获取值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM