[英]Atlassian JIRA gadget REST API
我編寫了一個JIRA小工具,該工具會先對JIRA REST API進行AJAX調用,然后再使用數據。 創建日期,解決日期和狀態來創建兩個單獨的數組,這些數組分別保存數據,如下所示:
var dateCreated;
dateCreated =[[<created>, <daily total>],...];
因此,如果在“ 2011-1-1”上創建了兩個問題,則數組的元素塊為
[ [‘2011-1-1’, 2],...]
另一個數組是:
var statusDate;
statusDate=[[<resolutiondate>, <daily total>],...]
因此,如果在“ 2011-1-1”上創建了兩個問題,則數組的元素塊為
[ [‘2011-1-1’, 2],...]
我使用JIRA小工具中的ajaxOptions進行AJAX調用,並且能夠使用Javascript獲取數據並進行數組操作,並將數據繪制為在時序圖上創建和關閉的全部問題。 但是,有些項目比其他項目有更多問題,將數據加載到圖表中大約需要30秒。 有了JIRA,我可以使用后端服務器腳本,該腳本可以在將數據移植到基於html的圖表並加載到客戶端計算機上的數據之前,在服務器端進行數組操作? 我聽說過JIRA中的Velocity模板,但是我不確定這是否是解決方案之一,而且很難找到有關JIRA和Velocity模板的示例。
任何幫助表示贊賞。
提前致謝
這是JIRA(或您自己的REST服務)的使用速度模板的示例。
從UI到REST服務進行ajax調用,您將獲得所需的html內容(或其他數據)。 HtmlPresentationHelper類用作html數據的包裝。
您可以使用Jira集成工具調試此(或您的)REST服務: REST API瀏覽器 : https : //developer.atlassian.com/display/DOCS/Using+the+REST+API+Browser/
並且不要忘記添加您的Velocity模板!
@Path("/")
public class CustomRestResource
{
private String pathToTemplate = "templates/reports/timesheet-report/";
private String templateFileName = "view.vm";
@GET
@Path("someMethod")
@AnonymousAllowed
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response anyName(@QueryParam("param") String param)
{
VelocityManager vm = ComponentAccessor.getVelocityManager();
try
{
return Response.ok(new HtmlPresentationHelper(
vm.getBody(pathToTemplate, templateFileName, prepareVelocityParams(param))
)).build();
}
catch (Exception ex)
{
ex.printStackTrace();
return Response.serverError().build();
}
}
Map<String, Object> prepareVelocityParams(String x)
{
Map<String, Object> velocityParams = new HashMap<String, Object>();
velocityParams.put("someParam", x);
velocityParams.put(...);
...
return velocityParams;
}
}
@XmlRootElement
public class HtmlPresentationHelper
{
@XmlElement
private String html;
private HtmlPresentationHelper()
{
// for JAXB
}
public HtmlPresentationHelper(String html)
{
this.html = html;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.