.timeSpent(getTimeLogged()) .startDate(getParsedStartDate()) .comment(getComment()) .visibility(visibility); if (ADJUST_ESTIMATE_NEW.equalsIgnoreCase(adjustEstimate)) .newEstimate(getNewEstimate()) .buildNewEstimate(); worklogResult = worklogService.validateCreateWithNewEstimate(getJiraServiceContext(), params); .adjustmentAmount(getAdjustmentAmount()) .buildAdjustmentAmount(); worklogResult = worklogService.validateCreateWithManuallyAdjustedEstimate(getJiraServiceContext(), params); final WorklogInputParameters params = builder.build(); worklogResult = worklogService.validateCreate(getJiraServiceContext(), params);
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())); } } }
builder.newEstimate(newEstimate); builder.adjustmentAmount(increaseBy); builder.adjustmentAmount(reduceBy);
builder.timeSpent(timeSpent); builder.timeSpent(timeSpent); builder.worklogId(existingWorklog.getId()); builder.timeSpent(timeSpent != null ? timeSpent : getTimeLoggedString(existingWorklog.getTimeSpent())); builder.startDate(start != null ? start : existingWorklog.getStartDate()); builder.comment(request.getComment() != null ? request.getComment() : existingWorklog.getComment()); if (request.getVisibility() != null) builder.visibility(Visibilities.fromVisibilityBean(request.getVisibility(), getProjectRoleManager())); builder.visibility(Visibilities.publicVisibility()); builder.visibility(Visibilities.fromGroupAndRoleId(existingWorklog.getGroupLevel(), existingWorklog.getRoleLevelId())); return builder.buildAll();
.timeSpent(timeSpent) .startDate(startDate) .comment(comment) .groupLevel(groupLevel) .roleLevelId(roleLevelId) .newEstimate(newRemainingEstimate) .buildNewEstimate(); WorklogNewEstimateResult worklogResult = worklogService.validateCreateWithNewEstimate(serviceContext, params); checkAndThrowValidationException(serviceContext.getErrorCollection());
if (WorklogValue.AdjustEstimate.NEW == value.adjustEstimate()) worklogResult = getWorklogService().validateCreateWithNewEstimate(jiraServiceContext, inputBuilder.buildNewEstimate()); worklogResult = getWorklogService().validateCreateWithManuallyAdjustedEstimate(jiraServiceContext, inputBuilder.buildAdjustmentAmount()); worklogResult = getWorklogService().validateCreate(jiraServiceContext, inputBuilder.build());
builder.timeSpent(timeSpent); builder.timeSpent(timeSpent); builder.startDate(request.getStarted() != null ? request.getStarted() : new Date()); builder.comment(request.getComment()); builder.visibility(Visibilities.fromVisibilityBean(request.getVisibility(), getProjectRoleManager())); return builder.buildAll();
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()); }
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()); }
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()); }
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()); }
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()); }
@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; }
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 + "_"); }