List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:nc.noumea.mairie.appock.viewmodel.EditStockViewModel.java
protected void creeMultipleNouvelleSortieStock(List<EntreeSortieStock> listeSortieStock) { listeSortieStock.forEach(sortieStock -> { // On rcupre la dernire version de ArticleStock mis jour par les itrations prcdentes Stock stock = stockService.findOne(sortieStock.getArticleStock().getStock().getId()); Optional<ArticleStock> optionalArticleStock = stock.getListeArticleStock().stream() .filter(a -> a.getId().equals(sortieStock.getArticleStock().getId())).findFirst(); optionalArticleStock.ifPresent(articleStock -> creeNouvelleSortieStock(articleStock, sortieStock.getQuantiteASortir(), sortieStock.getObservation())); });//from w w w.j a v a2 s.com }
From source file:inflor.core.plots.FCSChartPanel.java
public List<AbstractGate> createAbstractGates() { List<AbstractGate> gates = gateAnnotations.keySet().stream().map(ChartUtils::createGate) .collect(Collectors.toList()); gates.forEach(gate -> gate.setParentID(data.getID())); return gates; }
From source file:com.streamsets.datacollector.pipeline.executor.spark.yarn.YarnAppLauncher.java
/** * If there is a RecordEL, then an arg could eval to empty string. This method returns * args that are not null or empty./*from w ww. ja va 2s . co m*/ */ private String[] getNonEmptyArgs(List<String> appArgs) { List<String> nonEmpty = new ArrayList<>(); appArgs.forEach((String val) -> { if (!StringUtils.isEmpty(val)) { nonEmpty.add(val); } }); return nonEmpty.toArray(new String[nonEmpty.size()]); }
From source file:com.dickthedeployer.dick.web.service.SchedulerService.java
@Scheduled(fixedRateString = "${dock.web.scheduler.assign:1000}") public void assignJobsToWorkers() { List<JobBuild> jobBuilds = jobBuildDao .findByStatusAndWorkerNull(com.dickthedeployer.dick.web.domain.JobBuild.Status.READY); List<Worker> availableWorkers = workerDao.findByStatus(Worker.Status.READY); if (!availableWorkers.isEmpty()) { log.debug("Found available workers. Scheduling jobs"); jobBuilds.forEach(workerService::assignJobBuildToWorker); }//from w ww.j a va 2 s .c o m }
From source file:com.nike.cerberus.service.MetaDataService.java
protected List<SDBMetaData> getSDBMetaDataList(int limit, int offset) { List<SDBMetaData> sdbs = new LinkedList<>(); // Collect the categories. Map<String, String> catIdToStringMap = getCategoryIdToStringMap(); // Collect the roles Map<String, String> roleIdToStringMap = getRoleIdToStringMap(); // Collect The SDB Records final List<SafeDepositBoxRecord> safeDepositBoxRecords = safeDepositBoxDao.getSafeDepositBoxes(limit, offset);/*w w w.java 2 s . co m*/ // for each SDB collect the user and iam permissions and add to result safeDepositBoxRecords.forEach(sdb -> { SDBMetaData data = new SDBMetaData(); data.setName(sdb.getName()); data.setPath(sdb.getPath()); data.setDescription(sdb.getDescription()); data.setCategory(catIdToStringMap.get(sdb.getCategoryId())); data.setCreatedBy(sdb.getCreatedBy()); data.setCreatedTs(sdb.getCreatedTs()); data.setLastUpdatedBy(sdb.getLastUpdatedBy()); data.setLastUpdatedTs(sdb.getLastUpdatedTs()); // set the owner and map group to roles processGroupData(roleIdToStringMap, data, sdb.getId()); data.setIamRolePermissions(getIamRolePermissionMap(roleIdToStringMap, sdb.getId())); sdbs.add(data); }); return sdbs; }
From source file:cz.lbenda.dataman.db.frm.DbConfigFrmController.java
@Override public void initialize(URL url, ResourceBundle resourceBundle) { lvLibraries.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); btnAddLibrary.setOnAction(event -> { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(msgLibraryChooseTitle); fileChooser.getExtensionFilters().addAll(Constants.librariesFilter); List<File> files = fileChooser.showOpenMultipleDialog(btnAddLibrary.getScene().getWindow()); if (files != null) { files.forEach(file -> lvLibraries.getItems().add(file.getAbsolutePath())); }/*from w w w . j ava 2s . c o m*/ }); btnRemoveLibrary.setOnAction( event -> lvLibraries.getItems().removeAll(lvLibraries.getSelectionModel().getSelectedItems())); btnExtendConfigFindPath.setOnAction(event -> { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(msgExtendConfigChooseTitle); fileChooser.getExtensionFilters().addAll(Constants.configFileFilter); if (StringUtils.isEmpty(tfExtendConfigPath.getText())) { fileChooser.setInitialFileName(tfExtendConfigPath.getText()); } File file = fileChooser.showOpenDialog(btnExtendConfigFindPath.getScene().getWindow()); if (file != null) { tfExtendConfigPath.setText(file.getAbsolutePath()); } }); lvLibraries.getItems().addListener((ListChangeListener<String>) change -> { while (change.next()) { if (change.wasAdded() || change.wasRemoved()) { findDriverClasses(); } } }); }
From source file:com.twosigma.beakerx.evaluator.BaseEvaluator.java
@Override public List<Path> addJarsToClasspath(List<PathToJar> paths) { LinkedList<Path> addedPaths = new LinkedList<>(); paths.forEach(path -> { if (addJarToClasspath(path)) { addedPaths.add(Paths.get(path.getPath())); }//from ww w . ja va 2 s. c o m }); doReloadEvaluator(); return addedPaths; }
From source file:uk.co.flax.ukmp.twitter.TweetUpdateThread.java
private void storeUpdates(List<Status> updates) { if (!updates.isEmpty()) { try {/* w w w. j a va 2 s . c o m*/ List<Tweet> tweets = new ArrayList<>(updates.size()); updates.forEach(update -> tweets.add(buildTweetFromStatus(update))); searchEngine.indexTweets(tweets); LOGGER.debug("Indexed {} tweets", updates.size()); // Store the tweets storeTweets(tweets); } catch (SearchEngineException e) { LOGGER.error("Could not index {} tweets: {}", updates.size(), e.getMessage()); } catch (IOException e) { LOGGER.error("Could not store tweets: {}", e.getMessage()); } } }
From source file:hydrograph.ui.graph.debugconverter.SchemaHelper.java
private void removeDuplicateKeys(List<String> oldKeys, Map<String, SubjobDetails> componentNameAndLink) { if (componentNameAndLink.size() > 1) { oldKeys.forEach(field -> componentNameAndLink.remove(field)); }// ww w .j a v a2 s.c o m }
From source file:edu.pitt.dbmi.ccd.queue.service.AlgorithmQueueService.java
@Async public Future<Void> runAlgorithmFromQueue(JobQueueInfo jobQueueInfo) { Long queueId = jobQueueInfo.getId(); String fileName = jobQueueInfo.getFileName() + ".txt"; String jsonFileName = jobQueueInfo.getFileName() + ".json"; String commands = jobQueueInfo.getCommands(); String tmpDirectory = jobQueueInfo.getTmpDirectory(); String outputDirectory = jobQueueInfo.getOutputDirectory(); List<String> cmdList = new LinkedList<>(); cmdList.addAll(Arrays.asList(commands.split(";"))); cmdList.add("--out"); cmdList.add(tmpDirectory);//ww w . j ava2 s . c om StringBuilder sb = new StringBuilder(); cmdList.forEach(cmd -> { sb.append(cmd); sb.append(" "); }); LOGGER.info("Algorithm command: " + sb.toString()); String errorFileName = String.format("error_%s", fileName); Path error = Paths.get(tmpDirectory, errorFileName); Path errorDest = Paths.get(outputDirectory, errorFileName); Path src = Paths.get(tmpDirectory, fileName); Path dest = Paths.get(outputDirectory, fileName); Path json = Paths.get(tmpDirectory, jsonFileName); Path jsonDest = Paths.get(outputDirectory, jsonFileName); try { ProcessBuilder pb = new ProcessBuilder(cmdList); pb.redirectError(error.toFile()); Process process = pb.start(); //Get process Id Long pid = Processes.processId(process); JobQueueInfo queuedJobInfo = jobQueueInfoService.findOne(queueId); LOGGER.info("Set Job's pid to be: " + pid); queuedJobInfo.setPid(pid); jobQueueInfoService.saveJobIntoQueue(queuedJobInfo); process.waitFor(); if (process.exitValue() == 0) { LOGGER.info(String.format("Moving txt file %s to %s", src, dest)); Files.move(src, dest, StandardCopyOption.REPLACE_EXISTING); LOGGER.info(String.format("Moving json file %s to %s", json, dest)); Files.move(json, jsonDest, StandardCopyOption.REPLACE_EXISTING); Files.deleteIfExists(error); } else { LOGGER.info(String.format("Deleting tmp txt file %s", src)); Files.deleteIfExists(src); LOGGER.info(String.format("Moving error file %s to %s", error, errorDest)); Files.move(error, errorDest, StandardCopyOption.REPLACE_EXISTING); } } catch (IOException | InterruptedException exception) { LOGGER.error("Algorithm did not run successfully.", exception); } LOGGER.info("Delete Job ID from queue: " + queueId); jobQueueInfoService.deleteJobById(queueId); return new AsyncResult<>(null); }