@NotNull P4CommandRunner.QueryAnswer<List<P4Job>> searchJobs(@NotNull String queryPart, int maxResultsPerServer) { List<ServerConfig> configs; synchronized (sync) { configs = new ArrayList<>(activeConfigs); } P4CommandRunner.QueryAnswer<List<P4Job>> ret = new DoneQueryAnswer<>(new ArrayList<>()); for (ServerConfig config : configs) { ret = ret.mapQueryAsync((jobs) -> P4ServerComponent .query(project, config, new ListJobsQuery(null, null, queryPart, maxResultsPerServer)) .mapQuery((r) -> { jobs.addAll(r.getJobs()); return jobs; })); } return ret; }
private static P4CommandRunner.QueryAnswer<Set<P4Job>> getJobsIn(@NotNull Project project, @NotNull ServerConfig config, List<P4Job> jobs) { P4CommandRunner.QueryAnswer<Set<P4Job>> ret = new DoneQueryAnswer<>(new HashSet<>()); for (P4Job job : jobs) { ret = ret.mapQueryAsync((associatedJobs) -> P4ServerComponent .query(project, config, new ListJobsQuery(job.getJobId(), null, null, 1)) .mapQuery((result) -> { associatedJobs.addAll(result.getJobs()); return associatedJobs; })); } return ret; }
@NotNull P4CommandRunner.QueryAnswer<JobStatusNames> loadJobStatusNames() { List<ServerConfig> configs; synchronized (sync) { configs = new ArrayList<>(activeConfigs); } P4CommandRunner.QueryAnswer<Set<JobStatus>> res = new DoneQueryAnswer<>(new HashSet<>()); for (ServerConfig config : configs) { res = res.mapQueryAsync((statuses) -> P4ServerComponent .query(project, config, new GetJobSpecQuery()) .mapQuery((r) -> { P4JobSpec jobSpec = r.getJobSpec(); if (jobSpec != null) { statuses.addAll(JobStatusNamesImpl.load(jobSpec).getJobStatusNames()); } return statuses; })); } return res.mapQuery((r) -> { if (r.isEmpty()) { return JobStatusNamesImpl.DEFAULT_STATUSES; } return new JobStatusNamesImpl(r); }); }
P4ServerComponent.query(project, clientConfig.getServerConfig(), new ListUsersQuery(-1)) .mapQuery(r -> r.getUsers().stream() .map(Reviewer::new) .collect(Collectors.toList())),
@NotNull private P4CommandRunner.QueryAnswer<List<P4CommittedChangelist>> asyncLoadCommittedChanges( P4ChangeBrowserSettings settings, RepositoryLocation location, int maxCount) { if (LOG.isDebugEnabled()) { LOG.debug("Loading committed changes for " + location); } ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project); if (location == null || registry == null) { return new DoneQueryAnswer<>(Collections.emptyList()); } if (location instanceof P4RepositoryLocation) { P4RepositoryLocation repo = (P4RepositoryLocation) location; ClientConfig clientConfig = registry.getRegisteredClientConfigState(repo.getClientServerRef()); if (clientConfig == null) { LOG.warn("Could not find configuration for " + repo.getClientServerRef()); return new DoneQueryAnswer<>(Collections.emptyList()); } P4Vcs vcs = P4Vcs.getInstance(project); return P4ServerComponent .query(project, clientConfig, new ListSubmittedChangelistsQuery(repo, settings.getQueryFilter(), maxCount)) .mapQuery((c) -> c.getChangesForVcs(vcs)); } LOG.warn("Cannot load changes for non-perforce repository location " + location); return new DoneQueryAnswer<>(Collections.emptyList()); }