1
0
Fork 0

minor clean up and retab

master
Bob Carroll 2015-01-25 19:17:10 -08:00
parent c6c9f7ec5d
commit 9095944c98
6 changed files with 128 additions and 147 deletions

View File

@ -143,24 +143,13 @@ public class Issue extends Resource {
}
/**
* Search for issues with the given query and specify which fields to
* retrieve.
* count issues with the given query.
*
* @param restclient REST client instance
*
* @param jql JQL statement
*
* @param includedFields Specifies which issue fields will be included in
* the result.
* <br>Some examples how this parameter works:
* <ul>
* <li>*all - include all fields</li>
* <li>*navigable - include just navigable fields</li>
* <li>summary,comment - include just the summary and comments</li>
* <li>*all,-comment - include all fields</li>
* </ul>
*
* @return a search result structure with results
* @return the count
*
* @throws JiraException when the search fails
*/

View File

@ -17,7 +17,7 @@ public class IssueHistory extends Resource {
private Date created;
/**
* Creates a priority from a JSON payload.
* Creates an issue history record from a JSON payload.
*
* @param restclient REST client instance
* @param json JSON payload
@ -29,12 +29,6 @@ public class IssueHistory extends Resource {
deserialise(restclient,json);
}
}
/*
{"id":"150478","author":{"self":"http://jira.devops.northplains.com:8080/rest/api/2/user?username=rbagga","name":"rbagga","emailAddress":"rbagga@northplains.com","avatarUrls":{"16x16":"http://jira.devops.northplains.com:8080/secure/useravatar?size=small&avatarId=10113","48x48":"http://jira.devops.northplains.com:8080/secure/useravatar?avatarId=10113"},
"displayName":"Rajpaul Bagga","active":true},
"created":"2013-09-25T08:44:19.250-0400",
"items":[...]}
*/
public IssueHistory(IssueHistory record, ArrayList<IssueHistoryItem> changes) {
super(record.restclient);

View File

@ -12,9 +12,6 @@ public class IssueHistoryItem extends Resource {
private String fromStr;
private String toStr;
/*
* {"field":"assignee","fieldtype":"jira","from":"rbagga","fromString":"Rajpaul Bagga","to":"GGadyatskiy","toString":"Gleb Gadyatskiy"}
*/
public IssueHistoryItem(RestClient restclient) {
super(restclient);
}

View File

@ -148,6 +148,8 @@ public class JiraClient {
*
* @param jql JQL statement
*
* @return the count
*
* @throws JiraException when the search fails
*/
public int countIssues(String jql) throws JiraException {
@ -341,6 +343,7 @@ public class JiraClient {
return Issue.search(restclient, jql, includedFields, expandFields, maxResults,
startAt);
}
/**
*
* @return a list of all priorities available in the Jira installation
@ -502,14 +505,10 @@ public class JiraClient {
return Component.get(restclient, id);
}
/**
*
* @return a list of all priorities available in the Jira installation
* @throws JiraException
*/
public ArrayList<IssueHistory> filterChangeLog(List<IssueHistory> histoy,String fields) {
ArrayList<IssueHistory> result = new ArrayList<IssueHistory>(histoy.size());
fields = "," + fields + ",";
for (IssueHistory record : histoy) {
ArrayList<IssueHistoryItem> list = new ArrayList<IssueHistoryItem>(record.getChanges().size());
for (IssueHistoryItem item : record.getChanges()) {
@ -517,34 +516,35 @@ public class JiraClient {
list.add(item);
}
}
if (list.size() > 0) {
result.add(new IssueHistory(record,list));
}
}
return result;
}
/**
*
* @return a list of all priorities available in the Jira installation
* @throws JiraException
*/
public ArrayList<IssueHistory> getIssueChangeLog(Issue issue) throws JiraException {
try {
ArrayList<IssueHistory> changes = null;
JSON response = getNextPortion(issue, 0);
while (true) {
JSONObject object = JSONObject.fromObject(response);
Object opers = object.get("changelog");
object = JSONObject.fromObject(opers);
Integer totalObj = (Integer)object.get("total");
JSONArray histories = JSONArray.fromObject(object.get("histories"));
if (changes == null) {
changes = new ArrayList<IssueHistory>(totalObj);
}
for (int i = 0; i < histories.size(); i++) {
JSONObject p = histories.getJSONObject(i);
changes.add(new IssueHistory(restclient, p));
}
if (changes.size() >= totalObj) {
break;
} else {
@ -558,15 +558,16 @@ public class JiraClient {
}
}
private JSON getNextPortion(Issue issue,Integer startAt) throws URISyntaxException, RestException, IOException {
private JSON getNextPortion(Issue issue, Integer startAt)
throws URISyntaxException, RestException, IOException {
Map<String, String> params = new HashMap<String, String>();
if (startAt != null) {
params.put("startAt", String.valueOf(startAt));
}
params.put("expand","changelog.fields");
URI uri = restclient.buildURI(Issue.getBaseUri() + "issue/" + issue.id, params);
return restclient.get(uri);
}
}