Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 2 additions & 130 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,135 +1,7 @@
jira-worklog-query-plugin
=========================

A JIRA plugin to query worklogs and return them in JSON format via an authenticated RESTful service.
There are two main features this plugin provides:
Worklog Query Plugin is a JIRA plugin enabling its users to run worklog queries and apply parameters on these queries through RESTful services. The plugin handles queries according to user roles, therefore, these queries can only be run on worklogs the user has appropriate permissions to access. Various filtering parameters can also be set up to narrow down the search results to a certain interval of time, user, user group and/or project. The result of the worklog query is served in JSON format.

* Querying worklogs.
* Summarize worked time by issues.
The documentation of the plugin can be found [here](https://github.com/everit-org/jira-worklog-query-plugin/wiki).

##Querying worklogs
**_/rest/jira-worklog-query/1.2.0/find/worklogs_**

Returns worklogs filtered by the given parameters.

|parameter |value |optional|description|
|----------|------------|--------|-----------|
|startDate |"YYYY-MM-DD"|false |The result will only contain worklogs after this date|
|endDate |"YYYY-MM-DD"|true |The result will only contain worklogs before this date. The default value is the current date.|
|group/user|string |false |A JIRA group or user name whose worklogs are queried. One of them is required.|
|project |string |true |The result will only contain worklogs which are logged to this project. By default, all projects worklogs are returned.|
|fields |string list |true |A list of additional fields to return. Available fields are: comment, updated.|

Available response representations:

* 200 - application/json
Example:
```
[
[
{
"id": 10204,
"startDate": "2014-07-31T08:00:00+0200",
"issueKey": "TEST-5",
"userId": "admin",
"duration": 22440
},
{
"id": 10207,
"startDate": "2014-07-31T14:14:00+0200",
"issueKey": "TEST-2",
"userId": "admin",
"duration": 2340
}
]
]
```
* 400 - Returned if there is a problem running the query.
Example:
```
Error running search: There is no project matching the given 'project' parameter: NOPROJECT
```

##Summarize worked time by issues
**_/rest/jira-worklog-query/1.2.0/find/worklogsByIssues_**

This function queries worklogs - filtered by the given parameters - and summarize them by issues.
The returned issues can be filtered by a JQL expression.
The response are paginated, with default page size of 25 issues.

|parameter |value |optional|description|
|----------|------------|--------|-----------|
|startDate |"YYYY-MM-DD"|false |The result will only contain worklogs after this date|
|endDate |"YYYY-MM-DD"|false |The result will only contain worklogs before this date. The default value is the current date.|
|group/user|string |false |A JIRA group or user name whose worklogs are queried. One of them is required.|
|jql |string |true |The returned issues are filtered by this JQL expression. By default, all issues are returned.|
|fields |string list |true |The list of fields to return for each issue. By default, no additional fields are returned. [More info](https://docs.atlassian.com/jira/REST/latest/#d2e423)|
|startAt |int |true |The index of the first issue to return (0-based)|
|maxResults|int |true |The maximum number of issues to return (default is 25).|

Available response representations:

* 200 - application/json
Example response with no additional fields parameter:
```
{
"startAt": 0,
"maxResults": 25,
"total": 2,
"issues": [
{
"id": "13405",
"self": "http://localhost:8080/rest/api/2/issue/13405",
"key": "TEST-1",
"timespent": 1440
},
{
"id": "13406",
"self": "http://localhost:8080/rest/api/2/issue/13406",
"key": "TEST-2",
"timespent": 35760
}
]
}
```


Example response with "fields=summary,progress" parameter:

```
{
"startAt": 0,
"maxResults": 25,
"total": 1,
"issues": [
{
"id": "13411",
"self": "http://localhost:8080/rest/api/2/issue/13411",
"key": "NEW-1",
"fields": {
"progress": {
"progress": 84000,
"total": 84000,
"percent": 100
},
"summary": "new issue1"
},
"timespent": 67080
}
]
}
```
* 400 - application/json
Returned if there is a problem running the query.
Example:
```
{
"errorMessages": [
"Cannot parse the 'startDate' parameter: 2013-0ghjg6-25"
],
"errors": {
}
}
```

[![Analytics](https://ga-beacon.appspot.com/UA-15041869-4/everit-org/jira-worklog-query-plugin-1.x)](https://github.com/igrigorik/ga-beacon)
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<parent>
<groupId>org.everit.jira.worklog.query.plugin</groupId>
<version>1.2.0</version>
<version>1.2.1-SNAPSHOT</version>
<artifactId>org.everit.jira.worklog.query.plugin.parent</artifactId>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,95 +32,97 @@
*/
public final class DateTimeConverterUtil {

/**
* The date format of the input parameters.
*/
private static final String INPUT_DATE_FORMAT = "yyyy-MM-dd";
/**
* The date format of the input parameters.
*/
private static final String INPUT_DATE_FORMAT = "yyyy-MM-dd";

/**
* The date format of JIRA.
*/
private static final String JIRA_OUTPUT_DATE_TIME_FORMAT = "yyyy-MM-dd hh:mm:ss.s";
/**
* The date format of JIRA.
*/
private static final String JIRA_OUTPUT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss.s";

/**
* The date format of the output.
*/
private static final String OUTPUT_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
/**
* The date format of the output.
*/
private static final String OUTPUT_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";

/**
* Convert the date to String ({@value #OUTPUT_DATE_TIME_FORMAT}).
*
* @param date
* The Date to convert.
* @return The result time.
*/
private static String dateToString(final Date date) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(OUTPUT_DATE_TIME_FORMAT);
String dateString = simpleDateFormat.format(date);
return dateString;
}
/**
* Convert the date to String ({@value #OUTPUT_DATE_TIME_FORMAT}).
*
* @param date
* The Date to convert.
* @return The result time.
*/
private static String dateToString(final Date date) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(OUTPUT_DATE_TIME_FORMAT);
String dateString = simpleDateFormat.format(date);
return dateString;
}

/**
* Convert String ({@value #INPUT_DATE_FORMAT}) to Calendar.
*
* @param dateString
* The String date to convert.
* @return The result Date.
* @throws ParseException
* If can't parse the date.
*/
public static Calendar inputStringToCalendar(final String dateString) throws ParseException {
DateFormat dateFormat = new SimpleDateFormat(INPUT_DATE_FORMAT);
Calendar calendar = Calendar.getInstance();
calendar.setTime(dateFormat.parse(dateString));
return calendar;
}
/**
* Convert String ({@value #INPUT_DATE_FORMAT}) to Calendar.
*
* @param dateString
* The String date to convert.
* @return The result Date.
* @throws ParseException
* If can't parse the date.
*/
public static Calendar inputStringToCalendar(final String dateString) throws ParseException {
DateFormat dateFormat = new SimpleDateFormat(INPUT_DATE_FORMAT);
Calendar calendar = Calendar.getInstance();
calendar.setTime(dateFormat.parse(dateString));
return calendar;
}

/**
* Set the calendar hour, minute and second value.
*
* @param originalCalendar
* The original calendar.
* @param hourOfDay
* The hour of the day to set.
* @param minute
* The minute to set.
* @param second
* The second to set.
* @return The new calendar object.
*/
public static Calendar setCalendarHourMinSec(final Calendar originalCalendar, final int hourOfDay,
final int minute, final int second) {
Calendar calendar = Calendar.getInstance();
calendar.set(
originalCalendar.get(Calendar.YEAR),
originalCalendar.get(Calendar.MONTH),
originalCalendar.get(Calendar.DAY_OF_MONTH),
hourOfDay,
minute,
second);
return calendar;
}
/**
* Set the calendar hour, minute and second value.
*
* @param originalCalendar
* The original calendar.
* @param hourOfDay
* The hour of the day to set.
* @param minute
* The minute to set.
* @param second
* The second to set.
* @return The new calendar object.
*/
public static Calendar setCalendarHourMinSec(final Calendar originalCalendar,
final int hourOfDay,
final int minute, final int second) {
Calendar calendar = Calendar.getInstance();
calendar.set(
originalCalendar.get(Calendar.YEAR),
originalCalendar.get(Calendar.MONTH),
originalCalendar.get(Calendar.DAY_OF_MONTH),
hourOfDay,
minute,
second);
return calendar;
}

/**
* Format a String date to valid ISO-8601 format String date.
*
* @param dateString
* The date.
* @return The formated String date.
* @throws ParseException
* If cannot parse the String to Date.
*/
public static String stringDateToISO8601FormatString(final String dateString) throws ParseException {
DateFormat dateFormat = new SimpleDateFormat(JIRA_OUTPUT_DATE_TIME_FORMAT);
Date date = dateFormat.parse(dateString);
return DateTimeConverterUtil.dateToString(date);
}
/**
* Format a String date to valid ISO-8601 format String date.
*
* @param dateString
* The date.
* @return The formated String date.
* @throws ParseException
* If cannot parse the String to Date.
*/
public static String stringDateToISO8601FormatString(final String dateString)
throws ParseException {
DateFormat dateFormat = new SimpleDateFormat(JIRA_OUTPUT_DATE_TIME_FORMAT);
Date date = dateFormat.parse(dateString);
return DateTimeConverterUtil.dateToString(date);
}

/**
* Private constructor.
*/
private DateTimeConverterUtil() {
}
/**
* Private constructor.
*/
private DateTimeConverterUtil() {
}

}
Loading