Пример #1
0
  public static URI getCurrentWorkItemURI() throws TeamRepositoryException {
    if (TeamPlatform.isStarted()
        && TeamPlatform.getTeamRepositoryService().getTeamRepositories().length > 0) {
      IWorkItemHandle wih = ClientModel.getWorkItemActivationManager().getActiveWorkItem();

      if (wih == null) return null;

      for (ITeamRepository repo : TeamPlatform.getTeamRepositoryService().getTeamRepositories()) {
        IAuditableClient ac = (IAuditableClient) repo.getClientLibrary(IAuditableClient.class);
        IWorkItem wi = (IWorkItem) ac.resolveAuditable(wih, IWorkItem.SMALL_PROFILE, null);
        if (wi != null) {
          return URI.create(
              repo.getRepositoryURI()
                  + "resource/itemName/com.ibm.team.workitem.WorkItem/"
                  + wi.getId());
        }
      }
    }
    return null;
  }
Пример #2
0
  public static URI getWorkItemURI(UUID itemId) throws TeamRepositoryException {
    if (TeamPlatform.isStarted()
        && TeamPlatform.getTeamRepositoryService().getTeamRepositories().length > 0) {
      for (ITeamRepository repo : TeamPlatform.getTeamRepositoryService().getTeamRepositories()) {
        IWorkItemHandle wih = (IWorkItemHandle) IWorkItem.ITEM_TYPE.createItemHandle(itemId, null);
        IAuditableClient ac = (IAuditableClient) repo.getClientLibrary(IAuditableClient.class);
        try {
          IWorkItem wi = (IWorkItem) ac.resolveAuditable(wih, IWorkItem.SMALL_PROFILE, null);
          if (wi != null) {
            return URI.create(
                repo.getRepositoryURI()
                    + "resource/itemName/com.ibm.team.workitem.WorkItem/"
                    + wi.getId());
          }
        } catch (ItemNotFoundException e) {

        }
      }
    }
    return null;
  }