Skip to content

Commit 306dbfb

Browse files
author
Balázs Zsoldos
committed
Merge pull request #16 from daniel-zsigus/1.2
Fixed time handling bug and updated wiki page
2 parents 1daffc6 + 06fee12 commit 306dbfb

File tree

8 files changed

+1021
-1070
lines changed

8 files changed

+1021
-1070
lines changed

README.md

Lines changed: 2 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,7 @@
11
jira-worklog-query-plugin
22
=========================
33

4-
A JIRA plugin to query worklogs and return them in JSON format via an authenticated RESTful service.
5-
There are two main features this plugin provides:
4+
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.
65

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

10-
##Querying worklogs
11-
**_/rest/jira-worklog-query/1.2.0/find/worklogs_**
12-
13-
Returns worklogs filtered by the given parameters.
14-
15-
|parameter |value |optional|description|
16-
|----------|------------|--------|-----------|
17-
|startDate |"YYYY-MM-DD"|false |The result will only contain worklogs after this date|
18-
|endDate |"YYYY-MM-DD"|true |The result will only contain worklogs before this date. The default value is the current date.|
19-
|group/user|string |false |A JIRA group or user name whose worklogs are queried. One of them is required.|
20-
|project |string |true |The result will only contain worklogs which are logged to this project. By default, all projects worklogs are returned.|
21-
|fields |string list |true |A list of additional fields to return. Available fields are: comment, updated.|
22-
23-
Available response representations:
24-
25-
* 200 - application/json
26-
Example:
27-
```
28-
[
29-
[
30-
{
31-
"id": 10204,
32-
"startDate": "2014-07-31T08:00:00+0200",
33-
"issueKey": "TEST-5",
34-
"userId": "admin",
35-
"duration": 22440
36-
},
37-
{
38-
"id": 10207,
39-
"startDate": "2014-07-31T14:14:00+0200",
40-
"issueKey": "TEST-2",
41-
"userId": "admin",
42-
"duration": 2340
43-
}
44-
]
45-
]
46-
```
47-
* 400 - Returned if there is a problem running the query.
48-
Example:
49-
```
50-
Error running search: There is no project matching the given 'project' parameter: NOPROJECT
51-
```
52-
53-
##Summarize worked time by issues
54-
**_/rest/jira-worklog-query/1.2.0/find/worklogsByIssues_**
55-
56-
This function queries worklogs - filtered by the given parameters - and summarize them by issues.
57-
The returned issues can be filtered by a JQL expression.
58-
The response are paginated, with default page size of 25 issues.
59-
60-
|parameter |value |optional|description|
61-
|----------|------------|--------|-----------|
62-
|startDate |"YYYY-MM-DD"|false |The result will only contain worklogs after this date|
63-
|endDate |"YYYY-MM-DD"|false |The result will only contain worklogs before this date. The default value is the current date.|
64-
|group/user|string |false |A JIRA group or user name whose worklogs are queried. One of them is required.|
65-
|jql |string |true |The returned issues are filtered by this JQL expression. By default, all issues are returned.|
66-
|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)|
67-
|startAt |int |true |The index of the first issue to return (0-based)|
68-
|maxResults|int |true |The maximum number of issues to return (default is 25).|
69-
70-
Available response representations:
71-
72-
* 200 - application/json
73-
Example response with no additional fields parameter:
74-
```
75-
{
76-
"startAt": 0,
77-
"maxResults": 25,
78-
"total": 2,
79-
"issues": [
80-
{
81-
"id": "13405",
82-
"self": "http://localhost:8080/rest/api/2/issue/13405",
83-
"key": "TEST-1",
84-
"timespent": 1440
85-
},
86-
{
87-
"id": "13406",
88-
"self": "http://localhost:8080/rest/api/2/issue/13406",
89-
"key": "TEST-2",
90-
"timespent": 35760
91-
}
92-
]
93-
}
94-
```
95-
96-
97-
Example response with "fields=summary,progress" parameter:
98-
99-
```
100-
{
101-
"startAt": 0,
102-
"maxResults": 25,
103-
"total": 1,
104-
"issues": [
105-
{
106-
"id": "13411",
107-
"self": "http://localhost:8080/rest/api/2/issue/13411",
108-
"key": "NEW-1",
109-
"fields": {
110-
"progress": {
111-
"progress": 84000,
112-
"total": 84000,
113-
"percent": 100
114-
},
115-
"summary": "new issue1"
116-
},
117-
"timespent": 67080
118-
}
119-
]
120-
}
121-
```
122-
* 400 - application/json
123-
Returned if there is a problem running the query.
124-
Example:
125-
```
126-
{
127-
"errorMessages": [
128-
"Cannot parse the 'startDate' parameter: 2013-0ghjg6-25"
129-
],
130-
"errors": {
131-
}
132-
}
133-
```
134-
135-
[![Analytics](https://ga-beacon.appspot.com/UA-15041869-4/everit-org/jira-worklog-query-plugin-1.x)](https://github.com/igrigorik/ga-beacon)

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<parent>
3030
<groupId>org.everit.jira.worklog.query.plugin</groupId>
31-
<version>1.2.0</version>
31+
<version>1.2.1-SNAPSHOT</version>
3232
<artifactId>org.everit.jira.worklog.query.plugin.parent</artifactId>
3333
</parent>
3434

core/src/main/java/org/everit/jira/worklog/query/plugin/core/DateTimeConverterUtil.java

Lines changed: 85 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -32,95 +32,97 @@
3232
*/
3333
public final class DateTimeConverterUtil {
3434

35-
/**
36-
* The date format of the input parameters.
37-
*/
38-
private static final String INPUT_DATE_FORMAT = "yyyy-MM-dd";
35+
/**
36+
* The date format of the input parameters.
37+
*/
38+
private static final String INPUT_DATE_FORMAT = "yyyy-MM-dd";
3939

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

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

50-
/**
51-
* Convert the date to String ({@value #OUTPUT_DATE_TIME_FORMAT}).
52-
*
53-
* @param date
54-
* The Date to convert.
55-
* @return The result time.
56-
*/
57-
private static String dateToString(final Date date) {
58-
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(OUTPUT_DATE_TIME_FORMAT);
59-
String dateString = simpleDateFormat.format(date);
60-
return dateString;
61-
}
50+
/**
51+
* Convert the date to String ({@value #OUTPUT_DATE_TIME_FORMAT}).
52+
*
53+
* @param date
54+
* The Date to convert.
55+
* @return The result time.
56+
*/
57+
private static String dateToString(final Date date) {
58+
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(OUTPUT_DATE_TIME_FORMAT);
59+
String dateString = simpleDateFormat.format(date);
60+
return dateString;
61+
}
6262

63-
/**
64-
* Convert String ({@value #INPUT_DATE_FORMAT}) to Calendar.
65-
*
66-
* @param dateString
67-
* The String date to convert.
68-
* @return The result Date.
69-
* @throws ParseException
70-
* If can't parse the date.
71-
*/
72-
public static Calendar inputStringToCalendar(final String dateString) throws ParseException {
73-
DateFormat dateFormat = new SimpleDateFormat(INPUT_DATE_FORMAT);
74-
Calendar calendar = Calendar.getInstance();
75-
calendar.setTime(dateFormat.parse(dateString));
76-
return calendar;
77-
}
63+
/**
64+
* Convert String ({@value #INPUT_DATE_FORMAT}) to Calendar.
65+
*
66+
* @param dateString
67+
* The String date to convert.
68+
* @return The result Date.
69+
* @throws ParseException
70+
* If can't parse the date.
71+
*/
72+
public static Calendar inputStringToCalendar(final String dateString) throws ParseException {
73+
DateFormat dateFormat = new SimpleDateFormat(INPUT_DATE_FORMAT);
74+
Calendar calendar = Calendar.getInstance();
75+
calendar.setTime(dateFormat.parse(dateString));
76+
return calendar;
77+
}
7878

79-
/**
80-
* Set the calendar hour, minute and second value.
81-
*
82-
* @param originalCalendar
83-
* The original calendar.
84-
* @param hourOfDay
85-
* The hour of the day to set.
86-
* @param minute
87-
* The minute to set.
88-
* @param second
89-
* The second to set.
90-
* @return The new calendar object.
91-
*/
92-
public static Calendar setCalendarHourMinSec(final Calendar originalCalendar, final int hourOfDay,
93-
final int minute, final int second) {
94-
Calendar calendar = Calendar.getInstance();
95-
calendar.set(
96-
originalCalendar.get(Calendar.YEAR),
97-
originalCalendar.get(Calendar.MONTH),
98-
originalCalendar.get(Calendar.DAY_OF_MONTH),
99-
hourOfDay,
100-
minute,
101-
second);
102-
return calendar;
103-
}
79+
/**
80+
* Set the calendar hour, minute and second value.
81+
*
82+
* @param originalCalendar
83+
* The original calendar.
84+
* @param hourOfDay
85+
* The hour of the day to set.
86+
* @param minute
87+
* The minute to set.
88+
* @param second
89+
* The second to set.
90+
* @return The new calendar object.
91+
*/
92+
public static Calendar setCalendarHourMinSec(final Calendar originalCalendar,
93+
final int hourOfDay,
94+
final int minute, final int second) {
95+
Calendar calendar = Calendar.getInstance();
96+
calendar.set(
97+
originalCalendar.get(Calendar.YEAR),
98+
originalCalendar.get(Calendar.MONTH),
99+
originalCalendar.get(Calendar.DAY_OF_MONTH),
100+
hourOfDay,
101+
minute,
102+
second);
103+
return calendar;
104+
}
104105

105-
/**
106-
* Format a String date to valid ISO-8601 format String date.
107-
*
108-
* @param dateString
109-
* The date.
110-
* @return The formated String date.
111-
* @throws ParseException
112-
* If cannot parse the String to Date.
113-
*/
114-
public static String stringDateToISO8601FormatString(final String dateString) throws ParseException {
115-
DateFormat dateFormat = new SimpleDateFormat(JIRA_OUTPUT_DATE_TIME_FORMAT);
116-
Date date = dateFormat.parse(dateString);
117-
return DateTimeConverterUtil.dateToString(date);
118-
}
106+
/**
107+
* Format a String date to valid ISO-8601 format String date.
108+
*
109+
* @param dateString
110+
* The date.
111+
* @return The formated String date.
112+
* @throws ParseException
113+
* If cannot parse the String to Date.
114+
*/
115+
public static String stringDateToISO8601FormatString(final String dateString)
116+
throws ParseException {
117+
DateFormat dateFormat = new SimpleDateFormat(JIRA_OUTPUT_DATE_TIME_FORMAT);
118+
Date date = dateFormat.parse(dateString);
119+
return DateTimeConverterUtil.dateToString(date);
120+
}
119121

120-
/**
121-
* Private constructor.
122-
*/
123-
private DateTimeConverterUtil() {
124-
}
122+
/**
123+
* Private constructor.
124+
*/
125+
private DateTimeConverterUtil() {
126+
}
125127

126128
}

0 commit comments

Comments
 (0)