@Override public Worklog validateAndPerformAndLeaveEstimate(JiraServiceContext serviceContext, Issue issue, WorklogInputParameters worklogInputParameters) { WorklogResult worklogResult = getWorklogService().validateCreate(serviceContext, worklogInputParameters); return getWorklogService().createAndRetainRemainingEstimate(serviceContext, worklogResult, true); }
worklogResult = worklogService.validateCreate(getJiraServiceContext(), params);
worklogResult = getWorklogService().validateCreate(jiraServiceContext, inputBuilder.build());
@Override public Worklog validateAndPerformAndAutoAdjustEstimate(JiraServiceContext serviceContext, Issue issue, WorklogInputParameters worklogInputParameters) { WorklogResult worklogResult = getWorklogService().validateCreate(serviceContext, worklogInputParameters); return getWorklogService().createAndAutoAdjustRemainingEstimate(serviceContext, worklogResult, true); }
/** * Handle a commit comment command * * @param ctx The context * @param issue The issue the command is for * @param command The command word, as entered by the user * @param arguments The arguments supplied to the command */ public void handle(JiraServiceContext ctx, MutableIssue issue, String command, String arguments) { Matcher matcher = timePattern.matcher(arguments); if (matcher.find()) { String timeLogged = matcher.group(1); String comment = matcher.group(2); // We need to instantiate a new ctx with a new error collection, because the ctx we were passed might // already have errors in it, and so we won't know if the errors in it are from this validation or not JiraServiceContext tmpCtx = new JiraServiceContextImpl(ctx.getUser()); Worklog worklog = worklogService.validateCreate(tmpCtx, issue, timeLogged, new Date(), comment, null, null); // Check that there are no errors if (!tmpCtx.getErrorCollection().hasAnyErrors()) { worklogService.createAndAutoAdjustRemainingEstimate(tmpCtx, worklog, true); } ctx.getErrorCollection().addErrorCollection(tmpCtx.getErrorCollection()); } } }
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())); } } }
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()); }