public List<Worklog> getIssueWorklogsObjects(Issue issue) { final JiraServiceContextImpl serviceContext = new JiraServiceContextImpl(authenticationContext.getUser()); return worklogService.getByIssueVisibleToUser(serviceContext, issue); }
public RemoteWorklog[] getWorklogs(final User user, final String issueKey) throws RemoteException, RemotePermissionException, RemoteValidationException { JiraServiceContext serviceContext = new JiraServiceContextImpl(user, new SimpleErrorCollection()); Issue issue = getIssueFromKey(issueKey); List workLogs = worklogService.getByIssueVisibleToUser(serviceContext, issue); RemoteWorklog[] remoteWorkLogs = new RemoteWorklog[workLogs.size()]; int i = 0; for (Iterator iterator = workLogs.iterator(); iterator.hasNext();) { Worklog worklog = (Worklog) iterator.next(); remoteWorkLogs[i++] = RemoteWorklogImpl.copyToRemoteWorkLog(worklog, getJiraDurationUtils()); } return remoteWorkLogs; }
@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 FieldJsonRepresentation getJsonFromIssue(Issue issue, boolean renderedVersionRequested, final @Nullable FieldLayoutItem fieldLayoutItem) { final JiraServiceContextImpl serviceContext = new JiraServiceContextImpl(authenticationContext.getUser()); final PagedList<Worklog> worklogs = getWorklogService().getByIssueVisibleToUser(serviceContext, issue, 20); if (!serviceContext.getErrorCollection().hasAnyErrors()) { WorklogWithPaginationBean worklogWithPaginationBean = new WorklogWithPaginationBean(); worklogWithPaginationBean.setMaxResults(worklogs.getPageSize()); worklogWithPaginationBean.setTotal(worklogs.getSize()); worklogWithPaginationBean.setStartAt(0); worklogWithPaginationBean.setWorklogs(WorklogJsonBean.asBeans(worklogs.getPage(0), jiraBaseUrls, ComponentAccessor.getUserManager(), ComponentAccessor.getComponent(TimeTrackingConfiguration.class), authenticationContext.getUser(), emailFormatter)); FieldJsonRepresentation fieldJsonRepresentation = new FieldJsonRepresentation(new JsonData(worklogWithPaginationBean)); if (renderedVersionRequested) { WorklogWithPaginationBean renderedWorklogBean = new WorklogWithPaginationBean(); renderedWorklogBean.setMaxResults(worklogs.getPageSize()); renderedWorklogBean.setTotal(worklogs.getSize()); renderedWorklogBean.setStartAt(0); renderedWorklogBean.setWorklogs(WorklogJsonBean.asRenderedBeans(worklogs.getPage(0), jiraBaseUrls, fieldLayoutItem != null ? fieldLayoutItem.getRendererType() : null, issue.getIssueRenderContext(), authenticationContext.getUser(), emailFormatter)); fieldJsonRepresentation.setRenderedData(new JsonData(renderedWorklogBean)); } return fieldJsonRepresentation; } return null; }