List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:dk.dma.msinm.legacy.nm.LegacyNmImportService.java
/** * Ensures that the template charts area all saved * @param templateCharts the template charts * @return the actual charts/*w w w . j a va 2 s . c o m*/ */ private List<Chart> findOrCreateCharts(List<Chart> templateCharts) { List<Chart> result = new ArrayList<>(); templateCharts.forEach(templateChart -> { Chart chart = chartService.findByChartNumber(templateChart.getChartNumber()); if (chart == null) { chart = chartService.createChart(templateChart); } result.add(chart); }); return result; }
From source file:fr.lepellerin.ecole.service.internal.UtilisateurServiceImpl.java
@Override @Transactional(readOnly = false)//from ww w .j av a 2 s . com public List<ForgottenPwdDto> resetPasswordForFamille(final String email) { final List<ForgottenPwdDto> dtos = new ArrayList<>(); final List<Famille> fams = this.familleRepository.findFamilleByEmail(email); fams.forEach(fam -> { final ForgottenPwdDto dto = new ForgottenPwdDto(); final String pwd = PasswordGenerator.randomString(8); final String hashedPwd = this.passwordEncoder.encode(pwd); final List<Individu> individus = this.individuRepository.findUserByFamille(fam); final User user = this.userRepository.findOneByFamille(fam); if (user != null) { dto.setAccount(user.getUsername()); dto.setPassword(pwd); dto.setEmails(new ArrayList<>()); user.setPassword(hashedPwd); individus.forEach(i -> { if (i.getMail() != null) { dto.getEmails().add(i.getMail()); } }); this.userRepository.save(user); dtos.add(dto); } }); return dtos; }
From source file:com.centurylink.cloud.sdk.server.services.client.domain.ip.PublicIpRequest.java
/** * Specify List of source restrictions in CIDR(Classless Inter-Domain Routing) format * @param sourceRestrictions list of source restrictions * @return PublicIp configuration/*from ww w. j ava2s . c om*/ */ public PublicIpRequest sourceRestrictions(List<String> sourceRestrictions) { List<SourceRestriction> restrictions = new ArrayList<>(sourceRestrictions.size()); sourceRestrictions.forEach(value -> restrictions.add(new SourceRestriction(value))); setSourceRestrictions(restrictions); return this; }
From source file:io.syndesis.rest.v1.handler.setup.OAuthAppHandler.java
@GET @Produces(MediaType.APPLICATION_JSON)//from w w w . j av a 2 s . co m @Path(value = "") public List<OAuthApp> get() { ArrayList<OAuthApp> apps = new ArrayList<>(); List<Connector> items = dataMgr.fetchAll(Connector.class).getItems(); items.forEach(connector -> { if (isOauthConnector(connector)) { apps.add(createOAuthApp(connector)); } }); return apps; }
From source file:com.github.horrorho.inflatabledonkey.requests.ProtoBufsRequestFactory.java
public <T extends GeneratedMessage> HttpUriRequest newRequest(String url, String container, String bundle, String cloudKitUserId, String cloudKitToken, String uuid, List<T> protobufs) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); protobufs.forEach(message -> { try {//from w w w .jav a2s . co m message.writeDelimitedTo(baos); } catch (IOException ex) { throw new UncheckedIOException(ex); } }); ByteArrayEntity byteArrayEntity = new ByteArrayEntity(baos.toByteArray()); HttpPost post = new HttpPost(url); post.setHeader(Headers.XAPPLEREQUESTUUID.header(uuid)); post.setHeader(Headers.XCLOUDKITUSERID.header(cloudKitUserId)); post.setHeader(Headers.XCLOUDKITAUTHTOKEN.header(cloudKitToken)); post.setHeader(Headers.XCLOUDKITCONTAINERID.header(container)); post.setHeader(Headers.XCLOUDKITBUNDLEID.header(bundle)); post.setHeader(HttpHeaders.ACCEPT, "application/x-protobuf"); post.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-protobuf; desc=\"https://p33-ckdatabase.icloud.com:443/static/protobuf/CloudDB/CloudDBClient.desc\"; messageType=RequestOperation; delimited=true"); post.addHeader(headers.get(Headers.USERAGENT)); post.addHeader(headers.get(Headers.XCLOUDKITPROTOCOLVERSION)); post.addHeader(headers.get(Headers.XMMECLIENTINFO)); post.setEntity(byteArrayEntity); return post; }
From source file:mesclasses.objects.LoadWindow.java
public LoadWindow(Stage stage, List<AppTask> tasks) { tasks.forEach(t -> { services.add(new LoadingService(t)); });/* w ww . j a v a2s . c o m*/ dialogStage = new Stage(); dialogStage.setTitle("Chargement"); dialogStage.initModality(Modality.WINDOW_MODAL); dialogStage.initOwner(stage); dialogStage.setScene(createloadingScene()); LOG.info("LOAD WINDOW REQUESTED. tasks = " + StringUtils.join(getTaskNames(), ",")); }
From source file:cz.muni.fi.editor.services.api.notifications.NotificationServiceImpl.java
private void notifyMultiple(EditorEvent event, List<User> notified) { notified.forEach(u -> { Notification n = notificationFactory.provideNotification(event); n.setNotified(u);//w w w. ja v a 2 s .com notificationDAO.create(n); }); }
From source file:com.devicehive.dao.riak.NetworkDeviceDaoRiakImpl.java
public Set<Long> findNetworksForDevice(String deviceUuid) { BinIndexQuery biq = new BinIndexQuery.Builder(NETWORK_DEVICE_NS, "deviceUuid", deviceUuid).build(); try {// w ww . j av a 2 s . c o m BinIndexQuery.Response response = client.execute(biq); List<NetworkDevice> nds = fetchMultiple(response, NetworkDevice.class); Set<Long> networks = new HashSet<>(); nds.forEach(networkDevice -> networks.add(networkDevice.getNetworkId())); return networks; } catch (ExecutionException | InterruptedException e) { throw new HivePersistenceLayerException("Cannot find networks for device.", e); } }
From source file:com.enitalk.opentok.OpenTokListener.java
@Scheduled(fixedDelay = 10000L) public void updateFinalStatus() { try {/*w w w .j av a 2 s. c om*/ Criteria cc3 = Criteria.where("status").is(2); Criteria cc1 = Criteria.where("video").exists(false); Query q = Query.query(Criteria.where("endDate").lt(new DateTime().toDate()).andOperator(cc3, cc1)); q.fields().exclude("_id").include("opentok").include("ii"); List<HashMap> eligibleEvents = mongo.find(q, HashMap.class, "events"); if (!eligibleEvents.isEmpty()) { ArrayNode evs = jackson.convertValue(eligibleEvents, ArrayNode.class); Iterator<JsonNode> evIt = evs.elements(); while (evIt.hasNext()) { JsonNode ev = evIt.next(); HashMultimap<String, String> mmap = HashMultimap.create(); List<JsonNode> alls = ev.path("opentok").findParents("id"); alls.forEach((JsonNode op) -> { mmap.put(op.path("id").asText(), op.path("status").asText()); }); logger.info("Opentok multimap {}", mmap); long uploadedArchives = mmap.keySet().stream().filter((String id) -> { return mmap.get(id).contains("uploaded"); }).count(); if (uploadedArchives == mmap.keySet().size()) { logger.info("All archives uploaded, process further"); mongo.updateFirst(Query.query(Criteria.where("ii").is(ev.path("ii").asText())), new Update().set("video", 0), "events"); } else { logger.info("Only {} of {} archives uploaded", uploadedArchives, mmap); } } } } catch (Exception e) { logger.error(ExceptionUtils.getFullStackTrace(e)); } }
From source file:com.centurylink.cloud.sdk.sample.port.adapter.web.DataCenterController.java
@RequestMapping(method = GET) List<DataCenterBean> findAll() { List<DataCenterMetadata> dataCenters = sdkRegistry.getSdk().dataCenterService().findAll(); List<DataCenterBean> dataCenterBeans = new ArrayList<>(dataCenters.size()); dataCenters.forEach( dataCenter -> dataCenterBeans.add(new DataCenterBean(dataCenter.getId(), dataCenter.getName()))); return dataCenterBeans; }