From df163bb610a38a053719933290e42428e0e42d00 Mon Sep 17 00:00:00 2001 From: gadyag Date: Tue, 21 Nov 2017 13:48:21 -0500 Subject: [PATCH 1/5] Green Hopper returns in-completed issues as 2 lists: issuesNotCompletedInCurrentSprint and issuesCompletedInAnotherSprint --- .../net/rcarz/jiraclient/IssueHistory.java | 136 +++++++++--------- .../rcarz/jiraclient/IssueHistoryItem.java | 114 +++++++-------- .../jiraclient/greenhopper/SprintReport.java | 37 +++-- 3 files changed, 151 insertions(+), 136 deletions(-) diff --git a/src/main/java/net/rcarz/jiraclient/IssueHistory.java b/src/main/java/net/rcarz/jiraclient/IssueHistory.java index 1c0dd508..ce1114f9 100644 --- a/src/main/java/net/rcarz/jiraclient/IssueHistory.java +++ b/src/main/java/net/rcarz/jiraclient/IssueHistory.java @@ -1,68 +1,68 @@ -package net.rcarz.jiraclient; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -public class IssueHistory extends Resource { - - private static final long serialVersionUID = 1L; - private User user; - private ArrayList changes; - private Date created; - - /** - * Creates an issue history record from a JSON payload. - * - * @param restclient REST client instance - * @param json JSON payload - */ - protected IssueHistory(RestClient restclient, JSONObject json) { - super(restclient); - - if (json != null) { - deserialise(restclient,json); - } - } - - public IssueHistory(IssueHistory record, ArrayList changes) { - super(record.restclient); - user = record.user; - id = record.id; - self = record.self; - created = record.created; - this.changes = changes; - } - - private void deserialise(RestClient restclient, JSONObject json) { - Map map = json; - self = Field.getString(map.get("self")); - id = Field.getString(map.get("id")); - user = new User(restclient,(JSONObject)map.get("author")); - created = Field.getDateTime(map.get("created")); - JSONArray items = JSONArray.fromObject(map.get("items")); - changes = new ArrayList(items.size()); - for (int i = 0; i < items.size(); i++) { - JSONObject p = items.getJSONObject(i); - changes.add(new IssueHistoryItem(restclient, p)); - } - } - - public User getUser() { - return user; - } - - public ArrayList getChanges() { - return changes; - } - - public Date getCreated() { - return created; - } - -} +package net.rcarz.jiraclient; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class IssueHistory extends Resource { + + private static final long serialVersionUID = 1L; + private User user; + private ArrayList changes; + private Date created; + + /** + * Creates an issue history record from a JSON payload. + * + * @param restclient REST client instance + * @param json JSON payload + */ + protected IssueHistory(RestClient restclient, JSONObject json) { + super(restclient); + + if (json != null) { + deserialise(restclient,json); + } + } + + public IssueHistory(IssueHistory record, ArrayList changes) { + super(record.restclient); + user = record.user; + id = record.id; + self = record.self; + created = record.created; + this.changes = changes; + } + + private void deserialise(RestClient restclient, JSONObject json) { + Map map = json; + self = Field.getString(map.get("self")); + id = Field.getString(map.get("id")); + user = new User(restclient,(JSONObject)map.get("author")); + created = Field.getDateTime(map.get("created")); + JSONArray items = JSONArray.fromObject(map.get("items")); + changes = new ArrayList(items.size()); + for (int i = 0; i < items.size(); i++) { + JSONObject p = items.getJSONObject(i); + changes.add(new IssueHistoryItem(restclient, p)); + } + } + + public User getUser() { + return user; + } + + public ArrayList getChanges() { + return changes; + } + + public Date getCreated() { + return created; + } + +} diff --git a/src/main/java/net/rcarz/jiraclient/IssueHistoryItem.java b/src/main/java/net/rcarz/jiraclient/IssueHistoryItem.java index 0373dfc2..cb046f0c 100644 --- a/src/main/java/net/rcarz/jiraclient/IssueHistoryItem.java +++ b/src/main/java/net/rcarz/jiraclient/IssueHistoryItem.java @@ -1,57 +1,57 @@ -package net.rcarz.jiraclient; - -import java.util.Map; - -import net.sf.json.JSONObject; - -public class IssueHistoryItem extends Resource { - - private String field; - private String from; - private String to; - private String fromStr; - private String toStr; - - public IssueHistoryItem(RestClient restclient) { - super(restclient); - } - - public IssueHistoryItem(RestClient restclient, JSONObject json) { - this(restclient); - if (json != null) { - deserialise(restclient,json); - } - } - - private void deserialise(RestClient restclient, JSONObject json) { - Map map = json; - self = Field.getString(map.get("self")); - id = Field.getString(map.get("id")); - field = Field.getString(map.get("field")); - from = Field.getString(map.get("from")); - to = Field.getString(map.get("to")); - fromStr = Field.getString(map.get("fromString")); - toStr = Field.getString(map.get("toString")); - } - - public String getField() { - return field; - } - - public String getFrom() { - return from; - } - - public String getTo() { - return to; - } - - public String getFromStr() { - return fromStr; - } - - public String getToStr() { - return toStr; - } - -} +package net.rcarz.jiraclient; + +import java.util.Map; + +import net.sf.json.JSONObject; + +public class IssueHistoryItem extends Resource { + + private String field; + private String from; + private String to; + private String fromStr; + private String toStr; + + public IssueHistoryItem(RestClient restclient) { + super(restclient); + } + + public IssueHistoryItem(RestClient restclient, JSONObject json) { + this(restclient); + if (json != null) { + deserialise(restclient,json); + } + } + + private void deserialise(RestClient restclient, JSONObject json) { + Map map = json; + self = Field.getString(map.get("self")); + id = Field.getString(map.get("id")); + field = Field.getString(map.get("field")); + from = Field.getString(map.get("from")); + to = Field.getString(map.get("to")); + fromStr = Field.getString(map.get("fromString")); + toStr = Field.getString(map.get("toString")); + } + + public String getField() { + return field; + } + + public String getFrom() { + return from; + } + + public String getTo() { + return to; + } + + public String getFromStr() { + return fromStr; + } + + public String getToStr() { + return toStr; + } + +} diff --git a/src/main/java/net/rcarz/jiraclient/greenhopper/SprintReport.java b/src/main/java/net/rcarz/jiraclient/greenhopper/SprintReport.java index 8d8d61f5..7669dc86 100644 --- a/src/main/java/net/rcarz/jiraclient/greenhopper/SprintReport.java +++ b/src/main/java/net/rcarz/jiraclient/greenhopper/SprintReport.java @@ -19,16 +19,15 @@ package net.rcarz.jiraclient.greenhopper; -import net.rcarz.jiraclient.Field; -import net.rcarz.jiraclient.Issue; -import net.rcarz.jiraclient.JiraException; -import net.rcarz.jiraclient.RestClient; - import java.net.URI; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import net.rcarz.jiraclient.Field; +import net.rcarz.jiraclient.JiraException; +import net.rcarz.jiraclient.RestClient; import net.sf.json.JSON; import net.sf.json.JSONObject; @@ -40,13 +39,15 @@ public class SprintReport { private RestClient restclient = null; private Sprint sprint = null; private List completedIssues = null; - private List incompletedIssues = null; private List puntedIssues = null; private EstimateSum completedIssuesEstimateSum = null; private EstimateSum incompletedIssuesEstimateSum = null; private EstimateSum allIssuesEstimateSum = null; private EstimateSum puntedIssuesEstimateSum = null; private List issueKeysAddedDuringSprint = null; + private EstimateSum issuesCompletedInAnotherSprintInitialEstimateSum; + private List issuesCompletedInAnotherSprint; + private List issuesNotCompletedInCurrentSprint; /** * Creates a sprint report from a JSON payload. @@ -69,10 +70,14 @@ private void deserialise(JSONObject json) { SprintIssue.class, map.get("completedIssues"), restclient); - incompletedIssues = GreenHopperField.getResourceArray( + issuesNotCompletedInCurrentSprint = GreenHopperField.getResourceArray( SprintIssue.class, - map.get("incompletedIssues"), + map.get("issuesNotCompletedInCurrentSprint"), restclient); + issuesCompletedInAnotherSprint = GreenHopperField.getResourceArray( + SprintIssue.class, + map.get("issuesCompletedInAnotherSprint"), + restclient); puntedIssues = GreenHopperField.getResourceArray( SprintIssue.class, map.get("puntedIssues"), @@ -81,12 +86,15 @@ private void deserialise(JSONObject json) { map.get("completedIssuesEstimateSum")); incompletedIssuesEstimateSum = GreenHopperField.getEstimateSum( map.get("incompletedIssuesEstimateSum")); + issuesCompletedInAnotherSprintInitialEstimateSum = GreenHopperField.getEstimateSum( + map.get("issuesCompletedInAnotherSprintInitialEstimateSum")); allIssuesEstimateSum = GreenHopperField.getEstimateSum( map.get("allIssuesEstimateSum")); puntedIssuesEstimateSum = GreenHopperField.getEstimateSum( map.get("puntedIssuesEstimateSum")); - issueKeysAddedDuringSprint = GreenHopperField.getStringArray( - map.get("issueKeysAddedDuringSprint")); + //JIRA-1234,true + Map added = Field.getMap(String.class, Boolean.class, map.get("issueKeysAddedDuringSprint")); + issueKeysAddedDuringSprint = new ArrayList<>(added.keySet()); } /** @@ -139,9 +147,16 @@ public List getCompletedIssues() { } public List getIncompletedIssues() { - return incompletedIssues; + return issuesNotCompletedInCurrentSprint; } + public List getIssuesCompletedInAnotherSprint() { + return issuesCompletedInAnotherSprint; + } + public EstimateSum getIssuesCompletedInAnotherSprintInitialEstimateSum() { + return issuesCompletedInAnotherSprintInitialEstimateSum; + } + public List getPuntedIssues() { return puntedIssues; } From 2bdda78d45bae2624438904f3e3fc5b9c11bf806 Mon Sep 17 00:00:00 2001 From: gadyag Date: Tue, 21 Nov 2017 19:13:10 -0500 Subject: [PATCH 2/5] Rollback changes in IssueHistory and IssueHistoryItem --- .../net/rcarz/jiraclient/IssueHistory.java | 136 +++++++++--------- .../rcarz/jiraclient/IssueHistoryItem.java | 114 +++++++-------- 2 files changed, 125 insertions(+), 125 deletions(-) diff --git a/src/main/java/net/rcarz/jiraclient/IssueHistory.java b/src/main/java/net/rcarz/jiraclient/IssueHistory.java index ce1114f9..1c0dd508 100644 --- a/src/main/java/net/rcarz/jiraclient/IssueHistory.java +++ b/src/main/java/net/rcarz/jiraclient/IssueHistory.java @@ -1,68 +1,68 @@ -package net.rcarz.jiraclient; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -public class IssueHistory extends Resource { - - private static final long serialVersionUID = 1L; - private User user; - private ArrayList changes; - private Date created; - - /** - * Creates an issue history record from a JSON payload. - * - * @param restclient REST client instance - * @param json JSON payload - */ - protected IssueHistory(RestClient restclient, JSONObject json) { - super(restclient); - - if (json != null) { - deserialise(restclient,json); - } - } - - public IssueHistory(IssueHistory record, ArrayList changes) { - super(record.restclient); - user = record.user; - id = record.id; - self = record.self; - created = record.created; - this.changes = changes; - } - - private void deserialise(RestClient restclient, JSONObject json) { - Map map = json; - self = Field.getString(map.get("self")); - id = Field.getString(map.get("id")); - user = new User(restclient,(JSONObject)map.get("author")); - created = Field.getDateTime(map.get("created")); - JSONArray items = JSONArray.fromObject(map.get("items")); - changes = new ArrayList(items.size()); - for (int i = 0; i < items.size(); i++) { - JSONObject p = items.getJSONObject(i); - changes.add(new IssueHistoryItem(restclient, p)); - } - } - - public User getUser() { - return user; - } - - public ArrayList getChanges() { - return changes; - } - - public Date getCreated() { - return created; - } - -} +package net.rcarz.jiraclient; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class IssueHistory extends Resource { + + private static final long serialVersionUID = 1L; + private User user; + private ArrayList changes; + private Date created; + + /** + * Creates an issue history record from a JSON payload. + * + * @param restclient REST client instance + * @param json JSON payload + */ + protected IssueHistory(RestClient restclient, JSONObject json) { + super(restclient); + + if (json != null) { + deserialise(restclient,json); + } + } + + public IssueHistory(IssueHistory record, ArrayList changes) { + super(record.restclient); + user = record.user; + id = record.id; + self = record.self; + created = record.created; + this.changes = changes; + } + + private void deserialise(RestClient restclient, JSONObject json) { + Map map = json; + self = Field.getString(map.get("self")); + id = Field.getString(map.get("id")); + user = new User(restclient,(JSONObject)map.get("author")); + created = Field.getDateTime(map.get("created")); + JSONArray items = JSONArray.fromObject(map.get("items")); + changes = new ArrayList(items.size()); + for (int i = 0; i < items.size(); i++) { + JSONObject p = items.getJSONObject(i); + changes.add(new IssueHistoryItem(restclient, p)); + } + } + + public User getUser() { + return user; + } + + public ArrayList getChanges() { + return changes; + } + + public Date getCreated() { + return created; + } + +} diff --git a/src/main/java/net/rcarz/jiraclient/IssueHistoryItem.java b/src/main/java/net/rcarz/jiraclient/IssueHistoryItem.java index cb046f0c..0373dfc2 100644 --- a/src/main/java/net/rcarz/jiraclient/IssueHistoryItem.java +++ b/src/main/java/net/rcarz/jiraclient/IssueHistoryItem.java @@ -1,57 +1,57 @@ -package net.rcarz.jiraclient; - -import java.util.Map; - -import net.sf.json.JSONObject; - -public class IssueHistoryItem extends Resource { - - private String field; - private String from; - private String to; - private String fromStr; - private String toStr; - - public IssueHistoryItem(RestClient restclient) { - super(restclient); - } - - public IssueHistoryItem(RestClient restclient, JSONObject json) { - this(restclient); - if (json != null) { - deserialise(restclient,json); - } - } - - private void deserialise(RestClient restclient, JSONObject json) { - Map map = json; - self = Field.getString(map.get("self")); - id = Field.getString(map.get("id")); - field = Field.getString(map.get("field")); - from = Field.getString(map.get("from")); - to = Field.getString(map.get("to")); - fromStr = Field.getString(map.get("fromString")); - toStr = Field.getString(map.get("toString")); - } - - public String getField() { - return field; - } - - public String getFrom() { - return from; - } - - public String getTo() { - return to; - } - - public String getFromStr() { - return fromStr; - } - - public String getToStr() { - return toStr; - } - -} +package net.rcarz.jiraclient; + +import java.util.Map; + +import net.sf.json.JSONObject; + +public class IssueHistoryItem extends Resource { + + private String field; + private String from; + private String to; + private String fromStr; + private String toStr; + + public IssueHistoryItem(RestClient restclient) { + super(restclient); + } + + public IssueHistoryItem(RestClient restclient, JSONObject json) { + this(restclient); + if (json != null) { + deserialise(restclient,json); + } + } + + private void deserialise(RestClient restclient, JSONObject json) { + Map map = json; + self = Field.getString(map.get("self")); + id = Field.getString(map.get("id")); + field = Field.getString(map.get("field")); + from = Field.getString(map.get("from")); + to = Field.getString(map.get("to")); + fromStr = Field.getString(map.get("fromString")); + toStr = Field.getString(map.get("toString")); + } + + public String getField() { + return field; + } + + public String getFrom() { + return from; + } + + public String getTo() { + return to; + } + + public String getFromStr() { + return fromStr; + } + + public String getToStr() { + return toStr; + } + +} From b57f1a00b23981c5b40fa7f60b1fd3939c5afcdb Mon Sep 17 00:00:00 2001 From: gadyag Date: Sat, 25 Nov 2017 09:17:33 -0500 Subject: [PATCH 3/5] Rapid Board Configuration support added --- .../java/net/rcarz/jiraclient/Resource.java | 1 + .../java/net/rcarz/jiraclient/Status.java | 31 +++++ .../net/rcarz/jiraclient/agile/Board.java | 8 ++ .../rcarz/jiraclient/agile/BoardColumn.java | 47 +++++++ .../jiraclient/agile/BoardConfiguration.java | 131 ++++++++++++++++++ .../agile/BoardConfigurationTest.java | 25 ++++ 6 files changed, 243 insertions(+) create mode 100644 src/main/java/net/rcarz/jiraclient/agile/BoardColumn.java create mode 100644 src/main/java/net/rcarz/jiraclient/agile/BoardConfiguration.java create mode 100644 src/test/java/net/rcarz/jiraclient/agile/BoardConfigurationTest.java diff --git a/src/main/java/net/rcarz/jiraclient/Resource.java b/src/main/java/net/rcarz/jiraclient/Resource.java index b59ca736..9183c8c8 100644 --- a/src/main/java/net/rcarz/jiraclient/Resource.java +++ b/src/main/java/net/rcarz/jiraclient/Resource.java @@ -88,5 +88,6 @@ public String getUrl() { public String getSelf() { return self; } + } diff --git a/src/main/java/net/rcarz/jiraclient/Status.java b/src/main/java/net/rcarz/jiraclient/Status.java index 757a8ab6..7401659d 100644 --- a/src/main/java/net/rcarz/jiraclient/Status.java +++ b/src/main/java/net/rcarz/jiraclient/Status.java @@ -19,9 +19,12 @@ package net.rcarz.jiraclient; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import net.sf.json.JSON; +import net.sf.json.JSONArray; import net.sf.json.JSONObject; /** @@ -55,6 +58,34 @@ private void deserialise(JSONObject json) { iconUrl = Field.getString(map.get("iconUrl")); name = Field.getString(map.get("name")); } + + /** + * Retrieves all boards visible to the session user. + * + * @param restclient REST client instance + * @return a list of boards + * @throws JiraException when the retrieval fails + */ + public static List getAll(RestClient restclient) throws JiraException { + JSON result = null; + + try { + result = restclient.get(getBaseUri() + "status"); + } catch (Exception ex) { + throw new JiraException("Failed to retrieve statuses ", ex); + } + + if (!(result instanceof JSONArray)) + throw new JiraException("JSON payload is malformed"); + + JSONArray array = (JSONArray) result; + List results = new ArrayList(array.size()); + for (int i = 0; i < array.size(); i++) { + JSONObject row = array.getJSONObject(i); + results.add(new Status(restclient, row)); + } + return results; + } /** * Retrieves the given status record. diff --git a/src/main/java/net/rcarz/jiraclient/agile/Board.java b/src/main/java/net/rcarz/jiraclient/agile/Board.java index 4db6aeca..e0a39a6c 100644 --- a/src/main/java/net/rcarz/jiraclient/agile/Board.java +++ b/src/main/java/net/rcarz/jiraclient/agile/Board.java @@ -89,6 +89,14 @@ public List getSprints() throws JiraException { return Sprint.getAll(getRestclient(), getId()); } + /** + * @return Configuarion the current board. + * @throws JiraException when the retrieval fails + */ + public BoardConfiguration getConfiguarion() throws JiraException { + return BoardConfiguration.get(getRestclient(), getId()); + } + /** * @return All issues in the Board backlog. * @throws JiraException when the retrieval fails diff --git a/src/main/java/net/rcarz/jiraclient/agile/BoardColumn.java b/src/main/java/net/rcarz/jiraclient/agile/BoardColumn.java new file mode 100644 index 00000000..eae7b429 --- /dev/null +++ b/src/main/java/net/rcarz/jiraclient/agile/BoardColumn.java @@ -0,0 +1,47 @@ +package net.rcarz.jiraclient.agile; + +import java.util.ArrayList; +import java.util.List; + +import net.rcarz.jiraclient.JiraException; +import net.rcarz.jiraclient.RestClient; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class BoardColumn extends AgileResource { + + private List statuses; + + public BoardColumn(RestClient restclient, JSONObject json) throws JiraException { + super(restclient, json); + } + + /** + * Deserialize the json to extract standard attributes and keep a reference of + * other attributes. + * + * @param json The JSON object to read. + */ + @Override + void deserialize(JSONObject json) throws JiraException { + super.deserialize(json); + setName(json.getString("name")); + JSONArray statusesJSON = json.getJSONArray("statuses"); + statuses = new ArrayList<>(statusesJSON.size()); + for (int i = 0; i < statusesJSON.size(); i++) { + JSONObject status = statusesJSON.getJSONObject(i); + Status stat = new Status(getRestclient(),status); + statuses.add(stat); + } + } + + public List getStatuses() { + return statuses; + } + + @Override + public String toString() { + return String.format("%s{name=%s, statuses='%s'}", getClass().getSimpleName(), getId(), statuses.toString()); + } + +} diff --git a/src/main/java/net/rcarz/jiraclient/agile/BoardConfiguration.java b/src/main/java/net/rcarz/jiraclient/agile/BoardConfiguration.java new file mode 100644 index 00000000..992d444e --- /dev/null +++ b/src/main/java/net/rcarz/jiraclient/agile/BoardConfiguration.java @@ -0,0 +1,131 @@ +/** + * jira-client - a simple JIRA REST client + * Copyright (c) 2013 Bob Carroll (bob.carroll@alum.rit.edu) + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.rcarz.jiraclient.agile; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import net.rcarz.jiraclient.Filter; +import net.rcarz.jiraclient.JiraClient; +import net.rcarz.jiraclient.JiraException; +import net.rcarz.jiraclient.RestClient; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * Represents an Agile Board Configuration. + * + * @author SelAnt + */ +public class BoardConfiguration extends AgileResource { + + private String type; + private List columns; + + /** + * Retrieve all sprints related to the specified board. + * + * @param restclient REST client instance + * @param boardId The Internal JIRA board ID. + * @return The list of sprints associated to the board. + * @throws JiraException when the retrieval fails + */ + static BoardConfiguration get(RestClient restclient, long boardId) throws JiraException { + return AgileResource.get(restclient, BoardConfiguration.class, RESOURCE_URI + "board/" + boardId+"/configuration"); + } + + /** + * Creates a new Agile resource. + * + * @param restclient REST client instance + * @param json JSON payload + */ + public BoardConfiguration(RestClient restclient, JSONObject json) throws JiraException { + super(restclient, json); + } + + /** + * Deserialize the json to extract standard attributes and keep a reference of + * other attributes. + * + * @param json The JSON object to read. + */ + @Override + void deserialize(JSONObject json) throws JiraException { + super.deserialize(json); + this.type = json.getString("type"); + setName(json.getString("name")); + //TODO: filter + Filter filter = new Filter(getRestclient(), json.getJSONObject("filter")); + /* + "filter": { + "id": "36869", + "self": "https://jira.pointclickcare.com/jira/rest/api/2/filter/36869" + }, + */ + JSONObject columnConfig = json.getJSONObject("columnConfig"); + //TODO: columnConfig.getString("constraintType") + columns = getResourceArray(BoardColumn.class, columnConfig , getRestclient(),"columns"); + + //Statuses in each Column do not have names - need to fetch all known statuses + List statuses = net.rcarz.jiraclient.Status.getAll(getRestclient()); + HashMap statMap = new HashMap<>(statuses.size()); + for (net.rcarz.jiraclient.Status status : statuses) { + statMap.put(status.getId(), status); + } + //set names to statuses in Board Columns + for (BoardColumn column : columns) { + for (Status st : column.getStatuses()) { + net.rcarz.jiraclient.Status status = statMap.get(String.valueOf(st.getId())); + if (status != null) { + st.setName(status.getName()); + } + } + } + //TODO: estimation and ranking fields + /* + "estimation": { + "type": "field", + "field": { + "fieldId": "customfield_10276", + "displayName": "Estimated Points" + } + }, + "ranking": { + "rankCustomFieldId": 18210 + } + */ + } + + @Override + public String toString() { + return String.format("%s{id=%s, name='%s'}", getClass().getSimpleName(), getId(), getName()); + } + + public String getType() { + return type; + } + + public List getColumns() { + return columns; + } + +} diff --git a/src/test/java/net/rcarz/jiraclient/agile/BoardConfigurationTest.java b/src/test/java/net/rcarz/jiraclient/agile/BoardConfigurationTest.java new file mode 100644 index 00000000..6b8dd9d3 --- /dev/null +++ b/src/test/java/net/rcarz/jiraclient/agile/BoardConfigurationTest.java @@ -0,0 +1,25 @@ +package net.rcarz.jiraclient.agile; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +import net.rcarz.jiraclient.JiraException; + +/** + * Test cases for stuff relating to filters. + */ +public class BoardConfigurationTest { + + @Test + public void testGetBoardConfiguration() throws JiraException { +// JiraClient jira = new JiraClient("https://jira.pointclickcare.com/jira", new TokenCredentials("AAC949A2137DA8A671EF197DDCCB8857")); +// AgileClient agileClient = new AgileClient(jira); +// Board board = agileClient.getBoard(144); +// BoardConfiguration configuration = board.getConfiguarion(); +// //Filter filter = jira.getFilter(id); + + assertNotNull("q"); + } + +} From db07a0b2aeb8c6ee711038f4acc404ba80565168 Mon Sep 17 00:00:00 2001 From: gadyag Date: Sat, 25 Nov 2017 09:17:33 -0500 Subject: [PATCH 4/5] Diamond removed for compatibility wit Java 1.7 and below --- src/main/java/net/rcarz/jiraclient/agile/BoardColumn.java | 2 +- .../java/net/rcarz/jiraclient/agile/BoardConfiguration.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/rcarz/jiraclient/agile/BoardColumn.java b/src/main/java/net/rcarz/jiraclient/agile/BoardColumn.java index eae7b429..e27edf3d 100644 --- a/src/main/java/net/rcarz/jiraclient/agile/BoardColumn.java +++ b/src/main/java/net/rcarz/jiraclient/agile/BoardColumn.java @@ -27,7 +27,7 @@ void deserialize(JSONObject json) throws JiraException { super.deserialize(json); setName(json.getString("name")); JSONArray statusesJSON = json.getJSONArray("statuses"); - statuses = new ArrayList<>(statusesJSON.size()); + statuses = new ArrayList(statusesJSON.size()); for (int i = 0; i < statusesJSON.size(); i++) { JSONObject status = statusesJSON.getJSONObject(i); Status stat = new Status(getRestclient(),status); diff --git a/src/main/java/net/rcarz/jiraclient/agile/BoardConfiguration.java b/src/main/java/net/rcarz/jiraclient/agile/BoardConfiguration.java index 992d444e..6de1075a 100644 --- a/src/main/java/net/rcarz/jiraclient/agile/BoardConfiguration.java +++ b/src/main/java/net/rcarz/jiraclient/agile/BoardConfiguration.java @@ -87,7 +87,7 @@ void deserialize(JSONObject json) throws JiraException { //Statuses in each Column do not have names - need to fetch all known statuses List statuses = net.rcarz.jiraclient.Status.getAll(getRestclient()); - HashMap statMap = new HashMap<>(statuses.size()); + HashMap statMap = new HashMap(statuses.size()); for (net.rcarz.jiraclient.Status status : statuses) { statMap.put(status.getId(), status); } From 53a232c14835540a76bc5a8ecc1b64dc0b6246a7 Mon Sep 17 00:00:00 2001 From: gadyag Date: Sat, 25 Nov 2017 09:17:33 -0500 Subject: [PATCH 5/5] Diamond removed for compatibility wit Java 1.7 and below --- .../java/net/rcarz/jiraclient/greenhopper/SprintReport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/rcarz/jiraclient/greenhopper/SprintReport.java b/src/main/java/net/rcarz/jiraclient/greenhopper/SprintReport.java index 7669dc86..941178a8 100644 --- a/src/main/java/net/rcarz/jiraclient/greenhopper/SprintReport.java +++ b/src/main/java/net/rcarz/jiraclient/greenhopper/SprintReport.java @@ -94,7 +94,7 @@ private void deserialise(JSONObject json) { map.get("puntedIssuesEstimateSum")); //JIRA-1234,true Map added = Field.getMap(String.class, Boolean.class, map.get("issueKeysAddedDuringSprint")); - issueKeysAddedDuringSprint = new ArrayList<>(added.keySet()); + issueKeysAddedDuringSprint = new ArrayList(added.keySet()); } /**