1
0
Fork 0

finished sprint report implementation

master
Bob Carroll 2013-08-25 10:58:13 -07:00
parent aef458bb52
commit 3d7a392e5d
8 changed files with 164 additions and 23 deletions

View File

@ -4,7 +4,7 @@ jira-client is a simple and lightweight JIRA REST client library for Java.
The goal of the project is to provide **simple** and clean English idiomatic expressions for interacting with JIRA. In pursuit of this goal, jira-client lacks the usual verbose and cumbersome contortions often found in Java applications. And since the implementation isn't buried under 57 layers of complicated abstractions, jira-client is easy to extend and debug.
jira-client depends on [Apache HttpComponents](http://hc.apache.org/) and [json-lib](http://json.sourceforge.net/).
jira-client depends on [Apache HttpComponents](http://hc.apache.org/), [json-lib](http://json.sourceforge.net/), and [joda-time](http://www.joda.org/joda-time/).
## Features ##

View File

@ -146,6 +146,22 @@ public final class Field {
return result;
}
/**
* Gets an floating-point number from the given object.
*
* @param i an Double instance
*
* @return an floating-point number or null if i isn't a Double instance
*/
public static Double getDouble(Object i) {
Double result = null;
if (i instanceof Double)
result = (Double)i;
return result;
}
/**
* Gets an integer from the given object.
*

View File

@ -20,18 +20,15 @@
package net.rcarz.jiraclient.greenhopper;
import net.rcarz.jiraclient.Field;
import net.rcarz.jiraclient.RestClient;
import java.util.Map;
import net.sf.json.JSONObject;
import org.joda.time.DateTime;
/**
* GreenHopper estimate statistics for rapid views.
*/
public final class EstimateStatistic extends GreenHopperResource {
public final class EstimateStatistic {
private String statFieldId = null;
private int statFieldValue = 0;
@ -40,17 +37,9 @@ public final class EstimateStatistic extends GreenHopperResource {
/**
* Creates an estimate statistic from a JSON payload.
*
* @param restclient REST client instance
* @param json JSON payload
*/
protected EstimateStatistic(RestClient restclient, JSONObject json) {
super(restclient);
if (json != null)
deserialise(json);
}
private void deserialise(JSONObject json) {
protected EstimateStatistic(JSONObject json) {
Map map = json;
statFieldId = Field.getString(map.get("statFieldId"));

View File

@ -0,0 +1,56 @@
/**
* 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.greenhopper;
import net.rcarz.jiraclient.Field;
import java.util.Map;
import net.sf.json.JSONObject;
/**
* GreenHopper estimate sum for rapid views.
*/
public final class EstimateSum {
private Double value = null;
private String text = null;
/**
* Creates an estimate sum from a JSON payload.
*
* @param json JSON payload
*/
protected EstimateSum(JSONObject json) {
Map map = json;
value = Field.getDouble(map.get("value"));
text = Field.getString(map.get("text"));
}
public Double getValue() {
return value;
}
public String getText() {
return text;
}
}

View File

@ -52,6 +52,38 @@ public final class GreenHopperField {
null;
}
/**
* Gets an estimate statistic object from the given object.
*
* @param es a JSONObject instance
*
* @return a EstimateStatistic instance or null if es isn't a JSONObject instance
*/
public static EstimateStatistic getEstimateStatistic(Object es) {
EstimateStatistic result = null;
if (es instanceof JSONObject && !((JSONObject)es).isNullObject())
result = new EstimateStatistic((JSONObject)es);
return result;
}
/**
* Gets an estimate sum object from the given object.
*
* @param es a JSONObject instance
*
* @return a EstimateSum instance or null if es isn't a JSONObject instance
*/
public static EstimateSum getEstimateSum(Object es) {
EstimateSum result = null;
if (es instanceof JSONObject && !((JSONObject)es).isNullObject())
result = new EstimateSum((JSONObject)es);
return result;
}
/**
* Gets a list of integers from the given object.
*
@ -85,9 +117,7 @@ public final class GreenHopperField {
T result = null;
if (r instanceof JSONObject && !((JSONObject)r).isNullObject()) {
if (type == EstimateStatistic.class)
result = (T)new EstimateStatistic(restclient, (JSONObject)r);
else if (type == RapidView.class)
if (type == RapidView.class)
result = (T)new RapidView(restclient, (JSONObject)r);
else if (type == Sprint.class)
result = (T)new Sprint(restclient, (JSONObject)r);
@ -122,5 +152,23 @@ public final class GreenHopperField {
return results;
}
/**
* Gets a list of strings from the given object.
*
* @param ia a JSONArray instance
*
* @return a list of strings
*/
public static List<String> getStringArray(Object ia) {
List<String> results = new ArrayList<String>();
if (ia instanceof JSONArray) {
for (Object v : (JSONArray)ia)
results.add((String)v);
}
return results;
}
}

View File

@ -181,7 +181,7 @@ public final class RapidView extends GreenHopperResource {
return canEdit;
}
public Boolean sprintSupportEnabled() {
public Boolean isSprintSupportEnabled() {
return sprintSupportEnabled;
}
}

View File

@ -56,7 +56,7 @@ public final class SprintIssue extends GreenHopperResource {
private int projectId = 0;
/**
* Creates a sprint from a JSON payload.
* Creates a sprint issue from a JSON payload.
*
* @param restclient REST client instance
* @param json JSON payload
@ -86,10 +86,7 @@ public final class SprintIssue extends GreenHopperResource {
avatarUrl = Field.getString(map.get("avatarUrl"));
colour = Field.getString(map.get("color"));
epic = Field.getString(map.get("epic"));
estimateStatistic = GreenHopperField.getResource(
EstimateStatistic.class,
map.get("estimateStatistic"),
restclient);
estimateStatistic = GreenHopperField.getEstimateStatistic(map.get("estimateStatistic"));
statusId = Field.getString(map.get("statusId"));
statusName = Field.getString(map.get("statusName"));
statusUrl = Field.getString(map.get("statusUrl"));

View File

@ -42,6 +42,11 @@ public final class SprintReport {
private List<SprintIssue> completedIssues = null;
private List<SprintIssue> incompletedIssues = null;
private List<SprintIssue> puntedIssues = null;
private EstimateSum completedIssuesEstimateSum = null;
private EstimateSum incompletedIssuesEstimateSum = null;
private EstimateSum allIssuesEstimateSum = null;
private EstimateSum puntedIssuesEstimateSum = null;
private List<String> issueKeysAddedDuringSprint = null;
/**
* Creates a sprint report from a JSON payload.
@ -72,6 +77,16 @@ public final class SprintReport {
SprintIssue.class,
map.get("puntedIssues"),
restclient);
completedIssuesEstimateSum = GreenHopperField.getEstimateSum(
map.get("completedIssuesEstimateSum"));
incompletedIssuesEstimateSum = GreenHopperField.getEstimateSum(
map.get("incompletedIssuesEstimateSum"));
allIssuesEstimateSum = GreenHopperField.getEstimateSum(
map.get("allIssuesEstimateSum"));
puntedIssuesEstimateSum = GreenHopperField.getEstimateSum(
map.get("puntedIssuesEstimateSum"));
issueKeysAddedDuringSprint = GreenHopperField.getStringArray(
map.get("issueKeysAddedDuringSprint"));
}
/**
@ -130,6 +145,26 @@ public final class SprintReport {
public List<SprintIssue> getPuntedIssues() {
return puntedIssues;
}
public EstimateSum getCompletedIssuesEstimateSum() {
return completedIssuesEstimateSum;
}
public EstimateSum getIncompletedIssuesEstimateSum() {
return incompletedIssuesEstimateSum;
}
public EstimateSum getAllIssuesEstimateSum() {
return allIssuesEstimateSum;
}
public EstimateSum getPuntedIssuesEstimateSum() {
return puntedIssuesEstimateSum;
}
public List<String> getIssueKeysAddedDuringSprint() {
return issueKeysAddedDuringSprint;
}
}