public Either<CommitHookErrors, Worklog> handle(ApplicationUser user, MutableIssue issue, String commandName, List<String> args) { JiraServiceContextImpl jiraServiceContext = new JiraServiceContextImpl(user); WorklogResult result = worklogService.validateCreate( jiraServiceContext, WorklogInputParametersImpl.builder() .issue(issue) .timeSpent(args.isEmpty() ? null : args.get(0)) .comment(args.size() > 1 ? args.get(1) : null) .startDate(new Date()) .build()); if (!jiraServiceContext.getErrorCollection().hasAnyErrors()) { return Either.value(worklogService.createAndAutoAdjustRemainingEstimate( jiraServiceContext, result, true)); } else { return Either.error(CommitHookErrors.fromErrorCollection( CMD_TYPE.getName(), issue.getKey(), jiraServiceContext.getErrorCollection())); } } }
.timeSpent(getTimeLogged()) .startDate(getParsedStartDate()) .comment(getComment())
builder.timeSpent(timeSpent); builder.timeSpent(timeSpent); builder.timeSpent(timeSpent != null ? timeSpent : getTimeLoggedString(existingWorklog.getTimeSpent())); builder.startDate(start != null ? start : existingWorklog.getStartDate()); builder.comment(request.getComment() != null ? request.getComment() : existingWorklog.getComment());
.timeSpent(timeSpent) .startDate(startDate) .comment(comment)
public RemoteWorklog addWorklogAndAutoAdjustRemainingEstimate(final User user, final String issueKey, final RemoteWorklog remoteWorklog) throws RemoteException, RemotePermissionException, RemoteValidationException { JiraServiceContext serviceContext = new JiraServiceContextImpl(user, new SimpleErrorCollection()); Issue issue = getIssueFromKey(issueKey); String timeSpent = remoteWorklog.getTimeSpent(); Date startDate = remoteWorklog.getStartDate(); String comment = remoteWorklog.getComment(); String groupLevel = remoteWorklog.getGroupLevel(); String roleLevelId = remoteWorklog.getRoleLevelId(); WorklogInputParameters params = WorklogInputParametersImpl .issue(issue) .timeSpent(timeSpent) .startDate(startDate) .comment(comment) .groupLevel(groupLevel) .roleLevelId(roleLevelId) .build(); WorklogResult worklogResult = worklogService.validateCreate(serviceContext, params); checkAndThrowValidationException(serviceContext.getErrorCollection()); if (worklogResult == null) { throw new RemoteValidationException(getI18nHelper().getText("error.unexpected.condition", "WorklogService.validateCreate")); } Worklog createdWorklog = worklogService.createAndAutoAdjustRemainingEstimate(serviceContext, worklogResult, true); checkAndThrowRemoteException(serviceContext.getErrorCollection()); return RemoteWorklogImpl.copyToRemoteWorkLog(createdWorklog, getJiraDurationUtils()); }
public RemoteWorklog addWorklogAndRetainRemainingEstimate(final User user, final String issueKey, final RemoteWorklog remoteWorklog) throws RemoteException, RemotePermissionException, RemoteValidationException { JiraServiceContext serviceContext = new JiraServiceContextImpl(user, new SimpleErrorCollection()); Issue issue = getIssueFromKey(issueKey); String timeSpent = remoteWorklog.getTimeSpent(); Date startDate = remoteWorklog.getStartDate(); String comment = remoteWorklog.getComment(); String groupLevel = remoteWorklog.getGroupLevel(); String roleLevelId = remoteWorklog.getRoleLevelId(); WorklogInputParameters params = WorklogInputParametersImpl .issue(issue) .timeSpent(timeSpent) .startDate(startDate) .comment(comment) .groupLevel(groupLevel) .roleLevelId(roleLevelId) .build(); WorklogResult worklogResult = worklogService.validateCreate(serviceContext, params); checkAndThrowValidationException(serviceContext.getErrorCollection()); if (worklogResult == null) { throw new RemoteValidationException(getI18nHelper().getText("error.unexpected.condition", "WorklogService.validateCreate")); } Worklog createdWorklog = worklogService.createAndRetainRemainingEstimate(serviceContext, worklogResult, true); checkAndThrowRemoteException(serviceContext.getErrorCollection()); return RemoteWorklogImpl.copyToRemoteWorkLog(createdWorklog, getJiraDurationUtils()); }
private WorklogInputParametersImpl.Builder getWorklogInputParams(Issue issue, WorklogValue value) { boolean editableCheckRequired = value.isEditIssue(); final CommentVisibility commentVisibility = new CommentVisibility(value.commentLevel()); final Visibility visibility = Visibilities.fromGroupAndStrRoleId(commentVisibility.getGroupLevel(), commentVisibility.getRoleLevel()); final Date parsedStartDate = WorklogValue.Builder.parseStartDate(getOutlookDateManager(), authenticationContext.getLocale(), value.startDate()); return WorklogInputParametersImpl .issue(issue) .timeSpent(value.timeLogged()) .startDate(parsedStartDate) .worklogId(value.id()) .comment(value.comment()) .visibility(visibility) .editableCheckRequired(editableCheckRequired) .newEstimate(value.newEstimate()) .adjustmentAmount(value.adjustmentAmount()) .errorFieldPrefix(IssueFieldConstants.WORKLOG + "_"); }
/** * @param timeSpent the amount of time spent * @return a Builder with the time spent pre-populated */ public static Builder timeSpent(final String timeSpent) { return new Builder().timeSpent(timeSpent); }