List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:edu.pitt.dbmi.ccd.queue.task.ScheduledAlgorithJob.java
@Scheduled(fixedRate = 5000) public void executeJobInQueue() { Platform platform = Platform.detect(); List<JobQueueInfo> jobsToSave = new LinkedList<>(); List<JobQueueInfo> runningJobList = jobQueueInfoService.findByStatus(1); runningJobList.forEach(job -> { Long pid = job.getPid();/*from w ww.j a v a2 s . c om*/ if (pid == null || !Processes.isProcessRunning(platform, pid)) { job.setStatus(2); // request to kill jobsToSave.add(job); } }); jobQueueInfoService.saveAll(jobsToSave); runningJobList = jobQueueInfoService.findByStatus(1); int numRunningJobs = runningJobList.size(); if (numRunningJobs < queueSize) { // Waiting list to execute List<JobQueueInfo> jobList = jobQueueInfoService.findByStatus(0); if (!jobList.isEmpty()) { // Execute one at a time JobQueueInfo jobQueueInfo = jobList.get(0); LOGGER.info("Run Job ID: " + jobQueueInfo.getId()); try { LOGGER.info("Set Job's status to be 1 (running): " + jobQueueInfo.getId()); jobQueueInfo.setStatus(1); jobQueueInfoService.saveJobIntoQueue(jobQueueInfo); algorithmQueueService.runAlgorithmFromQueue(jobQueueInfo); } catch (Exception exception) { LOGGER.error("Unable to run " + jobQueueInfo.getAlgorName(), exception); } } } // Waiting list to terminate List<JobQueueInfo> jobList = jobQueueInfoService.findByStatus(2); jobList.forEach(job -> { killJob(job.getId()); }); }
From source file:com.github.frapontillo.pulse.crowd.sentiment.sentiwordnet.SentiWordNet.java
private HashMap<String, SentiWord> getDictionary() { if (dict == null) { dict = new HashMap<>(); InputStream model = getClass().getClassLoader().getResourceAsStream("sentiwordnet"); try {// w ww.j a v a2 s.c o m List<String> lines = IOUtils.readLines(model, Charset.forName("UTF-8")); lines.forEach(s -> { SentiWord word = fromLine(s); if (word != null) { dict.put(word.getId(), word); } }); } catch (IOException e) { e.printStackTrace(); } } return dict; }
From source file:de.hska.ld.recommendation.service.impl.DocumentRecommInfoServiceImpl.java
@Override public List<User> addMissingRecommendationUpdatesUsers(String accessToken) { List<User> userWithMissingRecommendationsList = userRecommInfoRepository.findAllUserWithoutUserRecommInfo(); userWithMissingRecommendationsList.forEach(uwmr -> { UserRecommInfo userRecommInfo = userRecommInfoRepository.findByUser(uwmr); if (userRecommInfo == null) { // send current tags of the document to the SSS try { sssClient.performInitialSSSTagLoadUsers(uwmr.getId(), accessToken); } catch (IOException e) { e.printStackTrace();//from w ww . ja v a 2 s . c o m } } }); return userWithMissingRecommendationsList; }
From source file:com.baidu.rigel.biplatform.ma.resource.utils.DataModelUtils.java
private static List<List<String>> genRowCaptions(List<HeadField> rowHeadFields) { List<List<String>> rs = Lists.newArrayList(); for (int i = 0; i < rowHeadFields.size(); ++i) { final HeadField headField = rowHeadFields.get(i); final List<HeadField> nodeList = headField.getNodeList(); List<String> tmp = Lists.newArrayList(); if (nodeList == null || nodeList.size() == 0) { tmp.add(rowHeadFields.get(i).getCaption()); } else {//from w w w.ja va 2 s . com List<List<String>> nodeListCaption = genRowCaptions(headField.getNodeList()); nodeListCaption.forEach(list -> { list.add(0, headField.getCaption()); }); rs.addAll(nodeListCaption); } rs.add(tmp); if (headField.getChildren() != null && headField.getChildren().size() > 0) { rs.addAll(genRowCaptions(headField.getChildren())); } } List<List<String>> tmp = Lists.newArrayList(); rs.stream().forEach(list -> { if (list != null && list.size() > 0) { tmp.add(list); } }); return tmp; }
From source file:org.obiba.mica.dataset.search.VariableIndexer.java
@Async @Subscribe/*from ww w .ja v a 2 s.com*/ public synchronized void documentSetUpdated(DocumentSetUpdatedEvent event) { if (!variableSetService.isForType(event.getPersistable())) return; List<DatasetVariable> toIndex = Lists.newArrayList(); String id = event.getPersistable().getId(); if (event.hasRemovedIdentifiers()) { List<DatasetVariable> toRemove = variableSetService.getVariables(event.getRemovedIdentifiers(), false); toRemove.forEach(var -> var.removeSet(id)); toIndex.addAll(toRemove); } List<DatasetVariable> variables = variableSetService.getVariables(event.getPersistable(), false); variables.stream().filter(var -> !var.containsSet(id)).forEach(var -> { var.addSet(id); toIndex.add(var); }); indexer.indexAllIndexables(Indexer.PUBLISHED_VARIABLE_INDEX, toIndex); }
From source file:edu.pitt.dbmi.ccd.db.service.DataFileService.java
public List<DataFile> saveDataFile(List<DataFile> dataFiles) { List<DataFileInfo> dataFileInfos = new LinkedList<>(); dataFiles.forEach(dataFile -> { DataFileInfo dataFileInfo = dataFile.getDataFileInfo(); if (dataFileInfo != null) { dataFileInfos.add(dataFileInfo); }// w w w . j a v a 2 s . co m }); dataFileInfoRepository.save(dataFileInfos); return dataFileRepository.save(dataFiles); }
From source file:org.kawakicchi.bookshelf.application.internal.DefaultViewerService.java
@Override public List<SeriesEntity> getSeriesList() { final Viewer viewer = Viewer.getViewer(); final List<Series> seriesList = viewer.getSeriesList(bookRepository); final List<SeriesEntity> result = new ArrayList<SeriesEntity>(); seriesList.forEach(series -> { SeriesEntity e = new SeriesEntity(series); final Page page = series.getTitlePage(bookRepository); if (null != page) { e.setTitlePageSeq(page.getPageSeq().getValue()); }/* www . j ava 2 s. c o m*/ result.add(e); }); return result; }
From source file:com.netflix.spinnaker.clouddriver.artifacts.helm.IndexParser.java
public List<String> findVersions(InputStream in, String name) throws IOException { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("Artifact name field should not be empty"); }/*www . j av a2s . c o m*/ List<EntryConfig> configs = buildEntryConfigsByName(buildIndexConfig(in), name); List<String> versions = new ArrayList<>(); configs.forEach(e -> versions.add(e.getVersion())); return versions; }
From source file:com.linecorp.bot.spring.boot.support.LineMessageHandlerSupport.java
@PostMapping("${line.bot.handler.path:/callback}") public void callback(@LineBotMessages List<Event> events) { events.forEach(this::dispatch); }
From source file:guru.qas.martini.gherkin.DefaultMixology.java
protected List<Recipe> getRecipes(FeatureWrapper feature, Collection<Pickle> pickles) { Map<Integer, Recipe> recipeIndex = new LinkedHashMap<>(); RangeMap<Integer, ScenarioDefinition> rangeMap = getRangeMap(feature); for (Pickle pickle : pickles) { List<PickleLocation> locations = pickle.getLocations(); Map<Integer, PickleLocation> locationIndex = new HashMap<>(); locations.forEach(l -> { int line = l.getLine(); locationIndex.put(line, l);//from w ww .jav a 2 s.com }); Integer line = Ordering.natural().max(locationIndex.keySet()); recipeIndex.computeIfAbsent(line, l -> { PickleLocation location = locationIndex.get(l); Range<Integer> range = Range.singleton(line); RangeMap<Integer, ScenarioDefinition> subRangeMap = rangeMap.subRangeMap(range); Map<Range<Integer>, ScenarioDefinition> asMap = subRangeMap.asMapOfRanges(); checkState(1 == asMap.size(), "no single range found encompassing PickleLocation %s", location); ScenarioDefinition definition = Iterables.getOnlyElement(asMap.values()); return new DefaultRecipe(feature, pickle, location, definition); }); } return ImmutableList.copyOf(recipeIndex.values()); }