List of usage examples for java.util.stream Collectors toList
public static <T> Collector<T, ?, List<T>> toList()
From source file:ipgraph.datastructure.DTree.java
public List<DNode> getRoots() { return this.stream().parallel().filter(x -> x.getDepLabel().equals(LangLib.DEP_ROOT)).distinct() .collect(Collectors.toList()); }
From source file:com.create.security.RepositoryUserDetailsService.java
private List<GrantedAuthority> getGrantedAuthorities(User user) { return Stream.concat(getGrantedAuthoritiesForRoles(user), getGrantedAuthoritiesForPermissions(user)) .collect(Collectors.toList()); }
From source file:com.ikanow.aleph2.v1.document_db.utils.LegacyV1HadoopUtils.java
/** parse the V1 query string * @param query/*from w w w .j a v a 2 s.c o m*/ * @return the required objects embedded in various tuples */ public static Tuple4<String, Tuple2<Integer, Integer>, BasicDBObject, DBObject> parseQueryObject( final String query, final List<String> community_ids) { // Some fixed variables just to avoid changing the guts of the (tested in v1) code final boolean isCustomTable = false; @SuppressWarnings("unused") Integer nDebugLimit = null; final boolean bLocalMode = false; @SuppressWarnings("unused") final Boolean incrementalMode = null; final String input = "doc_metadata.metadata"; // Output objects final String out_query; int nSplits = 8; int nDocsPerSplit = 12500; List<ObjectId> communityIds = community_ids.stream().map(s -> new ObjectId(s)).collect(Collectors.toList()); //C/P code: //add communities to query if this is not a custom table BasicDBObject oldQueryObj = null; BasicDBObject srcTags = null; // Start with the old query: if (query.startsWith("{")) { oldQueryObj = (BasicDBObject) com.mongodb.util.JSON.parse(query); } else { oldQueryObj = new BasicDBObject(); } boolean elasticsearchQuery = oldQueryObj.containsField("qt") && !isCustomTable; @SuppressWarnings("unused") int nLimit = 0; if (oldQueryObj.containsField(":limit")) { nLimit = oldQueryObj.getInt(":limit"); oldQueryObj.remove(":limit"); } if (oldQueryObj.containsField(":splits")) { nSplits = oldQueryObj.getInt(":splits"); oldQueryObj.remove(":splits"); } if (oldQueryObj.containsField(":srctags")) { srcTags = new BasicDBObject(SourcePojo.tags_, oldQueryObj.get(":srctags")); oldQueryObj.remove(":srctags"); } if (bLocalMode) { // If in local mode, then set this to a large number so we always run inside our limit/split version // (since for some reason MongoInputFormat seems to fail on large collections) nSplits = InfiniteMongoSplitter.MAX_SPLITS; } if (oldQueryObj.containsField(":docsPerSplit")) { nDocsPerSplit = oldQueryObj.getInt(":docsPerSplit"); oldQueryObj.remove(":docsPerSplit"); } final DBObject fields = (DBObject) oldQueryObj.remove(":fields"); oldQueryObj.remove(":output"); oldQueryObj.remove(":reducers"); @SuppressWarnings("unused") String mapperKeyClass = oldQueryObj.getString(":mapper_key_class", ""); @SuppressWarnings("unused") String mapperValueClass = oldQueryObj.getString(":mapper_value_class", ""); oldQueryObj.remove(":mapper_key_class"); oldQueryObj.remove(":mapper_value_class"); String cacheList = null; Object cacheObj = oldQueryObj.get(":caches"); if (null != cacheObj) { cacheList = cacheObj.toString(); // (either array of strings, or single string) if (!cacheList.startsWith("[")) { cacheList = "[" + cacheList + "]"; // ("must" now be valid array) } oldQueryObj.remove(":caches"); } //TESTED // if (null != nDebugLimit) { // (debug mode override) // nLimit = nDebugLimit; // } // boolean tmpIncMode = ( null != incrementalMode) && incrementalMode; @SuppressWarnings("unused") String otherCollections = null; Date fromOverride = null; Date toOverride = null; Object fromOverrideObj = oldQueryObj.remove(":tmin"); Object toOverrideObj = oldQueryObj.remove(":tmax"); if (null != fromOverrideObj) { fromOverride = dateStringFromObject(fromOverrideObj, true); } if (null != toOverrideObj) { toOverride = dateStringFromObject(toOverrideObj, false); } if (!isCustomTable) { if (elasticsearchQuery) { oldQueryObj.put("communityIds", communityIds); //tmin/tmax not supported - already have that capability as part of the query } else { if (input.equals("feature.temporal")) { if ((null != fromOverride) || (null != toOverride)) { oldQueryObj.put("value.maxTime", createDateRange(fromOverride, toOverride, true)); } //TESTED oldQueryObj.put("_id.c", new BasicDBObject(DbManager.in_, communityIds)); } else { oldQueryObj.put(DocumentPojo.communityId_, new BasicDBObject(DbManager.in_, communityIds)); if ((null != fromOverride) || (null != toOverride)) { oldQueryObj.put(JsonUtils._ID, createDateRange(fromOverride, toOverride, false)); } //TESTED if (input.equals("doc_metadata.metadata")) { oldQueryObj.put(DocumentPojo.index_, new BasicDBObject(DbManager.ne_, "?DEL?")); // (ensures not soft-deleted) } } } } else { throw new RuntimeException("Custom Tables not currently supported (no plans to)"); // if ((null != fromOverride) || (null != toOverride)) { // oldQueryObj.put(JsonUtils._ID, createDateRange(fromOverride, toOverride, false)); // }//TESTED // //get the custom table (and database) // // String[] candidateInputs = input.split("\\s*,\\s*"); // input = CustomOutputManager.getCustomDbAndCollection(candidateInputs[0]); // if (candidateInputs.length > 1) { // otherCollections = Arrays.stream(candidateInputs) // .skip(1L) // .map(i -> CustomOutputManager.getCustomDbAndCollection(i)) // .map(i -> "mongodb://"+dbserver+"/"+i).collect(Collectors.joining("|")); // } } out_query = oldQueryObj.toString(); return Tuples._4T(out_query, Tuples._2T(nSplits, nDocsPerSplit), srcTags, fields); }
From source file:com.khartec.waltz.service.capability_usage.CapabilityUsageService.java
private static CapabilityUsage classifyAppCapabilities(Node<Capability, Long> capNode, List<ApplicationCapability> appCapabilities, List<CapabilityRating> ratings) { return ImmutableCapabilityUsage.builder().capability(capNode.getData()) .usages(appCapabilities.stream().filter(ac -> ac.capabilityId() == capNode.getId()) .collect(Collectors.toList())) .ratings(ratings.stream().filter(r -> r.capabilityId() == capNode.getId()) .collect(Collectors.toList())) .children(capNode.getChildren().stream() .map(n -> classifyAppCapabilities(n, appCapabilities, ratings)) .collect(Collectors.toList())) .build();//from w w w. j av a2s. c o m }
From source file:com.ikanow.aleph2.search_service.elasticsearch.utils.TestElasticsearchIndexConfigUtils.java
@Test public void test_docSchema() { assertEquals(Arrays.asList("__a"), _config.document_schema_override().keySet().stream().collect(Collectors.toList())); }
From source file:it.reply.orchestrator.config.WorkflowConfigProducerBean.java
@Override public List<Resource> getJbpmResources() { return resources.stream().map(r -> r.getResource()).collect(Collectors.toList()); }
From source file:edu.pitt.dbmi.ccd.db.specification.VocabularySpecification.java
private static List<Predicate> notInNameOrDescription(Root<Vocabulary> root, CriteriaBuilder cb, Set<String> terms) { return terms.stream().map(t -> containsLike(t)) .map(t -> cb.not(cb.or(nameContains(root, cb, t), descriptionContains(root, cb, t)))) .collect(Collectors.toList()); }
From source file:am.ik.categolj2.api.file.FileRestController.java
@RequestMapping(method = RequestMethod.GET, headers = Categolj2Headers.X_ADMIN) public Page<FileResource> getFiles(@PageableDefault Pageable pageable) { Page<UploadFileSummary> summaries = uploadFileService.findPage(pageable); List<FileResource> resources = summaries.getContent().stream() .map(file -> beanMapper.map(file, FileResource.class)).collect(Collectors.toList()); return new PageImpl<>(resources, pageable, summaries.getTotalElements()); }
From source file:pl.java.scalatech.generator.SimpleGenerator.java
@PostConstruct @SneakyThrows/*from www . j a v a 2 s. c om*/ void init() { //names= retrieveNames(Paths.get(male.getURI()), s -> s.length()>2); //names.addAll(retrieveNames(Paths.get(female.getURI()), s -> s.length()>2)); names = Stream.of("Smith", "Johnson", "Wong", "Lu", "Cobain", "Rockerfella", "Armstrong", "Alderan", "O'Connel", "Williams", "Brown", "Jones", "Miller", "Garcia", "Martin", "Moore", "White", "Jackson", "Taylor", "Lee", "Harris", "Clark", "Robinson", "Young", "King", "Scott", "Green", "Baker", "Hill", "Edwards").distinct().collect(Collectors.toList()); }
From source file:io.jexiletools.es.modsmapping.ModsMapping.java
@SuppressWarnings("unchecked") private ModsMapping() { Gson gson = new Gson(); Map<String, Object> m = null; try (InputStreamReader isr = new InputStreamReader(ModsMapping.class.getResourceAsStream("/mods.json")) { }) {/* w w w .j a va 2s.c o m*/ String s = CharStreams.toString(isr); s = s.replace("\\", "\\\\"); m = gson.fromJson(s, Map.class); } catch (IOException e) { throw new RuntimeException(e); } m = (Map<String, Object>) m.get("poe"); m = (Map<String, Object>) m.get("mappings"); m = (Map<String, Object>) m.get("item"); modMappings = m.entrySet().stream().map(e -> toMapping(e)).collect(Collectors.toList()); // the json mod mapping represents ranged mods as two, one for min and one for max // we only want one of the two, so let's clean // Remove DOUBLE_MAX mods modMappings = modMappings.stream().filter(mm -> mm.type != Type.DOUBLE_MAX).collect(Collectors.toList()); // Change DOUBLE_MIN mods to DOUBLE_MIN_MAX modMappings.stream().filter(mm -> mm.type == Type.DOUBLE_MIN).forEach(mm -> mm.type = Type.DOUBLE_MIN_MAX); // also add pseudo mods modMappings.add(new ModMapping("modsPseudo.eleResistSumChaos", "modsPseudo.eleResistSumChaos", "+#% to Lightning Chaos", Type.DOUBLE, ModType.PSEUDO, null)); modMappings.add(new ModMapping("modsPseudo.eleResistSumCold", "modsPseudo.eleResistSumCold", "+#% to Cold Resistance", Type.DOUBLE, ModType.PSEUDO, null)); modMappings.add(new ModMapping("modsPseudo.eleResistSumFire", "modsPseudo.eleResistSumFire", "+#% to Fire Resistance", Type.DOUBLE, ModType.PSEUDO, null)); modMappings.add(new ModMapping("modsPseudo.eleResistSumLightning", "modsPseudo.eleResistSumLightning", "+#% to Lightning Resistance", Type.DOUBLE, ModType.PSEUDO, null)); modMappings.add(new ModMapping("modsPseudo.eleResistTotal", "modsPseudo.eleResistTotal", "+#% total Elemental Resistance", Type.DOUBLE, ModType.PSEUDO, null)); modMappings.add(new ModMapping("modsPseudo.flatAttributesTotal", "modsPseudo.flatAttributesTotal", "+# to all Attributes", Type.DOUBLE, ModType.PSEUDO, null)); modMappings.add(new ModMapping("modsPseudo.flatSumDex", "modsPseudo.flatSumDex", "+# to Dexterity", Type.DOUBLE, ModType.PSEUDO, null)); modMappings.add(new ModMapping("modsPseudo.flatSumInt", "modsPseudo.flatSumInt", "+# to Intelligence", Type.DOUBLE, ModType.PSEUDO, null)); modMappings.add(new ModMapping("modsPseudo.flatSumStr", "modsPseudo.flatSumStr", "+# to Strength", Type.DOUBLE, ModType.PSEUDO, null)); modMappings.add(new ModMapping("modsPseudo.maxLife", "modsPseudo.maxLife", "+# to Maximum Life", Type.DOUBLE, ModType.PSEUDO, null)); }