/** * Returns the worklog being deleted * * @return worklog * @since v3.10.1 */ public Worklog getWorklog() { if (worklog == null && worklogResult != null) { worklog = worklogResult.getWorklog(); } return worklog; }
/** * Returns the worklog updated * * @return worklog * @since v3.10.1 */ public Worklog getWorklog() { if (worklog == null && worklogResult != null) { worklog = worklogResult.getWorklog(); } return worklog; }
/** * Returns the worklog created * * @return worklog * @since v3.10.1 */ public Worklog getWorklog() { if (worklog == null && worklogResult != null) { worklog = worklogResult.getWorklog(); } return worklog; }
@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; }
@Override public Worklog createAndAutoAdjustRemainingEstimate(JiraServiceContext jiraServiceContext, WorklogResult worklogResult, boolean dispatchEvent) { ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); if (worklogResult == null || worklogResult.getWorklog() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.null")); return null; } if (worklogResult.getWorklog().getIssue() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return null; } Long newEstimate = reduceEstimate(worklogResult.getWorklog().getIssue(), worklogResult.getWorklog().getTimeSpent()); return create(jiraServiceContext, worklogResult, newEstimate, dispatchEvent); }
/** * Used for copying the {@link WorklogResult} received from the base <code>validate</code> method and adding on the * <code>adjustmentAmount</code>. * * @param worklogResult the worklog result to copy; must not be null. * @param adjustmentAmount the adjustment amount in seconds * @return Creates a {@link WorklogResult} that contains the {@link Worklog} and the adjustment amount. The editable check will be required. */ public static WorklogAdjustmentAmountResult createAdjustmentAmount(final WorklogResult worklogResult, final Long adjustmentAmount) { notNull("worklogResult", worklogResult); return createAdjustmentAmount(worklogResult.getWorklog(), adjustmentAmount, worklogResult.isEditableCheckRequired()); }
@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; }
/** * Used for copying the {@link WorklogResult} received from the base <code>validate</code> method and adding on the * <code>newEstimate</code>. * * @param worklogResult the worklog result to copy; must not be null. * @param newEstimate the new estimate in seconds * @return Creates a {@link WorklogResult} that contains the {@link Worklog} and the new estimate. The editable check will be required. */ public static WorklogNewEstimateResult createNewEstimate(final WorklogResult worklogResult, final Long newEstimate) { notNull("worklogResult", worklogResult); return createNewEstimate(worklogResult.getWorklog(), newEstimate, worklogResult.isEditableCheckRequired()); }
protected Worklog update(JiraServiceContext jiraServiceContext, WorklogResult worklogResult, Long newEstimate, boolean dispatchEvent) { Worklog updatedWorklog = null; ApplicationUser user = jiraServiceContext.getLoggedInApplicationUser(); ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); if (worklogResult == null || worklogResult.getWorklog() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.null")); return null; } if (worklogResult.getWorklog().getIssue() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return null; } if (worklogResult.getWorklog().getId() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.id.null")); return null; } // Re-do the permission check if (hasPermissionToUpdate(jiraServiceContext, worklogResult.getWorklog())) { updatedWorklog = worklogManager.update(user, worklogResult.getWorklog(), newEstimate, dispatchEvent); } return updatedWorklog; }
protected boolean delete(JiraServiceContext jiraServiceContext, WorklogResult worklogResult, Long newEstimate, boolean dispatchEvent) { ApplicationUser user = jiraServiceContext.getLoggedInApplicationUser(); ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); if (worklogResult == null || worklogResult.getWorklog() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.null")); return false; } if (worklogResult.getWorklog().getIssue() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return false; } if (worklogResult.getWorklog().getId() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.id.null")); return false; } // Re-do the permission check if (hasPermissionToDelete(jiraServiceContext, worklogResult.getWorklog())) { return worklogManager.delete(user, worklogResult.getWorklog(), newEstimate, dispatchEvent); } return false; }
@Override public boolean deleteAndAutoAdjustRemainingEstimate(JiraServiceContext jiraServiceContext, WorklogResult worklogResult, boolean dispatchEvent) { ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); //these null checks are duplicated in update() but must be run before passing worklog to getAutoAdjustNewEstimateOnUpdate() if (worklogResult == null || worklogResult.getWorklog() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.null")); return false; } if (worklogResult.getWorklog().getIssue() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return false; } if (worklogResult.getWorklog().getId() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.id.null")); return false; } Long timeSpent = worklogResult.getWorklog().getTimeSpent(); Long newEstimate = increaseEstimate(worklogResult.getWorklog().getIssue(), timeSpent); return delete(jiraServiceContext, worklogResult, newEstimate, dispatchEvent); }
protected Worklog create(JiraServiceContext jiraServiceContext, WorklogResult worklogResult, Long newEstimate, boolean dispatchEvent) { Worklog newWorklog = null; ApplicationUser user = jiraServiceContext.getLoggedInApplicationUser(); ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); if (worklogResult == null || worklogResult.getWorklog() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.null")); return null; } if (worklogResult.getWorklog().getIssue() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return null; } // Re-do the permission check if (hasPermissionToCreate(jiraServiceContext, worklogResult.getWorklog().getIssue(), worklogResult.isEditableCheckRequired())) { newWorklog = worklogManager.create(user, worklogResult.getWorklog(), newEstimate, dispatchEvent); } return newWorklog; }
if (worklogResult == null || worklogResult.getWorklog() == null) if (worklogResult.getWorklog().getIssue() == null) if (worklogResult.getWorklog().getId() == null) Worklog originalWorklog = worklogManager.getById(worklogResult.getWorklog().getId()); errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.no.worklog.for.id", worklogResult.getWorklog().getId().toString())); return null; Long newTimeSpent = worklogResult.getWorklog().getTimeSpent(); Long newEstimate = getAutoAdjustNewEstimateOnUpdate(worklogResult.getWorklog().getIssue(), newTimeSpent, originalTimeSpent); return update(jiraServiceContext, worklogResult, newEstimate, dispatchEvent);