I develop a Plug-in that creates or updates a worklog if needed.
I can create worklogs with this code:
Booking booking; // object i receive from a web service if(issue != null) { WorklogInputParameters parameters = new WorklogInputParametersImpl.Builder() .issue(issue) .startDate(booking.getBookingDate()) .timeSpent(formatToMinute(booking.getTime())) .comment(booking.getDescription()) .build(); ApplicationUser user = userManager.getUserByKey(booking.getEmployeeShortcut()); if(user != null) { JiraServiceContextImpl jsci = new JiraServiceContextImpl(user); WorklogResult result = worklogService.validateCreate(jsci, parameters); worklogService.createAndAutoAdjustRemainingEstimate(jsci, result, true); } }
but i always get an error in the log:
java.lang.UnsupportedOperationException: Cannot set or mutate an ImmutableGenericValue
and the time tracking "Remaining" and "Logged" doesn't change its value. I think the error refers to that.
i think i have to change the last line "worklogService.create...()" but i also tried the other methods but they also didn't work.
updating a worklog also doesn't work.. i think there I have the same problem
thanks a lot
Community moderators have prevented the ability to post new answers.
I solved it myself.. I used MutableIssue instead of Issue, than it works.. see code below:
if(issue != null) { MuableIssue mutableIssue = issueManager.getIssueObject(issue.getId()); WorklogInputParameters parameters = new WorklogInputParametersImpl.Builder() .issue(mutableIssue) ... }
Updating works fine, but on creating i always get the error above.. the worklog creates but it doesn't set the new remaining estimate.
for updating i use this code:
WorklogInputParameters parameters = new WorklogInputParametersImpl.Builder() .issue(issue) .worklogId(booking.getWorklogID()) .startDate(booking.getBookingDate()) .timeSpent(formatToMinute(booking.getTime())) .adjustmentAmount(formatToMinute(booking.getTime())) .comment(booking.getDescription()) .build(); ApplicationUser user = userManager.getUserByKey(booking.getEmployeeShortcut()); if(user != null) { JiraServiceContextImpl jsci = new JiraServiceContextImpl(user); WorklogResult result = worklogService.validateUpdate(jsci, parameters); worklogService.updateAndAutoAdjustRemainingEstimate(jsci, result, false); }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.