gpt4 book ai didi

java - 编写 Jira 插件 : how to find issues changed after a given date?

转载 作者:太空宇宙 更新时间:2023-11-04 09:10:04 27 4
gpt4 key购买 nike

我正在为 Jira 编写一个插件。我需要查找给定日期之后更改的问题。请告诉我,我该怎么做。

IssueManager 只能通过 ID 和 ID 列表查找问题。

最佳答案

@Component
public class Utils{

@ComponentImport
private SearchProvider searchProvider;

@ComponentImport
private UserManager userManager;

@ComponentImport
private IssueManager issueManager;


@Inject
public Utils( IssueManager issueManager, UserManager userManager, SearchProvider searchProvider ){
this.issueManager = issueManager;
this.userManager = userManager;
this.searchProvider = searchProvider;
...
}

...

public List<Issue> getIssuesByDateUpdateAfter( Date dTime ) throws SearchException{
JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
builder.where().addDateCondition( IssueFieldConstants.UPDATED, Operator.GREATER_THAN_EQUALS, dTime );
return searchIssues( builder.buildQuery() );
}

public List<Issue> searchIssues( Query query ){
ApplicationUser user = userManager.getUserByName( username );
SearchQuery searchQuery = SearchQuery.create( query, user );
IssueIdCollector collector = new IssueIdCollector();
try{
ThreadLocalSearcherCache.startSearcherContext();
searchProvider.search( searchQuery, collector );
}catch( Exception e ){
e.getMessage();
}finally{
ThreadLocalSearcherCache.stopAndCloseSearcherContext();
}
return searchIssues(collector);
}

public List<Issue> searchIssues(IssueIdCollector collector){
Set<String> strIds = collector.getIssueIds();
List<Long> ids = new ArrayList<>();
for( String strId : strIds ){
ids.add( Long.parseLong( strId ) );
}
return issueManager.getIssueObjects( ids );
}

...
}

关于java - 编写 Jira 插件 : how to find issues changed after a given date?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59756567/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com