1
0
Fork 0

Merge pull request #1 from chaplinkyle/custom-field-options

Add method that returns list of custom field options by custom field id,...
master
Kyle Chaplin 2013-08-25 11:52:25 -07:00
commit ee8b753826
2 changed files with 32 additions and 2 deletions

View File

@ -340,7 +340,7 @@ public final class Issue extends Resource {
return RESOURCE_URI + "issue/" + (key != null ? key : "");
}
private static JSONObject getCreateMetadata(
public static JSONObject getCreateMetadata(
RestClient restclient, String project, String issueType) throws JiraException {
final String pval = project;
@ -880,5 +880,9 @@ public final class Issue extends Resource {
public List<WorkLog> getWorkLogs() {
return workLogs;
}
public JSONObject getCreateMetadata() throws JiraException{
return getCreateMetadata(restclient,"CS","Task");
}
}

View File

@ -20,8 +20,10 @@
package net.rcarz.jiraclient;
import java.net.URI;
import java.util.List;
import net.sf.json.JSONObject;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
/**
@ -99,6 +101,28 @@ public class JiraClient {
return Issue.search(restclient, jql);
}
/**
* Get a list of options for a custom field
*
* @param field field id
* @param project Key of the project context
* @param issueType Name of the issue type
*
* @return a search result structure with results
*
* @throws JiraException when the search fails
*/
public List<CustomFieldOption> getCustomFieldAllowedValues(String field, String project, String issueType) throws JiraException {
JSONObject createMetadata = (JSONObject) Issue.getCreateMetadata(restclient, project, issueType);
JSONObject fieldMetadata = (JSONObject) createMetadata.get(field);
List<CustomFieldOption> customFieldOptions = Field.getResourceArray(
CustomFieldOption.class,
fieldMetadata.get("allowedValues"),
restclient
);
return customFieldOptions;
}
public RestClient getRestClient() {
return restclient;
@ -107,5 +131,7 @@ public class JiraClient {
public String getSelf() {
return username;
}
}