List of usage examples for java.util.stream Collectors toList
public static <T> Collector<T, ?, List<T>> toList()
From source file:com.epam.ta.reportportal.ws.converter.builders.DashboardResourceBuilder.java
public DashboardResourceBuilder addDashboard(Dashboard dashboard) { if (dashboard != null) { getObject().setDashboardId(dashboard.getId()); getObject().setName(dashboard.getName()); getObject().setDescription(dashboard.getDescription()); if (null != dashboard.getWidgets()) { List<WidgetObjectModel> models = dashboard.getWidgets().stream() .map(widgetObject -> new WidgetObjectModel(widgetObject.getWidgetId(), widgetObject.getWidgetSize(), widgetObject.getWidgetPosition())) .collect(Collectors.toList()); getObject().setWidgets(models); }//from www .j ava2 s. c o m if (null != dashboard.getAcl()) { getObject().setOwner(dashboard.getAcl().getOwnerUserId()); getObject().setIsShared(!dashboard.getAcl().getEntries().isEmpty()); } } return this; }
From source file:io.github.retz.scheduler.Applications.java
public static List<Application> needsPersistentVolume(Resource resource, String role) { List<Application> apps = DICTIONARY.entrySet().stream() .filter(entry -> !entry.getValue().persistentFiles.isEmpty()) .filter(entry -> entry.getValue().diskMB.isPresent()) .filter(entry -> !resource.volumes().containsKey(entry.getValue().toVolumeId(role))) .map(entry -> entry.getValue()).collect(Collectors.toList()); return apps;//from w w w . java 2s .c om }
From source file:be.ordina.msdashboard.graph.GraphRetriever.java
@Cacheable(value = Constants.GRAPH_CACHE_NAME, keyGenerator = "simpleKeyGenerator") public Map<String, Object> retrieve() { List<Observable<Node>> observables = aggregators.stream() .collect(Collectors.mapping(NodeAggregator::aggregateNodes, Collectors.toList())); observables.add(redisService.getAllNodesAsObservable()); Map<String, Object> graph = new HashMap<>(); graph.put(DIRECTED, true);/*from ww w .j a v a2 s .c o m*/ graph.put(MULTIGRAPH, false); graph.put(GRAPH, new String[0]); graph.put(LANES, constructLanes()); graph.put(TYPES, constructTypes()); Map<String, Object> nodesAndLinks = Observable.mergeDelayError(observables) .doOnError(throwable -> logger.error("An error occurred during merging aggregators:", throwable)) .onErrorResumeNext(Observable.empty()).observeOn(Schedulers.io()) .doOnNext(node -> logger.info("Merging node with id '{}'", node.getId())) .reduce(new ArrayList<>(), NodeMerger.merge()) .doOnError(throwable -> logger.error("An error occurred during reducing:", throwable)) .onErrorResumeNext(Observable.empty()) .doOnNext(nodes -> logger.info("Merged all emitted nodes, converting to map")) .map(GraphMapper.toGraph()) .doOnNext(nodesAndLinksMap -> logger.info("Converted to nodes and links map")) .doOnError(throwable -> logger.error("An error occurred during mapping:", throwable)) .onErrorResumeNext(Observable.empty()).toBlocking().first(); logger.info("Graph retrieved: {}", nodesAndLinks); graph.put(NODES, nodesAndLinks.get(NODES)); graph.put(LINKS, nodesAndLinks.get(LINKS)); return graph; }
From source file:org.hawkular.apm.server.api.utils.zipkin.SpanHttpDeriverUtil.java
/** * Method returns only client or sever http errors. * * @param httpCodes list of http codes//from w w w . ja v a2s .c o m * @return Http client and server errors */ public static List<HttpCode> getClientOrServerErrors(List<HttpCode> httpCodes) { return httpCodes.stream().filter(x -> x.isClientOrServerError()).collect(Collectors.toList()); }
From source file:org.obiba.mica.dataset.rest.PublishedDatasetsResource.java
@GET @Path("/_list") @Timed/*from w ww . j av a 2s . com*/ public Mica.DatasetsDto list(@QueryParam("from") @DefaultValue("0") int from, @QueryParam("limit") @DefaultValue("10") int limit, @QueryParam("sort") String sort, @QueryParam("order") String order, @QueryParam("study") String studyId, @QueryParam("query") String query) { PublishedDocumentService.Documents<Dataset> datasets = publishedDatasetService.find(from, limit, sort, order, studyId, query); Mica.DatasetsDto.Builder builder = Mica.DatasetsDto.newBuilder(); builder.setFrom(datasets.getFrom()).setLimit(datasets.getLimit()).setTotal(datasets.getTotal()); builder.addAllDatasets(datasets.getList().stream().map(dtos::asDto).collect(Collectors.toList())); return builder.build(); }
From source file:org.obiba.mica.study.rest.PublishedStudiesResource.java
@GET @Path("/_list") @Timed//www . j a v a2 s. c o m public Mica.StudySummariesDto list(@QueryParam("from") @DefaultValue("0") int from, @QueryParam("limit") @DefaultValue("10") int limit, @QueryParam("sort") String sort, @QueryParam("order") String order, @QueryParam("query") String query) { PublishedDocumentService.Documents<BaseStudy> studies = publishedStudyService.find(from, limit, sort, order, null, query); Mica.StudySummariesDto.Builder builder = Mica.StudySummariesDto.newBuilder(); builder.setFrom(studies.getFrom()).setLimit(studies.getLimit()).setTotal(studies.getTotal()); builder.addAllStudySummaries(studies.getList().stream().map(baseStudy -> dtos.asSummaryDto(baseStudy)) .collect(Collectors.toList())); return builder.build(); }
From source file:ImportPhagelist.java
private void getStrains(String path1) throws IOException { String cvsSplitBy = "\\t"; List<String[]> lines = null; try (FileInputStream fis = new FileInputStream(path1); BufferedReader br = new BufferedReader(new InputStreamReader(fis))) { lines = br.lines().map((l) -> l.split(cvsSplitBy)).collect(Collectors.toList()); } catch (FileNotFoundException e) { e.printStackTrace();//www . ja v a 2 s . c o m } this.strains = lines.stream().skip(1).map(x -> x[1]).collect(Collectors.toSet()); ; }
From source file:org.ng200.openolympus.controller.api.TaskSearchController.java
@RequestMapping("/api/taskCompletion") public @ResponseBody List<String> searchTasks(@RequestParam(value = "term") final String name) { Assertions.resourceExists(name);/*from w w w .ja va2s . c o m*/ return this.taskRepository.findByNameContaining(name, new PageRequest(0, 30)).stream() .map((t) -> t.getName()).collect(Collectors.toList()); }
From source file:org.obiba.mica.network.rest.PublishedNetworksResource.java
@GET @Path("/_list") @Timed//from w w w. j a v a 2 s .com public Mica.NetworksDto list(@QueryParam("from") @DefaultValue("0") int from, @QueryParam("limit") @DefaultValue("10") int limit, @QueryParam("sort") String sort, @QueryParam("order") String order, @QueryParam("study") String studyId, @QueryParam("query") String query) { PublishedDocumentService.Documents<Network> networks = publishedNetworkService.find(from, limit, sort, order, studyId, query); Mica.NetworksDto.Builder builder = Mica.NetworksDto.newBuilder(); builder.setFrom(networks.getFrom()).setLimit(networks.getLimit()).setTotal(networks.getTotal()); builder.addAllNetworks(networks.getList().stream().map(dtos::asDto).collect(Collectors.toList())); return builder.build(); }
From source file:org.obiba.mica.dataset.search.EsDraftCollectedDatasetService.java
@Nullable @Override/* w w w. j a va2 s . com*/ protected Searcher.IdFilter getAccessibleIdFilter() { return new Searcher.IdFilter() { @Override public Collection<String> getValues() { return collectedDatasetService.findAllIds().stream() .filter(s -> subjectAclService.isPermitted("/draft/collected-dataset", "VIEW", s)) .collect(Collectors.toList()); } }; }