Package com.taskadapter.redmineapi
Class IssueManager
- java.lang.Object
-
- com.taskadapter.redmineapi.IssueManager
-
public class IssueManager extends java.lang.Object
Works with Issues, Time Entries, Issue Statuses, Issue Relations.Obtain it via RedmineManager:
RedmineManager redmineManager = RedmineManagerFactory.createWithUserAuth(redmineURI, login, password); IssueManager issueManager = redmineManager.getIssueManager();
Sample usage:
Issue issue = issueManager.getIssueById(3205, Include.journals, Include.relations, Include.attachments); System.out.println(issue.getJournals());
- See Also:
RedmineManager.getIssueManager()
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addWatcherToIssue(Watcher watcher, Issue issue)
IssueCategory
createCategory(IssueCategory category)
creates a newIssueCategory
for theProject
contained.Issue
createIssue(Issue issue)
Sample usage:IssueRelation
createRelation(java.lang.Integer issueId, java.lang.Integer issueToId, java.lang.String type)
void
deleteCategory(IssueCategory category)
deletes anIssueCategory
.void
deleteIssue(java.lang.Integer id)
void
deleteIssueRelations(Issue redmineIssue)
Delete all issue's relationsvoid
deleteIssueRelationsByIssueId(java.lang.Integer issueId)
Delete relations for the given issue ID.void
deleteRelation(java.lang.Integer id)
Delete Issue Relation with the given Id.void
deleteWatcherFromIssue(Watcher watcher, Issue issue)
java.util.List<IssueCategory>
getCategories(int projectID)
delivers a list ofIssueCategory
s of aProject
Issue
getIssueById(java.lang.Integer id, Include... include)
java.util.List<IssuePriority>
getIssuePriorities()
ResultsWrapper<Issue>
getIssues(Params parameters)
Free-form search that does not do any paging for you.java.util.List<Issue>
getIssues(java.lang.String projectKey, java.lang.Integer queryId, Include... include)
ResultsWrapper<Issue>
getIssues(java.util.Map<java.lang.String,java.lang.String> parameters)
Direct method to search for issues using any Redmine REST API parameters you want.java.util.List<Issue>
getIssuesBySummary(java.lang.String projectKey, java.lang.String summaryField)
There could be several issues with the same summary, so the method returns List.java.util.List<SavedQuery>
getSavedQueries()
Get all "saved queries" available to the current user.java.util.List<SavedQuery>
getSavedQueries(java.lang.String projectKey)
Get "saved queries" for the given project available to the current user.java.util.List<IssueStatus>
getStatuses()
Delivers a list of existingIssueStatus
es.java.util.List<Tracker>
getTrackers()
void
update(Issue obj)
-
-
-
Method Detail
-
getIssuesBySummary
public java.util.List<Issue> getIssuesBySummary(java.lang.String projectKey, java.lang.String summaryField) throws RedmineException
There could be several issues with the same summary, so the method returns List.- Returns:
- empty list if not issues with this summary field exist, never NULL
- Throws:
RedmineAuthenticationException
- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.NotFoundException
RedmineException
-
getIssues
public ResultsWrapper<Issue> getIssues(java.util.Map<java.lang.String,java.lang.String> parameters) throws RedmineException
Direct method to search for issues using any Redmine REST API parameters you want.Unlike other getXXXObjects() methods in this library, this one does NOT handle paging for you so you have to provide "offset" and "limit" parameters if you want to control paging.
Sample usage:
final Map
params = new HashMap (); params.put("project_id", projectId); params.put("subject", "~free_form_search"); final List issues = issueManager.getIssues(params); - Parameters:
parameters
- the http parameters key/value pairs to append to the rest api request- Returns:
- resultsWrapper with raw response from Redmine REST API
- Throws:
RedmineAuthenticationException
- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.RedmineException
-
getIssues
public ResultsWrapper<Issue> getIssues(Params parameters) throws RedmineException
Free-form search that does not do any paging for you. Btw, where is Redmine free-form search documentation??Sample usage:
Params params = new Params() .add("set_filter", "1") .add("f[]", "summary") .add("op[summary]", "~") .add("v[summary]", "another") .add("f[]", "description") .add("op[description]", "~") .add("v[description][]", "abc"); list = issueManager.getIssues(params);
- Parameters:
parameters
-- Throws:
RedmineException
-
getIssueById
public Issue getIssueById(java.lang.Integer id, Include... include) throws RedmineException
- Parameters:
id
- Redmine issue Idinclude
- list of "includes". e.g. "relations", "journals", ...- Returns:
- Issue object. never Null: an exception is thrown if the issue is not found (see Throws section).
- Throws:
RedmineAuthenticationException
- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.NotFoundException
- the issue with the given id is not found on the serverRedmineException
-
addWatcherToIssue
public void addWatcherToIssue(Watcher watcher, Issue issue) throws RedmineException
- Throws:
RedmineException
-
deleteWatcherFromIssue
public void deleteWatcherFromIssue(Watcher watcher, Issue issue) throws RedmineException
- Throws:
RedmineException
-
createIssue
public Issue createIssue(Issue issue) throws RedmineException
Sample usage:Issue issueToCreate = IssueFactory.create(projectDatabaseId, subject); Issue newIssue = mgr.createIssue(issueToCreate);
- Parameters:
issue
- the Issue object to create on the server.- Returns:
- the newly created Issue.
- Throws:
RedmineAuthenticationException
- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.NotFoundException
- the project is not foundRedmineException
-
deleteIssue
public void deleteIssue(java.lang.Integer id) throws RedmineException
- Throws:
RedmineException
-
getIssues
public java.util.List<Issue> getIssues(java.lang.String projectKey, java.lang.Integer queryId, Include... include) throws RedmineException
- Parameters:
projectKey
- ignored if NULLqueryId
- id of the saved query in Redmine. the query must be accessible to the user represented by the API access key (if the Redmine project requires authorization). This parameter is optional, NULL can be provided to get all available issues.- Returns:
- list of Issue objects
- Throws:
RedmineAuthenticationException
- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.RedmineException
- See Also:
Issue
-
createRelation
public IssueRelation createRelation(java.lang.Integer issueId, java.lang.Integer issueToId, java.lang.String type) throws RedmineException
- Parameters:
issueId
- id of the source issueissueToId
- if of the target issuetype
- type of the relation. e.g. "precedes". see IssueRelation.TYPE for possible types.- Returns:
- newly created IssueRelation instance.
- Throws:
RedmineException
- See Also:
IssueRelation.TYPE
-
deleteRelation
public void deleteRelation(java.lang.Integer id) throws RedmineException
Delete Issue Relation with the given Id.- Throws:
RedmineException
-
deleteIssueRelations
public void deleteIssueRelations(Issue redmineIssue) throws RedmineException
Delete all issue's relations- Throws:
RedmineException
-
deleteIssueRelationsByIssueId
public void deleteIssueRelationsByIssueId(java.lang.Integer issueId) throws RedmineException
Delete relations for the given issue ID.- Parameters:
issueId
- issue ID- Throws:
RedmineException
-
getIssuePriorities
public java.util.List<IssuePriority> getIssuePriorities() throws RedmineException
- Throws:
RedmineException
-
update
public void update(Issue obj) throws RedmineException
- Throws:
RedmineException
-
getCategories
public java.util.List<IssueCategory> getCategories(int projectID) throws RedmineException
delivers a list ofIssueCategory
s of aProject
- Parameters:
projectID
- the ID of theProject
- Returns:
- the list of
IssueCategory
s of theProject
- Throws:
RedmineAuthenticationException
- thrown in case something went wrong while trying to loginRedmineException
- thrown in case something went wrong in RedmineNotFoundException
- thrown in case an object can not be found
-
createCategory
public IssueCategory createCategory(IssueCategory category) throws RedmineException
creates a newIssueCategory
for theProject
contained.
Pre-condition: the attributeProject
for theIssueCategory
must not be null!- Parameters:
category
- theIssueCategory
. Must contain aProject
.- Returns:
- the new
IssueCategory
created by Redmine - Throws:
java.lang.IllegalArgumentException
- thrown in case the category does not contain a project.RedmineAuthenticationException
- thrown in case something went wrong while trying to loginRedmineException
- thrown in case something went wrong in RedmineNotFoundException
- thrown in case an object can not be found
-
deleteCategory
public void deleteCategory(IssueCategory category) throws RedmineException
deletes anIssueCategory
.- Parameters:
category
- theIssueCategory
.- Throws:
RedmineAuthenticationException
- thrown in case something went wrong while trying to loginRedmineException
- thrown in case something went wrong in RedmineNotFoundException
- thrown in case an object can not be found
-
getStatuses
public java.util.List<IssueStatus> getStatuses() throws RedmineException
Delivers a list of existingIssueStatus
es.- Returns:
- a list of existing
IssueStatus
es. - Throws:
RedmineAuthenticationException
- thrown in case something went wrong while trying to loginRedmineException
- thrown in case something went wrong in RedmineNotFoundException
- thrown in case an object can not be found
-
getTrackers
public java.util.List<Tracker> getTrackers() throws RedmineException
- Returns:
- a list of all
Tracker
s available (like "Bug", "Task", "Feature") - Throws:
RedmineAuthenticationException
- thrown in case something went wrong while trying to loginRedmineException
- thrown in case something went wrong in RedmineNotFoundException
- thrown in case an object can not be found
-
getSavedQueries
public java.util.List<SavedQuery> getSavedQueries(java.lang.String projectKey) throws RedmineException
Get "saved queries" for the given project available to the current user.This REST API feature was added in Redmine 1.3.0. See http://www.redmine.org/issues/5737
- Throws:
RedmineException
-
getSavedQueries
public java.util.List<SavedQuery> getSavedQueries() throws RedmineException
Get all "saved queries" available to the current user.This REST API feature was added in Redmine 1.3.0. See http://www.redmine.org/issues/5737
- Throws:
RedmineException
-
-