IDEA-74652 Time tracking features. Bugs with formatting of spending time

This commit is contained in:
Evgeny Zakrevsky
2012-12-27 21:16:29 +04:00
parent 682a517de6
commit c855ae9ff3
4 changed files with 6 additions and 11 deletions
@@ -216,12 +216,12 @@ public class JiraRepository extends BaseRepositoryImpl {
}
@Override
public void updateTimeSpent(final LocalTask task, final int timeSpentInMinutes, final String comment) throws Exception {
public void updateTimeSpent(final LocalTask task, final String timeSpent, final String comment) throws Exception {
final HttpClient client = login();
checkVersion(client);
PostMethod method = new PostMethod(getUrl() + "/rest/api/2/issue/" + task.getId() + "/worklog");
method.setRequestEntity(
new StringRequestEntity("{\"timeSpentSeconds\" : " + String.valueOf(calculateTimeSpent(timeSpentInMinutes)) +
new StringRequestEntity("{\"timeSpent\" : \"" + timeSpent + "\"" +
(StringUtil.isNotEmpty(comment) ? ", \"comment\" : " + comment : "")
+ " }", "application/json", "UTF-8"));
client.executeMethod(method);
@@ -230,11 +230,6 @@ public class JiraRepository extends BaseRepositoryImpl {
}
}
private static long calculateTimeSpent(final int timeSpentInMinutes) {
int days = timeSpentInMinutes / 60 / 24;
return (days * 8 * 60 + timeSpentInMinutes % (60 * 24)) * 60;
}
private void checkVersion(final HttpClient client) throws Exception {
GetMethod method = new GetMethod(getUrl() + "/rest/api/2/project");
client.executeMethod(method);
@@ -194,7 +194,7 @@ public abstract class TaskRepository {
return "{id} (e.g. FOO-001), {summary}, {number} (e.g. 001), {project} (e.g. FOO)";
}
public void updateTimeSpent(final LocalTask task, final int timeSpentInMinutes, final String comment) throws Exception {
public void updateTimeSpent(final LocalTask task, final String timeSpent, final String comment) throws Exception {
throw new UnsupportedOperationException();
}
@@ -282,9 +282,9 @@ public class YouTrackRepository extends BaseRepositoryImpl {
private static final Logger LOG = Logger.getInstance("#com.intellij.tasks.youtrack.YouTrackRepository");
@Override
public void updateTimeSpent(final LocalTask task, final int timeSpentInMinutes, final String comment) throws Exception {
public void updateTimeSpent(final LocalTask task, final String timeSpent, final String comment) throws Exception {
checkVersion();
final HttpMethod method = doREST("/rest/issue/execute/" + task.getId() + "?command=work+Today+" + timeSpentInMinutes + "m+" + comment, true);
final HttpMethod method = doREST("/rest/issue/execute/" + task.getId() + "?command=work+Today+" + timeSpent.replaceAll(" ", "+") + "+" + comment, true);
if (method.getStatusCode() != 200) {
InputStream stream = method.getResponseBodyAsStream();
String message = new SAXBuilder(false).build(stream).getRootElement().getText();
@@ -104,7 +104,7 @@ public class SendTimeTrackingInformationDialog extends DialogWrapper {
if (repository != null &&
repository.isSupported(TaskRepository.TIME_MANAGEMENT)) {
try {
repository.updateTimeSpent(myTask, timeSpent, myCommentTextArea.getText());
repository.updateTimeSpent(myTask, timeSpentText, myCommentTextArea.getText());
myTask.setLastPost(new Date());
}
catch (Exception e1) {