@Override public Worklog validateAndPerformAndAutoAdjustEstimate(JiraServiceContext serviceContext, Issue issue, WorklogInputParameters worklogInputParameters) { WorklogResult worklogResult = getWorklogService().validateCreate(serviceContext, worklogInputParameters); return getWorklogService().createAndAutoAdjustRemainingEstimate(serviceContext, worklogResult, true); }
@Override public Worklog validateAndPerformAndLeaveEstimate(JiraServiceContext serviceContext, Issue issue, WorklogInputParameters worklogInputParameters) { WorklogResult worklogResult = getWorklogService().validateCreate(serviceContext, worklogInputParameters); return getWorklogService().createAndRetainRemainingEstimate(serviceContext, worklogResult, true); }
@Override public Worklog validateAndPerformAndSetNewEstimate(JiraServiceContext serviceContext, Issue issue, WorklogInputParameters worklogInputParameters) { WorklogNewEstimateResult worklogResult = getWorklogService().validateCreateWithNewEstimate(serviceContext, (WorklogNewEstimateInputParameters) worklogInputParameters); return getWorklogService().createWithNewRemainingEstimate(serviceContext, worklogResult, true); }
@Override public Worklog validateAndPerformAndAutoAdjustEstimate(JiraServiceContext serviceContext, Issue issue, WorklogInputParameters worklogInputParameters) { WorklogResult worklogResult = getWorklogService().validateUpdate(serviceContext, worklogInputParameters); return getWorklogService().updateAndAutoAdjustRemainingEstimate(serviceContext, worklogResult, true); }
public void createValue(Issue issue, WorklogValue value) { final WorklogResult worklogResult = value.worklogResult(); // note that we don't expect this to be actually used but we need to pass it anyway final JiraServiceContext jiraServiceContext = new JiraServiceContextImpl(authenticationContext.getUser()); // Based on how the user wants to update the remaining estimate we will call the correct do method on the service switch (value.adjustEstimate()) { case LEAVE: getWorklogService().createAndRetainRemainingEstimate(jiraServiceContext, worklogResult, true); break; case NEW: getWorklogService().createWithNewRemainingEstimate(jiraServiceContext, (WorklogNewEstimateResult) worklogResult, true); break; case MANUAL: getWorklogService().createWithManuallyAdjustedEstimate(jiraServiceContext, (WorklogAdjustmentAmountResult) worklogResult, true); break; default : getWorklogService().createAndAutoAdjustRemainingEstimate(jiraServiceContext, worklogResult, true); } }
@RequiresXsrfCheck protected String doExecute() throws Exception { // Based on how the user wants to update the remaining estimate we will call the correct do method on the service if (ADJUST_ESTIMATE_AUTO.equalsIgnoreCase(adjustEstimate)) { worklogService.deleteAndAutoAdjustRemainingEstimate(getJiraServiceContext(), worklogResult, true); } else if (ADJUST_ESTIMATE_NEW.equalsIgnoreCase(adjustEstimate)) { worklogService.deleteWithNewRemainingEstimate(getJiraServiceContext(), (WorklogNewEstimateResult) worklogResult, true); } else if (ADJUST_ESTIMATE_MANUAL.equalsIgnoreCase(adjustEstimate)) { worklogService.deleteWithManuallyAdjustedEstimate(getJiraServiceContext(), (WorklogAdjustmentAmountResult) worklogResult, true); } else { worklogService.deleteAndRetainRemainingEstimate(getJiraServiceContext(), worklogResult, true); } if (getHasErrorMessages()) { return ERROR; } if (isInlineDialogMode()) { return returnComplete(); } return getRedirect("/browse/" + getIssue().getString("key")); }
.newEstimate(getNewEstimate()) .buildNewEstimate(); worklogResult = worklogService.validateCreateWithNewEstimate(getJiraServiceContext(), params); .adjustmentAmount(getAdjustmentAmount()) .buildAdjustmentAmount(); worklogResult = worklogService.validateCreateWithManuallyAdjustedEstimate(getJiraServiceContext(), params); worklogResult = worklogService.validateCreate(getJiraServiceContext(), params);
@RequiresXsrfCheck protected String doExecute() throws Exception { // Based on how the user wants to update the remaining estimate we will call the correct do method on the service if (ADJUST_ESTIMATE_AUTO.equalsIgnoreCase(adjustEstimate)) { worklogService.updateAndAutoAdjustRemainingEstimate(getJiraServiceContext(), worklogResult, true); } else if (ADJUST_ESTIMATE_NEW.equalsIgnoreCase(adjustEstimate)) { worklogService.updateWithNewRemainingEstimate(getJiraServiceContext(), (WorklogNewEstimateResult) worklogResult, true); } else { worklogService.updateAndRetainRemainingEstimate(getJiraServiceContext(), worklogResult, true); } if (getHasErrorMessages()) { return ERROR; } if (isInlineDialogMode()) { return returnComplete(); } return getRedirect("/browse/" + getIssue().getString("key")); }
@Override public List<IssueAction> getActions(Issue issue, ApplicationUser remoteUser) { JiraServiceContextImpl context = new JiraServiceContextImpl(remoteUser, new SimpleErrorCollection()); List<Worklog> userWorklogs = worklogService.getByIssueVisibleToUser(context, issue); List<IssueAction> worklogs = Lists.newArrayListWithCapacity(userWorklogs.size()); final Locale userLocale = context.getI18nBean().getLocale(); for (Worklog userWorklog : userWorklogs) { boolean canEditWorklog = worklogService.hasPermissionToUpdate(context, userWorklog); boolean canDeleteWorklog = worklogService.hasPermissionToDelete(context, userWorklog); worklogs.add(new WorklogAction(descriptor, userWorklog, jiraDurationUtils, canEditWorklog, canDeleteWorklog, fieldLayoutManager, rendererManager, userLocale, userFormats)); } // This is a bit of a hack to indicate that there are no comments to display if (worklogs.isEmpty()) { IssueAction action = new GenericMessageAction(descriptor.getI18nBean().getText("viewissue.nowork")); return Lists.newArrayList(action); } Collections.sort(worklogs, IssueActionComparator.COMPARATOR); return worklogs; }
@Override public Worklog validateAndPerformAndAutoAdjustEstimate(JiraServiceContext serviceContext, Issue issue, WorklogInputParameters worklogInputParameters) { WorklogResult worklogResult = getWorklogService().validateDelete(serviceContext, worklogInputParameters.getWorklogId()); boolean success = getWorklogService().deleteAndAutoAdjustRemainingEstimate(serviceContext, worklogResult, true); return success ? worklogResult.getWorklog() : null; }
public boolean hasPermissionToUpdateWorklog(User user, String worklogId) throws RemoteException, RemoteValidationException { JiraServiceContext serviceContext = new JiraServiceContextImpl(user, new SimpleErrorCollection()); Long id = SoapUtils.toLongRequired(worklogId); Worklog worklog = worklogService.getById(serviceContext, id); // getById does not currenty return errors but it might so we do this code checkAndThrowValidationException(serviceContext.getErrorCollection()); return worklog != null && worklogService.hasPermissionToUpdate(serviceContext, worklog); }
@Override public Worklog validateAndPerformAndLeaveEstimate(JiraServiceContext serviceContext, Issue issue, WorklogInputParameters worklogInputParameters) { WorklogResult worklogResult = getWorklogService().validateDelete(serviceContext, worklogInputParameters.getWorklogId()); boolean success = getWorklogService().deleteAndRetainRemainingEstimate(serviceContext, worklogResult, true); return success ? worklogResult.getWorklog() : null; }
@Override public Worklog validateAndPerformAndSetNewEstimate(JiraServiceContext serviceContext, Issue issue, WorklogInputParameters worklogInputParameters) { WorklogNewEstimateResult worklogResult = getWorklogService().validateDeleteWithNewEstimate(serviceContext, worklogInputParameters.getWorklogId(), ((WorklogNewEstimateInputParameters) worklogInputParameters).getNewEstimate()); boolean success = getWorklogService().deleteWithNewRemainingEstimate(serviceContext, worklogResult, true); return success ? worklogResult.getWorklog() : null; }
public boolean hasPermissionToDeleteWorklog(User user, String worklogId) throws RemoteException, RemoteValidationException { JiraServiceContext serviceContext = new JiraServiceContextImpl(user, new SimpleErrorCollection()); Long id = SoapUtils.toLongRequired(worklogId); Worklog worklog = worklogService.getById(serviceContext, id); // getById does not currenty return errors but it might so we do this code checkAndThrowValidationException(serviceContext.getErrorCollection()); return worklog != null && worklogService.hasPermissionToDelete(serviceContext, worklog); }
private Option<String> worklogComment(JiraActivityItem item) { for (Long worklogId : getWorklogId(item)) { Worklog worklog = worklogService.getById(new JiraServiceContextImpl(authenticationContext.getLoggedInUser()), worklogId); if (worklog != null) { String comment = worklog.getComment(); if (!isBlank(comment)) { return some(comment); } } } return none(); }
public List<Worklog> getIssueWorklogsObjects(Issue issue) { final JiraServiceContextImpl serviceContext = new JiraServiceContextImpl(authenticationContext.getUser()); return worklogService.getByIssueVisibleToUser(serviceContext, issue); }
worklog = worklogService.createAndAutoAdjustRemainingEstimate(getJiraServiceContext(), worklogResult, true); worklog = worklogService.createWithNewRemainingEstimate(getJiraServiceContext(), (WorklogNewEstimateResult) worklogResult, true); worklog = worklogService.createWithManuallyAdjustedEstimate(getJiraServiceContext(), (WorklogAdjustmentAmountResult) worklogResult, true); worklog = worklogService.createAndRetainRemainingEstimate(getJiraServiceContext(), worklogResult, true);
if (WorklogValue.AdjustEstimate.NEW == value.adjustEstimate()) worklogResult = getWorklogService().validateCreateWithNewEstimate(jiraServiceContext, inputBuilder.buildNewEstimate()); worklogResult = getWorklogService().validateCreateWithManuallyAdjustedEstimate(jiraServiceContext, inputBuilder.buildAdjustmentAmount()); worklogResult = getWorklogService().validateCreate(jiraServiceContext, inputBuilder.build());
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 deleteWorklogAndAutoAdjustRemainingEstimate(User user, String remoteWorklogId) throws RemoteException, RemotePermissionException, RemoteValidationException { JiraServiceContext serviceContext = new JiraServiceContextImpl(user, new SimpleErrorCollection()); Long id = SoapUtils.toLongRequired(remoteWorklogId); WorklogResult worklogResult = worklogService.validateDelete(serviceContext, id); checkAndThrowValidationException(serviceContext.getErrorCollection()); if (worklogResult == null) { throw new RemoteValidationException(getI18nHelper().getText("error.unexpected.condition", "WorklogService.validateDelete")); } worklogService.deleteAndAutoAdjustRemainingEstimate(serviceContext, worklogResult, true); checkAndThrowRemoteException(serviceContext.getErrorCollection()); }