List of usage examples for java.util.stream Collectors toList
public static <T> Collector<T, ?, List<T>> toList()
From source file:io.cfp.service.TalkAdminService.java
/** * Retrieve all talks/*from www. j av a 2 s . c om*/ * * @param states List of states the talk must be * @return List of talks */ public List<TalkAdmin> findAll(int userId, Talk.State... states) { List<TalkAdmin> talks = talkRepo.findByEventIdAndStatesFetch(Event.current(), Arrays.asList(states)) .stream().map(TalkAdmin::new).collect(Collectors.toList()); List<Rate> rates = rateRepo.findAllFetchAdmin(Event.current()); Map<Integer, List<Rate>> reviewed = rates.stream().filter(r -> userId == r.getAdminUser().getId()) .collect(groupingBy(r -> r.getTalk().getId())); Map<Integer, Double> averages = rates.stream().filter(r -> r.getRate() > 0) .collect(groupingBy(r -> r.getTalk().getId(), averagingInt(Rate::getRate))); Map<Integer, List<String>> voters = rates.stream() .collect(groupingBy(r -> r.getTalk().getId(), mapping(r -> r.getAdminUser().getEmail(), toList()))); for (TalkAdmin talk : talks) { int talkId = talk.getId(); talk.setReviewed(reviewed.get(talkId) != null); talk.setMean(averages.get(talkId)); talk.setVoteUsersEmail(voters.get(talkId)); } return talks; }
From source file:io.curly.bloodhound.service.ElasticQueryService.java
@HystrixCommand(fallbackMethod = "noResults") public Observable<List<Artifact>> getResults(String query) { log.debug("Querying data for {}", query); return new ObservableResult<List<Artifact>>() { @Override/* w w w . j a va 2s . c o m*/ public List<Artifact> invoke() { return StreamSupport .stream(repository.search(elasticQueryBuilder.build(query)).spliterator(), false) .collect(Collectors.toList()); } }; }
From source file:se.uu.it.cs.recsys.ruleminer.config.CourseRecommenderRuleMinerSpringConfig.java
@Bean public CacheManager cacheManager() { SimpleCacheManager cacheManager = new SimpleCacheManager(); GuavaCache fpTreeCache = new GuavaCache("FPTrees", CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.DAYS).maximumSize(100).build()); GuavaCache fpPatternCache = new GuavaCache("FPPatterns", CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.DAYS).maximumSize(100).build()); cacheManager.setCaches(Stream.of(fpTreeCache, fpPatternCache).collect(Collectors.toList())); return cacheManager; }
From source file:com.khartec.waltz.data.entity_alias.EntityAliasDao.java
public int[] updateAliases(EntityReference ref, Collection<String> aliases) { LOG.info("Updating aliases for entity: {}, aliases: {}", ref, aliases); dsl.delete(ENTITY_ALIAS).where(constrainByEntityReference(ref)).execute(); List<EntityAliasRecord> records = aliases.stream() .map(t -> new EntityAliasRecord(ref.id(), t, ref.kind().name())).collect(Collectors.toList()); return dsl.batchInsert(records).execute(); }
From source file:org.trustedanalytics.datasetpublisher.boundary.MetadataMapper.java
@Override public HiveTable apply(Metadata metadata) { final List<String> fields = Arrays.asList(metadata.getDataSample().split(",")); // validate if initial names of header fields are distinct checkDuplicates(fields, "Duplicated header fields in file"); final String tableName = toValidTableName(metadata.getTitle()); final String dbName = toValidDBName(metadata.getOrgUUID()); final List<String> columns = fields.stream().map(this::toValidTableName).collect(Collectors.toList()); final String location = toValidLocation(metadata.getTargetUri()); // validate if names of fields transformed into name columns are distinct checkDuplicates(columns, "Duplicated columns in table"); return new HiveTable(dbName, tableName, columns, location); }
From source file:com.blackducksoftware.integration.hub.detect.help.html.HelpHtmlDataBuilder.java
public HelpHtmlData build() { final List<HelpHtmlGroup> sortedOptions = groupsByName.values().stream() .sorted((o1, o2) -> o1.groupName.compareTo(o2.groupName)).collect(Collectors.toList()); sortedOptions.forEach(it -> it.getOptions().sort((o1, o2) -> o1.key.compareTo(o2.key))); return new HelpHtmlData(sortedOptions); }
From source file:org.obiba.mica.web.model.LocalizedStringDtos.java
@NotNull
List<LocalizedString> fromDtoList(@NotNull Collection<Mica.LocalizedStringDtos> dtos) {
return dtos.stream().map(dto -> fromDto(dto.getLocalizedStringsList())).collect(Collectors.toList());
}
From source file:org.obiba.mica.dataset.search.EsDraftHarmonizedDatasetService.java
@Nullable @Override//from w w w . j ava 2 s.co m protected Searcher.IdFilter getAccessibleIdFilter() { return new Searcher.IdFilter() { @Override public Collection<String> getValues() { return harmonizedDatasetService.findAllIds().stream() .filter(s -> subjectAclService.isPermitted("/draft/harmonized-dataset", "VIEW", s)) .collect(Collectors.toList()); } }; }
From source file:de.knoplab.todomaven.task.DefaultDataTask.java
@Override public void deleteSelected() { List<TodoTask> listToDelete = this.todoTaskList; this.todoTaskList = this.todoTaskList.stream().filter(e -> e.getState() == false) .collect(Collectors.toList()); listToDelete.removeAll(this.todoTaskList); listToDelete.forEach(e -> {/*from w w w. j a v a 2s .c o m*/ todoTaskList.remove(e); eventService.publish(new DataDeleteEvent(e)); }); }
From source file:com.davidmogar.alsa.services.schedule.internal.ScheduleManagerServiceImpl.java
@Override public List<ScheduleDto> findAll() { return StreamSupport.stream(scheduleDataService.findAll().spliterator(), false).map(ScheduleDto::new) .collect(Collectors.toList()); }