简体   繁体   English

如何使用第一版Java REST客户端将第一版工作URL(端点)转换为Java查询

[英]How to convert version one working url(endpoint) to java query using version one java REST client

I need to convert below working REST endpoint to java query 我需要将以下工作的REST端点转换为Java查询

/rest-1.v1/Data/Timebox?Where=Schedule.ScheduledScopes.Name="Sample: Call Center Product"&sel=Workitems:Defect[AssetState='Closed'].Estimate.@Sum,Name,Workitems:Story[AssetState='Closed'].Estimate.@Sum /rest-1.v1/Data/Timebox?Where=Schedule.ScheduledScopes.Name=“示例:呼叫中心产品”&sel = Workitems:Defect [AssetState ='Closed']。Estimate。@ Sum,Name,Workitems:Story [ AssetState =“已关闭”] .Estimate。@ Sum

My Not working Code: 我的无效代码:

IAssetType storyType = services.getMeta().getAssetType("Timebox");
        Query query = new Query(storyType, true);
        IAttributeDefinition name = storyType.getAttributeDefinition("Name");
        IAttributeDefinition defect_estimate = storyType.getAttributeDefinition("Workitems:Defect[AssetState='Closed'].Estimate.@Sum");
        IAttributeDefinition story_estimate = storyType.getAttributeDefinition("Workitems:Story[AssetState='Closed'].Estimate.@Sum");
        query.getSelection().add(name);
        query.getSelection().add(defect_estimate);
        query.getSelection().add(story_estimate);
        //IFilterTerm activeSprint = new TokenTerm("State.Code='ACTV'");
        IFilterTerm activeSprint = new TokenTerm("Schedule.ScheduledScopes.Name='Sample: Call Center Product'");
        query.setFilter(activeSprint);        
        DefaultCategoryDataset dataset = new DefaultCategoryDataset( );
        QueryResult result = services.retrieve(query);

Error i am getting: 我得到的错误:

Exception in thread "main" com.versionone.apiclient.exceptions.MetaException: Unknown AttributeDefinition: Timebox.Workitems:Defect[AssetState='Closed'].Estimate.@Sum
at com.versionone.apiclient.MetaModel.getAttributeDefinition(MetaModel.java:119)
at com.versionone.apiclient.AssetType.getAttributeDefinition(AssetType.java:96)
at v1_rest_intig.Example1.main(Example1.java:230)

what am i doing wrong?? 我究竟做错了什么?? any guidance is of great help 任何指导都是有很大帮助的

Thanks in advance 提前致谢

You are using the right attribute definition, but apparently, at some version of the API they stop translating symbols, like brakets '[' into the URL encoding ( '%5B' for open bracket) and therefore the resulting error message. 您使用的是正确的属性定义,但是很显然,在某些版本的API上,它们停止将符号转换,例如将文本'['转换为URL编码(括号为'%5B'),并因此导致错误消息。

Please, try this instead: 请尝试以下方法:

Workitems:Defect%5BAssetState=%27128%27%5D 工作项:缺陷%5BAssetState =%27128%27%5D

for your attributes definition for the Defect/Story AssetType. 定义“缺陷/故事资产类型”的属性。

Let me know if this works. 让我知道这个是否奏效。

TIA, TIA,

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

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