当前位置: 首页>>代码示例>>Java>>正文


Java PullRequest类代码示例

本文整理汇总了Java中org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest的典型用法代码示例。如果您正苦于以下问题:Java PullRequest类的具体用法?Java PullRequest怎么用?Java PullRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PullRequest类属于org.eclipse.che.plugin.pullrequest.shared.dto包,在下文中一共展示了PullRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPullRequest

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
@Override
public Promise<PullRequest> getPullRequest(
    final String owner, final String repository, final String username, final String branchName) {
  return bitbucketClientService
      .getRepositoryPullRequests(owner, repository)
      .thenPromise(
          new Function<List<BitbucketPullRequest>, Promise<PullRequest>>() {
            @Override
            public Promise<PullRequest> apply(List<BitbucketPullRequest> pullRequests)
                throws FunctionException {
              for (final BitbucketPullRequest pullRequest : pullRequests) {
                final BitbucketUser author = pullRequest.getAuthor();
                final BitbucketPullRequestLocation source = pullRequest.getSource();
                if (author != null && source != null) {
                  final BitbucketPullRequestBranch branch = source.getBranch();
                  // Bitbucket Server adds '~' to authenticated user, need to substring it.
                  String name = username.startsWith("~") ? username.substring(1) : username;
                  if (name.equals(author.getUsername()) && branchName.equals(branch.getName())) {
                    return Promises.resolve(valueOf(pullRequest));
                  }
                }
              }
              return Promises.reject(
                  JsPromiseError.create(new NoPullRequestException(branchName)));
            }
          });
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:28,代码来源:BitbucketHostingService.java

示例2: getPullRequest

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
@Override
public Promise<PullRequest> getPullRequest(
    String owner, String repository, String username, final String branchName) {
  return microsoftClient
      .getPullRequests(account, collection, owner, repository)
      .thenPromise(
          new Function<List<MicrosoftPullRequest>, Promise<PullRequest>>() {
            @Override
            public Promise<PullRequest> apply(List<MicrosoftPullRequest> result)
                throws FunctionException {
              for (MicrosoftPullRequest pullRequest : result)
                if (pullRequest != null
                    && pullRequest.getSourceRefName().equals(refsHeads(branchName))) {
                  return Promises.resolve(valueOf(pullRequest));
                }
              return Promises.reject(
                  JsPromiseError.create(new NoPullRequestException(branchName)));
            }
          });
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:21,代码来源:MicrosoftHostingService.java

示例3: valueOf

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
/**
 * Converts an instance of {@link
 * org.eclipse.che.ide.ext.microsoft.shared.dto.MicrosoftPullRequest} into a {@link PullRequest}.
 *
 * @param microsoftPullRequest the MicrosoftVstsRestClient repository to convert.
 * @return the corresponding {@link PullRequest} instance or {@code null} if given
 *     microsoftRepository is {@code null}.
 */
private PullRequest valueOf(final MicrosoftPullRequest microsoftPullRequest) {
  if (microsoftPullRequest == null) {
    return null;
  }

  return dtoFactory
      .createDto(PullRequest.class)
      .withId(String.valueOf(microsoftPullRequest.getPullRequestId()))
      .withUrl(microsoftPullRequest.getUrl())
      .withHtmlUrl("")
      .withNumber(String.valueOf(microsoftPullRequest.getPullRequestId()))
      .withState(microsoftPullRequest.getStatus())
      .withHeadRef(microsoftPullRequest.getSourceRefName())
      .withDescription(microsoftPullRequest.getDescription());
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:24,代码来源:MicrosoftHostingService.java

示例4: getPullRequest

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
@Override
public Promise<PullRequest> getPullRequest(
    String owner, String repository, String username, final String branchName) {
  return oAuthServiceClient
      .getToken(SERVICE_NAME.toLowerCase())
      .thenPromise(
          token ->
              gitHubClientService.getPullRequests(
                  token.getToken(), owner, repository, username + ':' + branchName))
      .thenPromise(
          new Function<GitHubPullRequestList, Promise<PullRequest>>() {
            @Override
            public Promise<PullRequest> apply(GitHubPullRequestList prsList)
                throws FunctionException {
              if (prsList.getPullRequests().isEmpty()) {
                return Promises.reject(
                    JsPromiseError.create(new NoPullRequestException(branchName)));
              }
              return Promises.resolve(valueOf(prsList.getPullRequests().get(0)));
            }
          });
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:GitHubHostingService.java

示例5: getPullRequests

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
/**
 * Get all pull requests for given owner:repository
 *
 * @param owner the username of the owner.
 * @param repository the repository name.
 * @param callback callback called when operation is done.
 */
private void getPullRequests(
    @NotNull final String owner,
    @NotNull final String repository,
    @NotNull final AsyncCallback<List<PullRequest>> callback) {

  oAuthServiceClient
      .getToken(SERVICE_NAME.toLowerCase())
      .thenPromise(
          token -> gitHubClientService.getPullRequests(token.getToken(), owner, repository))
      .then(
          result -> {
            final List<PullRequest> pullRequests = new ArrayList<>();
            for (final GitHubPullRequest oneGitHubPullRequest : result.getPullRequests()) {
              pullRequests.add(valueOf(oneGitHubPullRequest));
            }
            callback.onSuccess(pullRequests);
          })
      .catchError(
          error -> {
            callback.onFailure(error.getCause());
          });
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:GitHubHostingService.java

示例6: valueOf

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
/**
 * Converts an instance of {@link org.eclipse.che.plugin.github.shared.GitHubPullRequest} into a
 * {@link PullRequest}.
 *
 * @param gitHubPullRequest the GitHub pull request to convert.
 * @return the corresponding {@link PullRequest} instance or {@code null} if given
 *     gitHubPullRequest is {@code null}.
 */
private PullRequest valueOf(final GitHubPullRequest gitHubPullRequest) {
  if (gitHubPullRequest == null) {
    return null;
  }

  return dtoFactory
      .createDto(PullRequest.class)
      .withId(gitHubPullRequest.getId())
      .withUrl(gitHubPullRequest.getUrl())
      .withHtmlUrl(gitHubPullRequest.getHtmlUrl())
      .withNumber(gitHubPullRequest.getNumber())
      .withState(gitHubPullRequest.getState())
      .withHeadRef(gitHubPullRequest.getHead().getLabel())
      .withDescription(gitHubPullRequest.getBody());
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:GitHubHostingService.java

示例7: execute

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
@Override
public void execute(final WorkflowExecutor executor, final Context context) {
  final PullRequest pullRequest = context.getPullRequest();
  factoryService
      .getFactoryJson(appContext.getWorkspaceId(), null)
      .then(
          new Operation<FactoryDto>() {
            @Override
            public void apply(FactoryDto currentFactory) throws OperationException {
              final String factoryId = extractFactoryId(pullRequest.getDescription());
              if (!Strings.isNullOrEmpty(factoryId)) {
                updateFactory(executor, context, factoryId, currentFactory);
              } else {
                addReviewUrl(executor, context, currentFactory);
              }
            }
          })
      .catchError(handleError(executor, context));
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:UpdatePullRequestStep.java

示例8: doUpdate

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
private void doUpdate(
    final WorkflowExecutor executor,
    final Context context,
    final PullRequest pullRequest,
    final String comment) {
  context
      .getVcsHostingService()
      .updatePullRequest(
          context.getOriginRepositoryOwner(),
          context.getUpstreamRepositoryName(),
          pullRequest.withDescription(comment))
      .then(
          new Operation<PullRequest>() {
            @Override
            public void apply(PullRequest pr) throws OperationException {
              executor.done(UpdatePullRequestStep.this, context);
            }
          })
      .catchError(handleError(executor, context));
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:UpdatePullRequestStep.java

示例9: valueOf

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
/**
 * Converts an instance of {@link org.eclipse.che.ide.ext.bitbucket.shared.BitbucketPullRequest}
 * into a {@link PullRequest}.
 *
 * @param bitbucketPullRequest the bitbucket pull request to convert.
 * @return the corresponding {@link PullRequest} instance or {@code null} if given
 *     bitbucketPullRequest is {@code null}.
 */
private PullRequest valueOf(final BitbucketPullRequest bitbucketPullRequest) {
  if (bitbucketPullRequest == null) {
    return null;
  }

  final String pullRequestId = String.valueOf(bitbucketPullRequest.getId());
  final BitbucketPullRequestLocation pullRequestSource = bitbucketPullRequest.getSource();
  final BitbucketPullRequestBranch pullRequestBranch =
      pullRequestSource != null ? pullRequestSource.getBranch() : null;
  final BitbucketPullRequestLinks pullRequestLinks = bitbucketPullRequest.getLinks();
  final BitbucketLink pullRequestHtmlLink =
      pullRequestLinks != null ? pullRequestLinks.getHtml() : null;
  final BitbucketLink pullRequestSelfLink =
      pullRequestLinks != null ? pullRequestLinks.getSelf() : null;

  return dtoFactory
      .createDto(PullRequest.class)
      .withId(pullRequestId)
      .withTitle(bitbucketPullRequest.getTitle())
      .withVersion(bitbucketPullRequest.getVersion())
      .withDescription(bitbucketPullRequest.getDescription())
      .withUrl(pullRequestSelfLink != null ? pullRequestSelfLink.getHref() : null)
      .withHtmlUrl(pullRequestHtmlLink != null ? pullRequestHtmlLink.getHref() : null)
      .withNumber(pullRequestId)
      .withState(bitbucketPullRequest.getState().name())
      .withHeadRef(pullRequestBranch.getName());
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:36,代码来源:BitbucketHostingService.java

示例10: updatePullRequest

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
@Override
public Promise<PullRequest> updatePullRequest(
    String owner, String repository, PullRequest pullRequest) {
  return microsoftClient
      .updatePullRequest(
          account, collection, owner, repository, pullRequest.getId(), valueOf(pullRequest))
      .then(
          new Function<MicrosoftPullRequest, PullRequest>() {
            @Override
            public PullRequest apply(MicrosoftPullRequest microsoftPullRequest)
                throws FunctionException {
              return valueOf(microsoftPullRequest);
            }
          });
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:16,代码来源:MicrosoftHostingService.java

示例11: getPullRequestByBranch

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
protected PullRequest getPullRequestByBranch(
    final String headBranch, final List<PullRequest> pullRequests) {
  for (final PullRequest onePullRequest : pullRequests) {
    if (headBranch.equals(onePullRequest.getHeadRef())) {
      return onePullRequest;
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:GitHubHostingService.java

示例12: updatePullRequest

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
@Override
public Promise<PullRequest> updatePullRequest(
    String owner, String repository, PullRequest pullRequest) {
  return oAuthServiceClient
      .getToken(SERVICE_NAME.toLowerCase())
      .thenPromise(
          token ->
              gitHubClientService.updatePullRequest(
                  token.getToken(),
                  owner,
                  repository,
                  pullRequest.getNumber(),
                  valueOf(pullRequest)))
      .then((Function<GitHubPullRequest, PullRequest>) this::valueOf);
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:GitHubHostingService.java

示例13: updateFactory

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
private Promise<FactoryDto> updateFactory(
    final WorkflowExecutor executor,
    final Context context,
    final String factoryId,
    final FactoryDto currentFactory) {
  return factoryService
      .updateFactory(factoryId, currentFactory)
      .then(
          new Operation<FactoryDto>() {
            @Override
            public void apply(FactoryDto updatedFactory) throws OperationException {
              context.setReviewFactoryUrl(FactoryHelper.getAcceptFactoryUrl(updatedFactory));
              executor.done(UpdatePullRequestStep.this, context);
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError error) throws OperationException {
              createNewFactory(
                  executor,
                  context,
                  currentFactory,
                  new Operation<FactoryDto>() {
                    @Override
                    public void apply(FactoryDto factory) throws OperationException {
                      final PullRequest pull = context.getPullRequest();
                      doUpdate(
                          executor,
                          context,
                          pull,
                          pull.getDescription().replaceAll(factoryId, factory.getId()));
                    }
                  });
            }
          });
}
 
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:UpdatePullRequestStep.java

示例14: execute

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
@Override
public void execute(final WorkflowExecutor executor, final Context context) {
  context
      .getVcsHostingService()
      .getPullRequest(
          context.getOriginRepositoryOwner(),
          context.getOriginRepositoryName(),
          context.getHostUserLogin(),
          context.getWorkBranchName())
      .then(
          new Operation<PullRequest>() {
            @Override
            public void apply(final PullRequest pr) throws OperationException {
              notificationManager.notify(
                  messages.stepDetectPrExistsTitle(),
                  messages.stepDetectPrExistsTitle(context.getWorkBranchName()),
                  StatusNotification.Status.FAIL,
                  FLOAT_MODE);
              context.setPullRequest(pr);
              context.setPullRequestIssueNumber(pr.getNumber());
              context.setForkedRepositoryName(context.getOriginRepositoryName());
              context.setStatus(READY_TO_UPDATE_PR);
              executor.fail(
                  DetectPullRequestStep.this, context, messages.stepDetectPrExistsTitle());
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(final PromiseError error) throws OperationException {
              // keep going if pr already exists
              executor.done(DetectPullRequestStep.this, context);
            }
          });
}
 
开发者ID:eclipse,项目名称:che,代码行数:36,代码来源:DetectPullRequestStep.java

示例15: createPullRequest

import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest; //导入依赖的package包/类
@Override
public Promise<PullRequest> createPullRequest(
    final String owner,
    final String repository,
    final String username,
    final String headBranchName,
    final String baseBranchName,
    final String title,
    final String body) {
  final BitbucketPullRequestLocation destination =
      dtoFactory
          .createDto(BitbucketPullRequestLocation.class)
          .withBranch(
              dtoFactory.createDto(BitbucketPullRequestBranch.class).withName(baseBranchName))
          .withRepository(
              dtoFactory
                  .createDto(BitbucketPullRequestRepository.class)
                  .withFullName(owner + '/' + repository));

  final BitbucketPullRequestLocation sources =
      dtoFactory
          .createDto(BitbucketPullRequestLocation.class)
          .withBranch(
              dtoFactory.createDto(BitbucketPullRequestBranch.class).withName(headBranchName))
          .withRepository(
              dtoFactory
                  .createDto(BitbucketPullRequestRepository.class)
                  .withFullName(username + '/' + repository));
  final BitbucketPullRequest pullRequest =
      dtoFactory
          .createDto(BitbucketPullRequest.class)
          .withTitle(title)
          .withDescription(body)
          .withDestination(destination)
          .withSource(sources);
  return bitbucketClientService
      .openPullRequest(owner, repository, pullRequest)
      .then(
          new Function<BitbucketPullRequest, PullRequest>() {
            @Override
            public PullRequest apply(BitbucketPullRequest arg) throws FunctionException {
              return valueOf(arg);
            }
          })
      .catchErrorPromise(
          error -> {
            final String message = error.getMessage();
            if (isNullOrEmpty(message)) {
              return reject(error);
            }
            if (getErrorCode(error.getCause()) == BAD_REQUEST
                && containsIgnoreCase(message, NO_CHANGES_TO_BE_PULLED_ERROR_MESSAGE)) {
              return reject(
                  JsPromiseError.create(
                      new NoCommitsInPullRequestException(headBranchName, baseBranchName)));
            } else if (containsIgnoreCase(message, PULL_REQUEST_ALREADY_EXISTS_ERROR_MESSAGE)) {
              return reject(
                  JsPromiseError.create(new PullRequestAlreadyExistsException(headBranchName)));
            }
            return reject(error);
          });
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:63,代码来源:BitbucketHostingService.java


注:本文中的org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。