List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:de.hska.ld.content.service.impl.SubscriptionServiceImpl.java
@Override @Transactional/* w ww . j av a 2 s.c o m*/ public void markNotificationsAsRead(List<Notification> notificationList) { User user = Core.currentUser(); if (notificationList != null) { notificationList.forEach(n -> { if (n.getSubscriberId().equals(user.getId())) { n.setMarkedAsRead(true); notificationRepository.save(n); } }); } }
From source file:org.apache.ambari.view.web.service.PackageScannerServiceImpl.java
@Override public void initializeRepositoryScan(ActorRef repositoryScanManager) { List<Registry> registryList = registryRepository.findAll(); registryList.forEach(registry -> { if (registry.getScanStatus() == RegistryScanStatus.RUNNING) { repositoryScanManager.tell(new ScanManager.Start(registry.getName(), registry.getScanUrl()), ActorRef.noSender()); }// w w w.jav a 2 s . c o m }); }
From source file:info.losd.galen.scheduler.repository.TestTaskRepo.java
@Test public void test_it_can_get_a_list_of_tasks_to_be_run() { List<Header> headers = Arrays.asList(new Header("h1", "v1"), new Header("h2", "v2")); String url = "http://localhost:8080/test"; String method = HttpMethod.GET.toString(); repo.save(new Task("test_task", 10, Instant.now().minusSeconds(10), url, method, Collections.emptyList())); repo.save(new Task("test_task", 10, Instant.now().minusSeconds(10), url, method, Collections.emptyList())); repo.save(new Task("test_task", 10, Instant.now().minusSeconds(10), url, method, headers)); repo.save(new Task("test_task", 10, Instant.now().plusSeconds(11), url, method, Collections.emptyList())); repo.save(new Task("test_task", 10, Instant.now().plusSeconds(12), url, method, Collections.emptyList())); List<Task> result = repo.findTasksToBeRun(); assertThat(result, IsCollectionWithSize.hasSize(3)); result.forEach(res -> { LOG.info("{} has {} headers", res.toString(), res.getHeaders().size()); });/*from w w w .ja v a 2 s. co m*/ }
From source file:io.gravitee.repository.redis.management.internal.impl.MembershipRedisRepositoryImpl.java
public Set<RedisMembership> findByReferences(String referenceType, List<String> referenceIds) { Set<RedisMembership> memberships = new HashSet<>(); referenceIds.forEach(id -> { Set<Object> keys = redisTemplate.opsForSet().members(getMembershipByReferenceKey(referenceType, id)); List<Object> values = redisTemplate.opsForHash().multiGet(REDIS_KEY, keys); memberships.addAll(values.stream().filter(Objects::nonNull) .map(membership -> convert(membership, RedisMembership.class)).collect(Collectors.toSet())); });/*from www. ja v a2 s . c o m*/ return memberships; }
From source file:com.enitalk.controllers.youtube.processor.Y2BeProcessor.java
public void run() { try {// ww w . ja va 2 s. co m logger.info("Running processor"); //TO-DO make it work only for 30+ minutes after the Query q = Query.query(Criteria.where("").is("")); List<HashMap> items = mongo.find(q, HashMap.class, "events"); ArrayNode its = jackson.convertValue(items, ArrayNode.class); final List<JsonNode> allEvents = its.findParents("ii"); allEvents.forEach((JsonNode el) -> { try { List<String> ids = jackson.convertValue(el.path("liveId"), List.class); Credential credential = flow.loadCredential(el.at("/teacher/dest/sendTo").toString()); YouTube youtube = new YouTube.Builder(new NetHttpTransport(), JacksonFactory.getDefaultInstance(), credential).setApplicationName("enitalk").build(); boolean refreshed = credential.refreshToken(); logger.info("Token refreshed {} id {}", refreshed); YouTube.Videos.List list = youtube.videos() .list("id,liveStreamingDetails,recordingDetails,status,statistics"); list.setId(StringUtils.join(ids, ',')); logger.info("Video param query {}", list.buildHttpRequestUrl()); byte[] response = IOUtils.toByteArray(list.executeUnparsed().getContent()); JsonNode r = jackson.readTree(response); logger.info("Yt response {}", r); Update u = new Update().set("records", jackson.convertValue(r, HashMap.class)); long finishedItems = r.path("items").findParents("id").stream().filter((JsonNode yt) -> { return yt.at("/status/uploadStatus").asText().equals("processed"); }).count(); logger.info("Finished items {}", finishedItems); if (finishedItems == ids.size()) { logger.info("All items finished, shall sent links to user"); } else { u.set("nextCheck", new DateTime(DateTimeZone.UTC).plusMinutes(15).toDate()); } mongo.updateFirst(Query.query(Criteria.where("ii").is(el.path("ii").asText())), u, "events"); } catch (Exception e) { logger.error(ExceptionUtils.getFullStackTrace(e)); } }); } catch (Exception e) { logger.error(ExceptionUtils.getFullStackTrace(e)); } }
From source file:it.polimi.diceH2020.SPACE4CloudWS.core.DataProcessor.java
private void calculateDurationFineGrained(@NonNull List<SolutionPerJob> spjList) { spjList.forEach(s -> { ContainerLogicForEvaluation container = (ContainerLogicForEvaluation) context .getBean("containerLogicForEvaluation", s); container.start();/*from w ww. ja v a 2 s. com*/ }); }
From source file:io.fabric8.che.starter.client.CheRestClientTest.java
@Test public void listWorkspaces() { List<Workspace> workspaces = this.client.listWorkspaces(cheServerURL); LOG.info("Number of workspaces: {}", workspaces.size()); workspaces.forEach(w -> LOG.info("workspace ID: {}", w.getId())); }
From source file:com.baidu.rigel.biplatform.ma.report.utils.QueryUtils.java
/** * TODO://from w w w.java 2 s . c om * @param members * @return List<Map<String, String>> */ public static List<Map<String, String>> getMembersWithChildrenValue(List<Member> members, Cube cube, DataSourceInfo dataSource, Map<String, String> params) { List<Map<String, String>> rs = Lists.newArrayList(); if (members == null || members.isEmpty()) { return rs; } members.forEach(m -> { Map<String, String> tmp = Maps.newHashMap(); tmp.put("value", m.getUniqueName()); tmp.put("text", m.getCaption()); Member parent = m.getParentMember(cube, dataSource, params); if (parent != null) { tmp.put("parent", parent.getUniqueName()); } rs.add(tmp); List<Member> children = m.getChildMembers(cube, dataSource, params); if (children != null) { rs.addAll(getMembersWithChildrenValue(children, cube, dataSource, params)); } }); return rs; }
From source file:com.github.frapontillo.pulse.crowd.sentiment.sentiwordnet.MultiWordNet.java
/** * Loads a dictionary for a given language. * * @param language A {@link String} representing the language. * * @return a {@link HashMap}<String, String[]> where keys are lemmas and values are synsets. */// w w w.j av a2 s .com private HashMap<String, String[]> loadDictionary(String language) { HashMap<String, String[]> dict = new HashMap<>(); InputStream model = getClass().getClassLoader().getResourceAsStream(language + "_index"); if (model != null) { try { List<String> lines = IOUtils.readLines(model, Charset.forName("UTF-8")); lines.forEach(s -> { String[] components = mainDivider.split(s); if (components.length == 2) { String lemma = components[0]; String[] synsets = subDivider.split(components[1]); dict.put(lemma, synsets); } }); } catch (IOException e) { e.printStackTrace(); } } return dict; }
From source file:com.nike.cerberus.operation.vault.VaultHealthCheckOperation.java
@Override public void run(VaultHealthCheckCommand command) { List<String> msgList = Lists.newLinkedList(); boolean toggle = false; do {//w w w .j av a 2s .c o m final List<VaultAdminClient> clients = vaultAdminClientFactory.getClientsForCluster(); clients.forEach(client -> { try { VaultHealthResponse response = client.health(); msgList.add(String.format("%s: Initialized: %s, Sealed: %s, Standby: %s", client.getVaultUrl(), colorify(response.isInitialized()), colorify(response.isSealed()), colorify(response.isStandby()))); } catch (Throwable t) { msgList.add(String.format("ERROR: %s", t.getMessage())); } }); String sym = toggle ? "*" : "+"; sym = StringUtils.repeat(sym, 20); if (command.isPoll()) { logger.info(Ansi.eraseScreen()); } logger.info(String.format("%s - Vault Health Status - %s", sym, sym)); msgList.forEach(logger::info); msgList.clear(); toggle = !toggle; try { Thread.sleep(TimeUnit.SECONDS.toMillis(1)); } catch (InterruptedException e) { break; } } while (command.isPoll()); }