/** * Will build the {@link WorklogInputParameters} object and pass in every variable independent of which * adjustment option you have picked. * * @return a {@link WorklogInputParameters} object with the built parameters. */ public WorklogInputParameters buildAll() { return new WorklogInputParametersImpl(worklogId, issue, timeSpent, startDate, comment, groupLevel, roleLevelId, getVisibility(), newEstimate, adjustmentAmount, editableCheckRequired, errorFieldPrefix); }
@Override public WorklogInputParameters prepareData(JiraServiceContextImpl serviceContext, Issue issue, WorklogJsonBean request, IssueWorklogResource.WorklogAdjustmentRequest adjustment) { ErrorCollection errors = serviceContext.getErrorCollection(); Worklog existingWorklog = getAndValidateExistingWorklog(request, errors, serviceContext); if (!errors.hasAnyErrors()) { WorklogInputParametersImpl.Builder builder = WorklogInputParametersImpl .issue(issue); addAdjustmentParams(adjustment, builder, errors, DELETE, serviceContext); if (!errors.hasAnyErrors()) { builder.worklogId(existingWorklog.getId()); return builder.buildAll(); } } return null; }
public void doValidation() { final CommentVisibility commentVisibility = getCommentVisibility(); final Visibility visibility = Visibilities.fromGroupAndStrRoleId(commentVisibility.getGroupLevel(), commentVisibility.getRoleLevel()); // Call the correct validation on the service so that we can get the worklog to update final WorklogInputParametersImpl.Builder builder = WorklogInputParametersImpl .timeSpent(getTimeLogged()) .worklogId(getWorklogId()) .startDate(getParsedStartDate()) .comment(getComment()) .visibility(visibility); if (ADJUST_ESTIMATE_NEW.equalsIgnoreCase(adjustEstimate)) { final WorklogNewEstimateInputParameters params = builder .newEstimate(getNewEstimate()) .buildNewEstimate(); worklogResult = worklogService.validateUpdateWithNewEstimate(getJiraServiceContext(), params); } else { final WorklogInputParameters params = builder.build(); worklogResult = worklogService.validateUpdate(getJiraServiceContext(), params); } }
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 void updateWorklogAndAutoAdjustRemainingEstimate(User user, RemoteWorklog remoteWorklog) throws RemoteException, RemotePermissionException, RemoteValidationException { JiraServiceContext serviceContext = new JiraServiceContextImpl(user, new SimpleErrorCollection()); Long id = SoapUtils.toLongRequired(remoteWorklog.getId()); String timeSpent = remoteWorklog.getTimeSpent(); Date startDate = remoteWorklog.getStartDate(); String comment = remoteWorklog.getComment(); String groupLevel = remoteWorklog.getGroupLevel(); String roleLevelId = remoteWorklog.getRoleLevelId(); final WorklogInputParameters params = WorklogInputParametersImpl .timeSpent(timeSpent) .worklogId(id) .startDate(startDate) .comment(comment) .groupLevel(groupLevel) .roleLevelId(roleLevelId) .build(); WorklogResult worklogResult = worklogService.validateUpdate(serviceContext, params); checkAndThrowValidationException(serviceContext.getErrorCollection()); if (worklogResult == null) { throw new RemoteValidationException(getI18nHelper().getText("error.unexpected.condition", "WorklogService.validateUpdate")); } worklogService.updateAndAutoAdjustRemainingEstimate(serviceContext, worklogResult, true); checkAndThrowRemoteException(serviceContext.getErrorCollection()); }
.issue(getIssueObject()) .timeSpent(getTimeLogged()) .startDate(getParsedStartDate())
public void updateWorklogAndRetainRemainingEstimate(User user, RemoteWorklog remoteWorklog) throws RemoteException, RemotePermissionException, RemoteValidationException { JiraServiceContext serviceContext = new JiraServiceContextImpl(user, new SimpleErrorCollection()); Long id = SoapUtils.toLongRequired(remoteWorklog.getId()); String timeSpent = remoteWorklog.getTimeSpent(); Date startDate = remoteWorklog.getStartDate(); String comment = remoteWorklog.getComment(); String groupLevel = remoteWorklog.getGroupLevel(); String roleLevelId = remoteWorklog.getRoleLevelId(); final WorklogInputParameters params = WorklogInputParametersImpl .timeSpent(timeSpent) .worklogId(id) .startDate(startDate) .comment(comment) .groupLevel(groupLevel) .roleLevelId(roleLevelId) .build(); WorklogResult worklogResult = worklogService.validateUpdate(serviceContext, params); checkAndThrowValidationException(serviceContext.getErrorCollection()); if (worklogResult == null) { throw new RemoteValidationException(getI18nHelper().getText("error.unexpected.condition", "WorklogService.validateUpdate")); } worklogService.updateAndRetainRemainingEstimate(serviceContext, worklogResult, true); checkAndThrowRemoteException(serviceContext.getErrorCollection()); }
/** * Use this method to build the {@link WorklogAdjustmentAmountInputParameters} object required for the * "manual adjustment" (or "adjustment amount") service calls. * * @return a {@link WorklogAdjustmentAmountInputParameters} object with the built parameters. */ public WorklogAdjustmentAmountInputParameters buildAdjustmentAmount() { return new WorklogInputParametersImpl(worklogId, issue, timeSpent, startDate, comment, groupLevel, roleLevelId, getVisibility(), null, adjustmentAmount, editableCheckRequired, errorFieldPrefix); }
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 + "_"); }
public void updateWorklogWithNewRemainingEstimate(User user, RemoteWorklog remoteWorklog, String newRemainingEstimate) throws RemoteException, RemotePermissionException, RemoteValidationException { JiraServiceContext serviceContext = new JiraServiceContextImpl(user, new SimpleErrorCollection()); Long id = SoapUtils.toLongRequired(remoteWorklog.getId()); String timeSpent = remoteWorklog.getTimeSpent(); Date startDate = remoteWorklog.getStartDate(); String comment = remoteWorklog.getComment(); String groupLevel = remoteWorklog.getGroupLevel(); String roleLevelId = remoteWorklog.getRoleLevelId(); final WorklogNewEstimateInputParameters params = WorklogInputParametersImpl .timeSpent(timeSpent) .worklogId(id) .startDate(startDate) .comment(comment) .groupLevel(groupLevel) .roleLevelId(roleLevelId) .newEstimate(newRemainingEstimate) .buildNewEstimate(); WorklogNewEstimateResult worklogResult = worklogService.validateUpdateWithNewEstimate(serviceContext, params); checkAndThrowValidationException(serviceContext.getErrorCollection()); if (worklogResult == null) { throw new RemoteValidationException(getI18nHelper().getText("error.unexpected.condition", "WorklogService.validateUpdateWithNewEstimate")); } worklogService.updateWithNewRemainingEstimate(serviceContext, worklogResult, true); checkAndThrowRemoteException(serviceContext.getErrorCollection()); }
/** * Use this method to build the base {@link WorklogInputParameters} object. * * @return a {@link WorklogInputParameters} object with the built parameters. */ public WorklogInputParameters build() { return new WorklogInputParametersImpl(worklogId, issue, timeSpent, startDate, comment, groupLevel, roleLevelId, getVisibility(), null, null, editableCheckRequired, errorFieldPrefix); }
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()); }
/** * Use this method to build the {@link WorklogNewEstimateInputParameters} object required for the "new estimate" * service calls. * * @return a {@link WorklogNewEstimateInputParameters} object with the built parameters. */ public WorklogNewEstimateInputParameters buildNewEstimate() { return new WorklogInputParametersImpl(worklogId, issue, timeSpent, startDate, comment, groupLevel, roleLevelId, getVisibility(), newEstimate, null, editableCheckRequired, errorFieldPrefix); }
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()); }
.issue(issue) .timeSpent(timeSpent) .startDate(startDate)