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); } }
builder.worklogId(existingWorklog.getId()); builder.timeSpent(timeSpent != null ? timeSpent : getTimeLoggedString(existingWorklog.getTimeSpent())); builder.startDate(start != null ? start : existingWorklog.getStartDate());
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()); }
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 + "_"); }
@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; }