/** * @param worklog the worklog * @return Creates a simple {@link WorklogResult} that just contains the {@link Worklog} to use. The editable check will be required. */ public static WorklogResult create(final Worklog worklog) { return create(worklog, true); }
/** * Used for creating {@link WorklogResult} objects that also capture a <code>adjustmentAmount</code> to be set. * * @param worklog the worklog * @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 Worklog worklog, final Long adjustmentAmount) { return createAdjustmentAmount(worklog, adjustmentAmount, true); }
/** * Used for creating {@link WorklogResult} objects that also capture a <code>newEstimate</code> to be set. * * @param worklog the worklog * @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 Worklog worklog, final Long newEstimate) { return createNewEstimate(worklog, newEstimate, true); }
/** * 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()); }
@Override public WorklogResult validateDelete(JiraServiceContext jiraServiceContext, Long worklogId) { Worklog originalWorklog = worklogManager.getById(worklogId); // Does the user have permission to delete a worklog if (hasPermissionToDelete(jiraServiceContext, originalWorklog)) { return WorklogResultFactory.create(originalWorklog); } return null; }
@Override public WorklogAdjustmentAmountResult validateDeleteWithManuallyAdjustedEstimate(JiraServiceContext jiraServiceContext, Long worklogId, String adjustmentAmount) { WorklogResult originalWorklogResult = validateDelete(jiraServiceContext, worklogId); if (originalWorklogResult != null && isValidAdjustmentAmount(jiraServiceContext, adjustmentAmount)) { return WorklogResultFactory.createAdjustmentAmount(originalWorklogResult, getDurationForFormattedString(adjustmentAmount, jiraServiceContext)); } return null; }
@Override public WorklogNewEstimateResult validateDeleteWithNewEstimate(JiraServiceContext jiraServiceContext, Long worklogId, String newEstimate) { WorklogResult originalWorklogResult = validateDelete(jiraServiceContext, worklogId); if (originalWorklogResult != null && isValidNewEstimate(jiraServiceContext, newEstimate)) { final Long estimate = (newEstimate == null) ? null : getDurationForFormattedString(newEstimate, jiraServiceContext); return WorklogResultFactory.createNewEstimate(originalWorklogResult, estimate); } return null; }
@Override public WorklogResult validateUpdate(JiraServiceContext jiraServiceContext, final WorklogInputParameters params) { notNull("params", params); Worklog originalWorklog = worklogManager.getById(params.getWorklogId()); ApplicationUser user = jiraServiceContext.getLoggedInApplicationUser(); // Does the user have permission to edit a worklog if (hasPermissionToUpdate(jiraServiceContext, originalWorklog)) { Worklog updatedWorklog = validateParamsAndCreateWorklog(jiraServiceContext, originalWorklog.getIssue(), originalWorklog.getAuthorObject(), params.getVisibility(), params.getTimeSpent(), params.getStartDate(), params.getWorklogId(), params.getComment(), originalWorklog.getCreated(), new Date(), user, params.getErrorFieldPrefix()); if (updatedWorklog != null) { return WorklogResultFactory.create(updatedWorklog); } } return null; }
/** * 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 WorklogNewEstimateResult validateCreateWithNewEstimate(JiraServiceContext jiraServiceContext, WorklogNewEstimateInputParameters params) { WorklogResult worklogResult = validateCreate(jiraServiceContext, params); if (isValidNewEstimate(jiraServiceContext, params.getNewEstimate(), params.getErrorFieldPrefix()) && worklogResult != null) { final Long estimate = (params.getNewEstimate() == null) ? null : getDurationForFormattedString(params.getNewEstimate(), jiraServiceContext); return WorklogResultFactory.createNewEstimate(worklogResult, estimate); } return null; }
@Override public WorklogResult validateCreate(JiraServiceContext jiraServiceContext, WorklogInputParameters params) { ApplicationUser user = jiraServiceContext.getLoggedInApplicationUser(); // Does the user have permission to create a worklog if (hasPermissionToCreate(jiraServiceContext, params.getIssue(), params.isEditableCheckRequired())) { Worklog worklog = validateParamsAndCreateWorklog(jiraServiceContext, params.getIssue(), user, params.getVisibility(), params.getTimeSpent(), params.getStartDate(), null, params.getComment(), null, null, null, params.getErrorFieldPrefix()); if (worklog != null) { return WorklogResultFactory.create(worklog, params.isEditableCheckRequired()); } } return null; }
@Override public WorklogAdjustmentAmountResult validateCreateWithManuallyAdjustedEstimate(JiraServiceContext jiraServiceContext, WorklogAdjustmentAmountInputParameters params) { WorklogResult worklogResult = validateCreate(jiraServiceContext, params); if (isValidAdjustmentAmount(jiraServiceContext, params.getAdjustmentAmount(), params.getErrorFieldPrefix()) && worklogResult != null) { return WorklogResultFactory.createAdjustmentAmount(worklogResult, getDurationForFormattedString(params.getAdjustmentAmount(), jiraServiceContext)); } return null; }
@Override public WorklogNewEstimateResult validateUpdateWithNewEstimate(JiraServiceContext jiraServiceContext, final WorklogNewEstimateInputParameters params) { notNull("params", params); WorklogResult worklogResult = validateUpdate(jiraServiceContext, params); if (isValidNewEstimate(jiraServiceContext, params.getNewEstimate(), params.getErrorFieldPrefix()) && worklogResult != null) { final Long estimate = (params.getNewEstimate() == null) ? null : getDurationForFormattedString(params.getNewEstimate(), jiraServiceContext); return WorklogResultFactory.createNewEstimate(worklogResult, estimate); } return null; }