List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:org.obiba.mica.micaConfig.rest.CustomTranslationsResource.java
@PUT @Path("/import") @Consumes("application/json") public Response importTranslations(String translations, @QueryParam("merge") @DefaultValue("false") boolean merge) throws IOException { MicaConfig config = micaConfigService.getConfig(); JsonNode node = objectMapper.readTree(translations); List<String> locales = config.getLocalesAsString(); if (!config.hasTranslations()) { config.setTranslations(new LocalizedString()); }// w w w .j av a2 s . co m if (merge) { locales.forEach(l -> { JsonNode merged = micaConfigService.mergeJson(getTranslations(l), node.get(l)); config.getTranslations().put(l, merged.toString()); }); } else { locales.forEach(l -> config.getTranslations().put(l, node.get(l).toString())); } micaConfigService.save(config); return Response.ok().build(); }
From source file:br.com.webbudget.application.component.table.PageRequest.java
/** * Converte as metas de sort do primefaces para uma lista legivel pela * camada de dominio do sistema/*from ww w . jav a 2 s . c o m*/ * * @param metas as metas vindas das view * @return a lista de campos para sort */ private List<MultiSortField> sortMetaToSortFields(List<SortMeta> metas) { final List<MultiSortField> fields = new ArrayList<>(); if (metas != null) { metas.forEach(meta -> { fields.add(new MultiSortField(meta.getSortField(), meta.getSortOrder().name())); }); } return fields; }
From source file:ch.admin.suis.msghandler.signer.SignerTest.java
public void testSigningWithOneOutbox_MSGHANDLER_64() throws SignerException, IOException, ConfigurationException { cleanOutboxes();/*w w w .j ava 2 s . co m*/ // Populate signing inbox with PDF files. There a 3 files with extension .pdf there, but one of them is not a PDF // file! List<File> files = getAllFilesFromDir(new File(BASE_PATH_MSGHANDLER_64)); for (File f : files) { FileUtils.copyFile(f, new File(signingOutbox1, f.getName())); } System.out.println("testSigningWithOneOutbox_MSGHANDLER_64"); final File workingDir = createWorkingDir(); final File corruptedDir = new File(workingDir, ClientCommons.CORRUPTED_DIR); SigningOutbox signOutbox = new SigningOutboxMHCfg(p12File, "12345678", signingOutbox1, signatureProperties, null); Signer signer = new Signer(signOutbox, workingDir, corruptedDir); List<File> signedFiles = signer.sign(); signedFiles.forEach((f) -> { f.deleteOnExit(); }); assertEquals("We must have two signed files", 2, signedFiles.size()); assertEquals("The corrupted directory must contain one file", 1, FileUtils.listFiles(corruptedDir, TrueFileFilter.INSTANCE, null).size()); File foundFile = FileUtils.listFiles(corruptedDir, TrueFileFilter.INSTANCE, null).iterator().next(); assertEquals("The file in the corrupted dir must be 'pdfA-not_a_pdf_file.pdf'", "pdfA-not_a_pdf_file.pdf", foundFile.getName()); signer.cleanUp(signedFiles); }
From source file:com.oneops.transistor.util.CloudUtil.java
private Map<String, TreeSet<String>> getMissingCloudServices(long manifestPlatCiId, Set<String> requiredServices) { Map<String, TreeSet<String>> missingCloud2Services = new TreeMap<>(); //get clouds/*from w ww. j a v a2 s . com*/ List<CmsRfcRelation> cloudRelations = getCloudsForPlatform(manifestPlatCiId); // get services for all clouds cloudRelations.forEach(cloudRelation -> { Set<String> cloudServices = getCloudServices(cloudRelation); String cloud = cloudRelation.getToRfcCi().getCiName(); //check if service is configured requiredServices.stream().filter(s -> !cloudServices.contains(s)) .forEach(s -> missingCloud2Services.computeIfAbsent(cloud, k -> new TreeSet<>()).add(s)); logger.debug("cloud: " + cloud + " required services:: " + requiredServices.toString() + " missingServices " + missingCloud2Services.keySet()); }); return missingCloud2Services; }
From source file:com.klaussoft.springtest.CostumerController.java
@RequestMapping("/costumerme") public List<Costumer> costumerme(@RequestParam(value = "name", defaultValue = "World") String cname) { List<Costumer> costumers = new ArrayList<Costumer>(); log.info("Creating tables"); jdbcTemplate.execute("DROP TABLE customers IF EXISTS"); jdbcTemplate/*from ww w . j a v a2 s .c o m*/ .execute("CREATE TABLE customers(" + "id SERIAL, first_name VARCHAR(255), last_name VARCHAR(255))"); // Split up the array of whole names into an array of first/last names List<Object[]> splitUpNames = Arrays.asList("John Woo", "Jeff Dean", "Josh Bloch", "Josh Long").stream() .map(name -> name.split(" ")).collect(Collectors.toList()); // Use a Java 8 stream to print out each tuple of the list splitUpNames .forEach(name -> log.info(String.format("Inserting customer record for %s %s", name[0], name[1]))); // Uses JdbcTemplate's batchUpdate operation to bulk load data jdbcTemplate.batchUpdate("INSERT INTO customers(first_name, last_name) VALUES (?,?)", splitUpNames); log.info("Querying for customer records where first_name = 'Josh':"); jdbcTemplate .query("SELECT id, first_name, last_name FROM customers WHERE first_name = ?", new Object[] { "Josh" }, (rs, rowNum) -> new Costumer(rs.getLong("id"), "Josh", rs.getString("last_name"))) .forEach(customer -> costumers.add(customer)); return costumers; }
From source file:org.obiba.mica.file.service.TempFileService.java
@Scheduled(fixedDelay = TEMP_FILE_CLEANUP_INTERVAL) public void cleanupTempFiles() { log.debug("Cleaning up tempfiles"); List<TempFile> tempFiles = tempFileRepository.findByCreatedDateLessThan( DateTime.now().minusHours(TEMP_FILE_EXPIRE_TIMEOUT), new PageRequest(0, 100)); tempFiles.forEach(f -> tempFileRepository.delete(f)); }
From source file:com.haulmont.restapi.service.QueriesControllerManager.java
protected String _executeQuery(String entityName, String queryName, @Nullable Integer limit, @Nullable Integer offset, @Nullable String viewName, @Nullable Boolean returnNulls, @Nullable Boolean dynamicAttributes, @Nullable String version, Map<String, String> params) { LoadContext<Entity> ctx; entityName = restControllerUtils.transformEntityNameIfRequired(entityName, version, JsonTransformationDirection.FROM_VERSION); try {/*from w w w . ja va 2 s. c om*/ ctx = createQueryLoadContext(entityName, queryName, limit, offset, params); } catch (ClassNotFoundException | ParseException e) { throw new RestAPIException("Error on executing the query", e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR, e); } ctx.setLoadDynamicAttributes(BooleanUtils.isTrue(dynamicAttributes)); //override default view defined in queries config if (!Strings.isNullOrEmpty(viewName)) { MetaClass metaClass = restControllerUtils.getMetaClass(entityName); restControllerUtils.getView(metaClass, viewName); ctx.setView(viewName); } List<Entity> entities = dataManager.loadList(ctx); entities.forEach(entity -> restControllerUtils.applyAttributesSecurity(entity)); List<EntitySerializationOption> serializationOptions = new ArrayList<>(); serializationOptions.add(EntitySerializationOption.SERIALIZE_INSTANCE_NAME); if (BooleanUtils.isTrue(returnNulls)) serializationOptions.add(EntitySerializationOption.SERIALIZE_NULLS); String json = entitySerializationAPI.toJson(entities, ctx.getView(), serializationOptions.toArray(new EntitySerializationOption[0])); json = restControllerUtils.transformJsonIfRequired(entityName, version, JsonTransformationDirection.TO_VERSION, json); return json; }
From source file:com.spotify.scio.util.RemoteFileUtil.java
/** * Delete a batch of downloaded local files. *///ww w . j a va 2 s . co m public void delete(List<URI> srcs) { srcs.forEach(this::delete); }
From source file:com.ggvaidya.scinames.tabulardata.TabularDataViewController.java
/** * Provide an export of the data in the TableView as a "table". In its * simplest Java representation, that is a list of columns, with each * column starting with a column header and then all the rest of the data. * // w w w. j av a 2s . c o m * Warning: this can be a long-running function! * * @return A list of columns of data. */ public List<List<String>> getDataAsTable() { // What columns do we have? List<List<String>> result = new LinkedList<>(); List<TableColumn> columns = tableView.getColumns(); columns.forEach(col -> { List<String> column = new LinkedList<>(); // Add the header. column.add(col.getText()); // Add the data. for (int x = 0; x < tableView.getItems().size(); x++) { ObservableValue cellObservableValue = col.getCellObservableValue(x); Object val = cellObservableValue.getValue(); if (val == null) column.add("NA"); else column.add(val.toString()); } result.add(column); }); return result; }
From source file:eu.lunisolar.magma.doc.FileProcessor.java
void flushBuffer() { final Optional<Integer> charsToCut = lineBuffer.stream().map(this::numberOfPrefixSpaces) .min(Integer::compare); if (charsToCut.isPresent()) { List<String> newLines = lineBuffer.stream().map(l -> cutPrefix(l, charsToCut.get())).collect(toList()); newLines.forEach(this::print); } else {/*from www . j a va 2s. c o m*/ lineBuffer.forEach(this::print); } lineBuffer.clear(); }