1
0
Fork 0

added resolution and resolution date to issues

master
Bob Carroll 2013-05-26 23:36:57 -07:00
parent 47db0a6b5c
commit d5ef77e016
3 changed files with 117 additions and 1 deletions

View File

@ -62,6 +62,8 @@ public final class Field {
public static final String PRIORITY = "priority";
public static final String PROJECT = "project";
public static final String REPORTER = "reporter";
public static final String RESOLUTION = "resolution";
public static final String RESOLUTION_DATE = "resolutiondate";
public static final String STATUS = "status";
public static final String SUMMARY = "summary";
public static final String TIME_TRACKING = "timetracking";
@ -195,6 +197,8 @@ public final class Field {
result = (T)new Priority(restclient, (JSONObject)r);
else if (type == Project.class)
result = (T)new Project(restclient, (JSONObject)r);
else if (type == Resolution.class)
result = (T)new Resolution(restclient, (JSONObject)r);
else if (type == Status.class)
result = (T)new Status(restclient, (JSONObject)r);
else if (type == User.class)
@ -276,6 +280,8 @@ public final class Field {
results.add((T)new Priority(restclient, (JSONObject)v));
else if (type == Project.class)
results.add((T)new Project(restclient, (JSONObject)v));
else if (type == Resolution.class)
results.add((T)new Resolution(restclient, (JSONObject)v));
else if (type == Status.class)
results.add((T)new Status(restclient, (JSONObject)v));
else if (type == User.class)
@ -423,7 +429,8 @@ public final class Field {
SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT);
return df.format(d);
} else if (m.type.equals("issuetype") || m.type.equals("priority") || m.type.equals("user")) {
} else if (m.type.equals("issuetype") || m.type.equals("priority") ||
m.type.equals("user") || m.type.equals("resolution")) {
JSONObject json = new JSONObject();
json.put("name", value.toString());

View File

@ -266,6 +266,8 @@ public final class Issue extends Resource {
private Priority priority = null;
private Project project = null;
private User reporter = null;
private Resolution resolution = null;
private Date resolutionDate = null;
private Status status = null;
private String summary = null;
private TimeTracking timeTracking = null;
@ -307,6 +309,8 @@ public final class Issue extends Resource {
priority = Field.getResource(Priority.class, fields.get(Field.PRIORITY), restclient);
project = Field.getResource(Project.class, fields.get(Field.PROJECT), restclient);
reporter = Field.getResource(User.class, fields.get(Field.REPORTER), restclient);
resolution = Field.getResource(Resolution.class, fields.get(Field.RESOLUTION), restclient);
resolutionDate = Field.getDate(fields.get(Field.RESOLUTION_DATE));
status = Field.getResource(Status.class, fields.get(Field.STATUS), restclient);
summary = Field.getString(fields.get(Field.SUMMARY));
timeTracking = Field.getTimeTracking(fields.get(Field.TIME_TRACKING));
@ -656,6 +660,14 @@ public final class Issue extends Resource {
return reporter;
}
public Resolution getResolution() {
return resolution;
}
public Date getResolutionDate() {
return resolutionDate;
}
public Status getStatus() {
return status;
}

View File

@ -0,0 +1,97 @@
/**
* jira-client - a simple JIRA REST client
* Copyright (c) 2013 Bob Carroll (bob.carroll@alum.rit.edu)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.rcarz.jiraclient;
import java.util.Map;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
/**
* Represents an issue resolution.
*/
public final class Resolution extends Resource {
private String description = null;
private String name = null;
/**
* Creates a resolution from a JSON payload.
*
* @param restclient REST client instance
* @param json JSON payload
*/
protected Resolution(RestClient restclient, JSONObject json) {
super(restclient);
if (json != null)
deserialise(json);
}
private void deserialise(JSONObject json) {
Map map = json;
self = Field.getString(map.get("self"));
id = Field.getString(map.get("id"));
description = Field.getString(map.get("description"));
name = Field.getString(map.get("name"));
}
/**
* Retrieves the given resolution record.
*
* @param restclient REST client instance
* @param id Internal JIRA ID of the resolution
*
* @return a resolution instance
*
* @throws JiraException when the retrieval fails
*/
public static Resolution get(RestClient restclient, String id)
throws JiraException {
JSON result = null;
try {
result = restclient.get(RESOURCE_URI + "resolution/" + id);
} catch (Exception ex) {
throw new JiraException("Failed to retrieve resolution " + id, ex);
}
if (!(result instanceof JSONObject))
throw new JiraException("JSON payload is malformed");
return new Resolution(restclient, (JSONObject)result);
}
@Override
public String toString() {
return getName();
}
public String getDescription() {
return description;
}
public String getName() {
return name;
}
}