List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:com.mec.Services.EstablecimientosService.java
private void toDTO(List<EstablecimientoPost> establecimientos) { Map<String, List<EstablecimientoDTO>> _DTO = new HashMap<>(); establecimientos.forEach(est -> { est.getLocalizacion().forEach(anexo -> { EstablecimientoDTO holder = new EstablecimientoDTO(anexo.getNombre(), anexo.getAnexo()); if (!_DTO.containsKey(est.getCue())) { _DTO.put(est.getCue(), new ArrayList() { {/*from w w w.j a v a2 s.co m*/ add(holder); } }); } else { _DTO.get(est.getCue()).add(holder); } }); }); this.DTO = _DTO; }
From source file:it.smartcommunitylab.aac.controller.AdminController.java
@ExceptionHandler(MethodArgumentNotValidException.class) @ResponseStatus(HttpStatus.BAD_REQUEST)// w w w . j av a 2 s .c o m @ResponseBody public Response processValidationError(MethodArgumentNotValidException ex) { BindingResult br = ex.getBindingResult(); List<FieldError> fieldErrors = br.getFieldErrors(); StringBuilder builder = new StringBuilder(); fieldErrors.forEach(fe -> builder.append(fe.getDefaultMessage()).append("\n")); return Response.error(builder.toString()); }
From source file:cz.cvut.kbss.jsonld.jackson.environment.deserialization.JsonLdDeserializationTest.java
@Test public void testDeserializeCollectionOfInstances() throws Exception { final String input = Environment.readData("collectionOfInstances.json"); final List<Employee> result = objectMapper.readValue(input, new TypeReference<List<Employee>>() { });//w ww. j av a 2s.c o m assertNotNull(result); assertFalse(result.isEmpty()); result.forEach(e -> { final User expected = USERS.get(e.getUri()); verifyUserAttributes(expected, e); }); }
From source file:com.thinkbiganalytics.alerts.rest.AlertsModel.java
public Collection<AlertSummaryGrouped> groupAlertSummaries(List<AlertSummary> alertSummaries) { Map<String, AlertSummaryGrouped> group = new HashMap<>(); alertSummaries.forEach(alertSummary -> { String key = alertSummary.getType() + ":" + alertSummary.getSubtype(); String displayName = alertTypeDisplayName(alertSummary); if (alertSummary instanceof EntityAwareAlertSummary) { EntityAwareAlertSummary entityAwareAlertSummary = (EntityAwareAlertSummary) alertSummary; key = entityAwareAlertSummary.getGroupByKey(); group.computeIfAbsent(key,// w w w .j a va 2s .c om key1 -> new AlertSummaryGrouped.Builder().typeString(alertSummary.getType()) .typeDisplayName(displayName).subType(entityAwareAlertSummary.getSubtype()) .feedId(entityAwareAlertSummary.getFeedId() != null ? entityAwareAlertSummary.getFeedId().toString() : null) .feedName(entityAwareAlertSummary.getFeedName()) .slaId(entityAwareAlertSummary.getSlaId() != null ? entityAwareAlertSummary.getSlaId().toString() : null) .slaName(entityAwareAlertSummary.getSlaName()).build()) .add(toModel(alertSummary.getLevel()), alertSummary.getCount(), alertSummary.getLastAlertTimestamp()); } else { group.computeIfAbsent(key, key1 -> new AlertSummaryGrouped.Builder().typeString(alertSummary.getType()) .typeDisplayName(displayName).subType(alertSummary.getSubtype()).build()) .add(toModel(alertSummary.getLevel()), alertSummary.getCount(), alertSummary.getLastAlertTimestamp()); } }); return group.values(); }
From source file:net.bluewizardhat.yamlcfn.sg.YamlParser.java
@SuppressWarnings("unchecked") private void parseConnections(List<UnresolvedConnection> connections, List<?> list, boolean allowNamesOnly) { list.forEach(e -> { if (e instanceof String) { if (!allowNamesOnly) { throw new IllegalArgumentException("inbound rules must specify type and ports"); }//from w ww .j a v a 2 s.co m connections.add(new UnresolvedConnection.Ref((String) e)); } else if (e instanceof Map) { Map<String, String> m = (Map<String, String>) e; String ref = m.get("ref"); String cidr = m.get("cidr"); String type = m.get("type"); String ports = m.get("ports"); if (ref != null) { parsePorts(connections, ref, Protocol.from(type), ports, RefWithPort::new); } else if (cidr != null) { parsePorts(connections, cidr, Protocol.from(type), ports, CidrWithPort::new); } else { throw new IllegalArgumentException("Unable to parse: " + m); } } }); }
From source file:dk.dma.msinm.legacy.nm.LegacyNmImportRestService.java
/** * Extracts the list of active P&T NM's from the PDF * @param inputStream the PDF input stream * @param fileName the name of the PDF file * @param txt a log of the import/* w ww . j av a 2 s . c o m*/ */ private void updateActiveNm(InputStream inputStream, String fileName, StringBuilder txt) throws Exception { log.info("Extracting active P&T NtM's from PDF " + fileName); ActiveTempPrelimNmPdfExtractor extractor = new ActiveTempPrelimNmPdfExtractor(inputStream, fileName, app.getOrganization()); List<SeriesIdentifier> noticeIds = new ArrayList<>(); extractor.extractActiveNoticeIds(noticeIds); log.info("Extracted " + noticeIds.size() + " active P&T NtM's from " + fileName); txt.append("Detected " + noticeIds.size() + " active P&T NtM's in PDF file " + fileName + "\n"); DateTime weekStartDate = new DateTime().withYear(extractor.getYear()) .withDayOfWeek(DateTimeConstants.MONDAY).withWeekOfWeekyear(extractor.getWeek()); List<Message> messages = messageService.inactivateTempPrelimNmMessages(noticeIds, weekStartDate.toDate()); messages.forEach(msg -> { txt.append("Inactivate NtM " + msg.getSeriesIdentifier() + "\n"); }); log.info("Inactivated " + messages.size()); }
From source file:com.antsdb.saltedfish.sql.mysql.Alter_table_stmtGenerator.java
@Override public Instruction gen(GeneratorContext ctx, Alter_table_stmtContext rule) throws OrcaException { Flow flow = new Flow(); ObjectName tableName = TableName.parse(ctx, rule.table_name_()); List<Alter_table_optionsContext> options = rule.alter_table_options(); options.forEach(it -> { if (it.alter_table_add_constraint() != null) { flow.add(createAddConstraint(ctx, tableName, it.alter_table_add_constraint())); } else if (it.alter_table_add_primary_key() != null) { flow.add(createAddPrimaryKey(ctx, tableName, it.alter_table_add_primary_key())); } else if (it.alter_table_modify() != null) { flow.add(modifyColumn(ctx, tableName, it.alter_table_modify())); } else if (it.alter_table_rename() != null) { flow.add(renameColumn(ctx, tableName, it.alter_table_rename())); } else if (it.alter_table_add() != null) { Column_def_setContext colSet = it.alter_table_add().column_def_set(); if (colSet.column_def() != null) { createColumn(flow, ctx, colSet.column_def(), tableName); } else if (colSet.column_def_list() != null) { colSet.column_def_list().column_def().forEach(itdef -> { createColumn(flow, ctx, itdef, tableName); });/* ww w . j a va 2 s . com*/ } } else if (it.alter_table_drop() != null) { flow.add(dropColumn(ctx, it.alter_table_drop(), tableName)); } else if (it.alter_table_disable_keys() != null) { _log.warn("ALTER TABLE DISABLE KEYS has not been implemented"); } else if (it.alter_table_enable_keys() != null) { _log.warn("ALTER TABLE ENABLE KEYS has not been implemented"); } else if (it.alter_table_add_index() != null) { flow.add(addIndex(ctx, it.alter_table_add_index(), tableName)); } else if (it.alter_table_drop_index() != null) { flow.add(dropIndex(ctx, it.alter_table_drop_index(), tableName)); } else { throw new NotImplementedException(); } }); flow.add(new SyncTableSequence(tableName, null)); return flow; }
From source file:de.hska.ld.content.service.impl.CommentServiceImpl.java
@Override public void sendMentionNotifications(Comment comment) { try {// www . j av a2 s . com Content tempParent = comment.getParent(); while (!(tempParent instanceof Document)) { tempParent = ((Comment) tempParent).getParent(); } final Document document = (Document) tempParent; List<User> userList = filterUserMentions(comment.getText()); userList.forEach(u -> subscriptionService.saveNotification(document.getId(), u.getId(), comment.getCreator().getId(), Subscription.Type.COMMENT)); } catch (Exception e) { // } }
From source file:com.github.frapontillo.pulse.crowd.lemmatize.morphit.MorphITLemmatizer.java
/** * Build the TANL-to-MorphIT mapping dictionary as <key:(tanl-tag), * value:(morphit-tag-1,...)>./* w ww . j a va 2s.c o m*/ * Values are read from the resource file "tanl-morphit". * * @return A {@link HashMap} where the key is a {@link String} representing the TANL tag and * values are {@link Set}s of all the MorphIT tag {@link String}s. */ private HashMap<String, HashSet<String>> getTanlMorphITMap() { if (tanlMorphITMap == null) { InputStream mapStream = MorphITLemmatizer.class.getClassLoader().getResourceAsStream("tanl-morphit"); tanlMorphITMap = new HashMap<>(); try { List<String> mapLines = IOUtils.readLines(mapStream, Charset.forName("UTF-8")); mapLines.forEach(s -> { // for each line, split using spaces String[] values = spacePattern.split(s); if (values.length > 0) { // the first token is the key String key = values[0]; // all subsequent tokens are possible values HashSet<String> valueSet = new HashSet<>(); valueSet.addAll(Arrays.asList(values).subList(1, values.length)); tanlMorphITMap.put(key, valueSet); } }); } catch (IOException e) { e.printStackTrace(); } } return tanlMorphITMap; }
From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.op.artifact.KubernetesCleanupArtifactsOperation.java
@Override public Void operate(List priorOutputs) { List<Artifact> artifacts = description.getManifests().stream().map(this::artifactsToDelete) .flatMap(Collection::stream).collect(Collectors.toList()); artifacts.forEach(a -> { String type = a.getType(); if (!type.startsWith("kubernetes/")) { log.warn("Non-kubernetes type deletion requested..."); return; }// ww w . j a v a 2 s . c om String kind = type.substring("kubernetes/".length()); KubernetesResourceProperties properties = registry.get(accountName, KubernetesKind.fromString(kind)); if (properties == null) { log.warn("No properties for artifact {}, ignoring", a); return; } getTask().updateStatus(OP_NAME, "Deleting artifact '" + a + '"'); KubernetesHandler handler = properties.getHandler(); String name = a.getName(); if (StringUtils.isNotEmpty(a.getVersion())) { name = String.join("-", name, a.getVersion()); } // todo add to outputs handler.delete(credentials, a.getLocation(), name, null, new V1DeleteOptions()); }); return null; }