List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:me.bulat.jivr.webmin.data.service.login.LoginServiceImpl.java
@Override @Transactional/*from w w w. j a va 2 s .com*/ public void saveUser(User user) throws DataAccessException { List<Role> roles = user.getRoles(); user.setRoles(null); repository.addUser(user); roles.forEach(role -> role.setUserId(user.getUserId())); repository.addRoles(roles); }
From source file:com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageInstance.java
@Override public WebPage redirect() { List<NewWindowNotifyingBehavior> behaviors = page.getBehaviors(NewWindowNotifyingBehavior.class); behaviors.forEach(behavior -> page.remove(behavior)); page.add(new NewWindowNotifyingBehavior()); return page;/* w w w . j a v a2 s. c o m*/ }
From source file:org.openlmis.fulfillment.Resource2Db.java
/** * Inserts data into a single table. Given the columns and a list of data to insert, will * run a batch update to insert it./* w w w .j a v a 2s . co m*/ * @param tableName the name of the table (including schema) to insert into. * @param dataWithHeader a pair where pair.left is an ordered list of column names and pair.right * is an array of rows to insert, where each row is similarly ordered as * the columns in pair.left. */ private void insertToDbFromBatchedPair(String tableName, Pair<List<String>, List<Object[]>> dataWithHeader) { XLOGGER.entry(tableName); String columnDesc = dataWithHeader.getLeft().stream().collect(joining(",")); String valueDesc = dataWithHeader.getLeft().stream().map(s -> "?").collect((joining(","))); String insertSql = String.format("INSERT INTO %s (%s) VALUES (%s)", tableName, columnDesc, valueDesc); XLOGGER.info("Insert SQL: " + insertSql); List<Object[]> data = dataWithHeader.getRight(); data.forEach(e -> XLOGGER.info(tableName + ": " + Arrays.toString(e))); int[] updateCount = template.batchUpdate(insertSql, data); XLOGGER.exit("Total " + tableName + " inserts: " + Arrays.stream(updateCount).sum()); }
From source file:io.gravitee.definition.jackson.datatype.api.ser.ProxySerializer.java
@Override public void serialize(Proxy proxy, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeStartObject();// w ww .j a va2 s .c om jgen.writeStringField("context_path", proxy.getContextPath()); jgen.writeBooleanField("strip_context_path", proxy.isStripContextPath()); jgen.writeBooleanField("dumpRequest", proxy.isDumpRequest()); final List<Endpoint> endpoints = proxy.getEndpoints(); jgen.writeArrayFieldStart("endpoints"); endpoints.forEach(endpoint -> { try { jgen.writeObject(endpoint); } catch (IOException e) { e.printStackTrace(); } }); jgen.writeEndArray(); if (proxy.getLoadBalancer() != null) { jgen.writeObjectField("load_balancing", proxy.getLoadBalancer()); } if (proxy.getFailover() != null) { jgen.writeObjectField("failover", proxy.getFailover()); } jgen.writeEndObject(); }
From source file:edu.pitt.dbmi.ccd.queue.service.JobQueueService.java
public List<AlgorithmJob> createJobQueueList(String username) { List<AlgorithmJob> listItems = new ArrayList<>(); UserAccount userAccount = userAccountService.findByUsername(username); List<JobQueueInfo> listJobs = jobQueueInfoService.findByUserAccounts(Collections.singleton(userAccount)); listJobs.forEach(job -> { AlgorithmJob algorithmJob = JobQueueUtility.convertJobEntity2JobModel(job); listItems.add(algorithmJob);/*from w w w. ja v a 2s .c o m*/ }); return listItems; }
From source file:bg.elkabel.calculator.service.ConductorServiceImpl.java
@Override public List<ConductorViewModel> findAll() { List<Conductor> allConductors = this.conductorRepository.findAll(); List<ConductorViewModel> result = new ArrayList<>(); allConductors.forEach(c -> { ConductorViewModel currentConductor = this.modelMapper.map(c, ConductorViewModel.class); result.add(currentConductor);//from w w w.j av a2s . c o m }); return result.size() > 0 ? result : null; }
From source file:com.github.ljtfreitas.restify.spring.configure.BaseRestifyConfigurationRegistrar.java
protected void doScan(List<String> packages, RestifyableTypeScanner scanner, BeanDefinitionRegistry registry) { packages.forEach(p -> { scanner.findCandidateComponents(p).stream() .map(candidate -> new RestifyableType(candidate.getBeanClassName())) .forEach(type -> create(type, registry)); });//w w w . j a va 2s .com }
From source file:ijfx.service.workflow.DefaultWorkflow.java
@JsonSetter("stepList") public void serializeStepList(List<DefaultWorkflowStep> stepList) { //steps = stepList; steps.clear();/*w w w . ja v a 2 s. c o m*/ stepList.forEach(step -> steps.add(step)); }
From source file:com.creactiviti.piper.plugin.ffmpeg.Ffmpeg.java
@Override public Object handle(Task aTask) throws Exception { List<String> options = aTask.getList("options", String.class); CommandLine cmd = new CommandLine("ffmpeg"); options.forEach(o -> cmd.addArgument(o)); log.debug("{}", cmd); DefaultExecutor exec = new DefaultExecutor(); File tempFile = File.createTempFile("log", null); try (PrintStream stream = new PrintStream(tempFile);) { exec.setStreamHandler(new PumpStreamHandler(stream)); int exitValue = exec.execute(cmd); return exitValue != 0 ? FileUtils.readFileToString(tempFile) : cmd.toString(); } catch (ExecuteException e) { throw new ExecuteException(e.getMessage(), e.getExitValue(), new RuntimeException(FileUtils.readFileToString(tempFile))); } finally {//from www . ja v a2 s .com FileUtils.deleteQuietly(tempFile); } }
From source file:com.twosigma.beakerx.security.HashedMessageAuthenticationCode.java
public String signBytes(List<byte[]> msg) { try {/*ww w.j a va 2 s .co m*/ final Mac mac = Mac.getInstance(TYPE); mac.init(spec); msg.forEach(it -> mac.update(it)); byte[] digest = mac.doFinal(); return toHex(digest); } catch (InvalidKeyException e) { throw new RuntimeException(INVALID_HMAC_EXCEPTION, e); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }