List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:org.smigo.plants.PlantHandler.java
public List<Plant> addPlants(List<Plant> plants, Integer userId) { if (plants.isEmpty()) { return plants; }/*from w w w. j av a2s . c om*/ if (userId == null) { plantHolder.getPlants().addAll(plants); plants.forEach(plant -> plant.setId(plantId.incrementAndGet())); return plants; } plants.forEach(plant -> { plant.setUserId(userId); int id = plantDao.addPlant(plant); plant.setId(id); }); return plants; }
From source file:edu.usu.sdl.openstorefront.report.CategoryComponentReport.java
@Override protected void writeReport() { CSVGenerator cvsGenerator = (CSVGenerator) generator; String category = AttributeType.DI2E_SVCV4; if (StringUtils.isNotBlank(report.getReportOption().getCategory())) { category = report.getReportOption().getCategory(); }/*w ww.ja v a 2s .c om*/ //write header cvsGenerator.addLine("Category Component Report", sdf.format(TimeUtil.currentDate())); cvsGenerator.addLine("Category:" + category); cvsGenerator.addLine(""); cvsGenerator.addLine("Category Label", "Category Description", "Component Name", "Component Description", //"Security Classification", "Last Update Date"); //Only grab approved/active components AttributeType attributeType = service.getAttributeService().findType(category); List<AttributeCode> codes = service.getAttributeService().findCodesForType(category); if (Convert.toBoolean(attributeType.getArchitectureFlg())) { codes.sort(new AttributeCodeArchComparator<>()); } else { codes.sort(new AttributeCodeComparator<>()); } ComponentAttribute componentAttributeExample = new ComponentAttribute(); ComponentAttributePk componentAttributePk = new ComponentAttributePk(); componentAttributePk.setAttributeType(category); componentAttributeExample.setActiveStatus(ComponentAttribute.ACTIVE_STATUS); componentAttributeExample.setComponentAttributePk(componentAttributePk); List<ComponentAttribute> attributes = componentAttributeExample.findByExample(); Map<String, List<String>> codeComponentMap = new HashMap<>(); attributes.forEach(attribute -> { if (codeComponentMap.containsKey(attribute.getComponentAttributePk().getAttributeCode())) { codeComponentMap.get(attribute.getComponentAttributePk().getAttributeCode()) .add(attribute.getComponentId()); } else { List<String> componentIds = new ArrayList<>(); componentIds.add(attribute.getComponentId()); codeComponentMap.put(attribute.getComponentAttributePk().getAttributeCode(), componentIds); } }); Component componentExample = new Component(); componentExample.setActiveStatus(Component.ACTIVE_STATUS); componentExample.setApprovalState(ApprovalStatus.APPROVED); List<Component> components = componentExample.findByExample(); Map<String, Component> componentMap = new HashMap<>(); components.forEach(component -> { componentMap.put(component.getComponentId(), component); }); for (AttributeCode code : codes) { cvsGenerator.addLine(code.getLabel(), code.getDescription()); List<String> componentIds = codeComponentMap.get(code.getAttributeCodePk().getAttributeCode()); if (componentIds != null) { for (String componentId : codeComponentMap.get(code.getAttributeCodePk().getAttributeCode())) { Component component = componentMap.get(componentId); if (component != null) { cvsGenerator.addLine("", "", component.getName(), component.getDescription(), //component.getSecurityMarkingType(), sdf.format(component.getLastActivityDts())); } } } } }
From source file:com.github.mrstampy.gameboot.messages.context.GameBootContextLoader.java
/** * Gets the for locale./* www. j a v a 2 s . c om*/ * * @param suffix * the suffix * @return the for locale * @throws IOException * Signals that an I/O exception has occurred. */ public Map<Integer, ResponseContext> getForLocale(String suffix) throws IOException { Resource r = getOverridableErrorResource(suffix); if (r == null || !r.exists()) { log.trace("No error.properties for {}", suffix); return null; } Properties p = new Properties(); p.load(r.getInputStream()); List<String> codes = getCodes(p); Map<Integer, ResponseContext> map = new ConcurrentHashMap<>(); codes.forEach(c -> createError(c, p, map)); return map; }
From source file:org.obiba.mica.search.queries.DatasetQuery.java
@Override public void processHits(QueryResultDto.Builder builder, Searcher.DocumentResults results, QueryScope scope, CountStatsData counts) {/*from w ww . j av a2s .c om*/ DatasetResultDto.Builder resBuilder = DatasetResultDto.newBuilder(); DatasetCountStatsBuilder datasetCountStatsBuilder = counts == null ? null : DatasetCountStatsBuilder.newBuilder(counts); Consumer<Dataset> addDto = getDatasetConsumer(scope, resBuilder, datasetCountStatsBuilder); List<Dataset> published = getPublishedDocumentsFromHitsByClassName(results, Dataset.class); published.forEach(addDto::accept); builder.setExtension(DatasetResultDto.result, resBuilder.build()); }
From source file:br.com.elotech.karina.service.impl.PushServiceBlueMix.java
@Override @Scheduled(fixedDelay = 3000)/*from www . j a va 2 s.c o m*/ public void push() { final List<License> licenses = this.licenseService.processar(); if (CollectionUtils.isEmpty(licenses)) { return; } LOGGER.debug("Preparing push to license server: {}", licenses); final List<License> result = new ArrayList<>(); licenses.forEach(l -> { result.add(this.restTemplate.postForObject(this.licenseUrl + "/licenses", l, License.class)); }); LOGGER.info("Result from POST: {}", result); }
From source file:uk.ac.kcl.iop.brc.core.pipeline.dncpipeline.data.PatientDao.java
private void setPhoneNumbers(Patient patient) { SessionWrapper sessionWrapper = getCurrentSourceSession(); try {//from w ww . j a v a 2s .c o m Query getPhoneNumbers = sessionWrapper.getNamedQuery("getPhoneNumbers"); getPhoneNumbers.setParameter("patientId", patient.getId()); List list = getPhoneNumbers.list(); List<String> phoneNumbers = new ArrayList<>(); list.forEach(object -> { String phone = clobHelper.getStringFromExpectedClob(object); if (!StringUtils.isBlank(phone)) { phoneNumbers.add(phone); } }); patient.setPhoneNumbers(phoneNumbers); } finally { sessionWrapper.closeSession(); } }
From source file:com.nike.cerberus.service.MetaDataService.java
protected void processGroupData(Map<String, String> roleIdToStringMap, SDBMetaData data, String sdbId) { List<UserGroupPermissionRecord> userPerms = userGroupDao.getUserGroupPermissions(sdbId); Map<String, String> groupRoleMap = new HashMap<>(userPerms.size() - 1); userPerms.forEach(record -> { String group = userGroupDao.getUserGroup(record.getUserGroupId()).get().getName(); String role = roleIdToStringMap.get(record.getRoleId()); if (StringUtils.equals(role, RoleRecord.ROLE_OWNER)) { data.setOwner(group);/* w w w . j av a2s. com*/ } else { groupRoleMap.put(group, role); } }); data.setUserGroupPermissions(groupRoleMap); }
From source file:io.mandrel.document.impl.ElasticsearchDocumentStore.java
@Override public void save(List<Document> data) { if (data != null) { BulkRequest bulkRequest = Requests.bulkRequest(); data.forEach(item -> { bulkRequest.add(Requests.indexRequest(index).type(type).id(item.getId()).source(data)); });/* ww w . j a v a2 s.com*/ client.bulk(bulkRequest).actionGet(); } }
From source file:com.netflix.spinnaker.fiat.roles.github.GithubTeamsUserRolesProvider.java
@Override public List<Role> loadRoles(String username) { log.debug("loadRoles for user " + username); if (StringUtils.isEmpty(username) || StringUtils.isEmpty(gitHubProperties.getOrganization())) { return new ArrayList<>(); }//from ww w . jav a2 s . c o m if (!isMemberOfOrg(username)) { log.debug(username + "is not a member of organization " + gitHubProperties.getOrganization()); return new ArrayList<>(); } log.debug(username + "is a member of organization " + gitHubProperties.getOrganization()); List<Role> result = new ArrayList<>(); result.add(toRole(gitHubProperties.getOrganization())); // Get teams of the org List<Team> teams = getTeams(); log.debug("Found " + teams.size() + " teams in org."); teams.forEach(t -> { String debugMsg = username + " is a member of team " + t.getName(); if (isMemberOfTeam(t, username)) { result.add(toRole(t.getSlug())); debugMsg += ": true"; } else { debugMsg += ": false"; } log.debug(debugMsg); }); return result; }
From source file:org.hsweb.web.controller.file.FileController.java
/** * zip.?POST//from w ww . j a va 2 s .c o m * * @param name ?? * @param dataStr ?,jsonArray. ?:[{"name":"fileName","text":"fileText"}] * @param response {@link HttpServletResponse} * @throws IOException zip * @throws RuntimeException zip */ @RequestMapping(value = "/download-zip/{name:.+}", method = { RequestMethod.POST }) @AccessLogger("zip") public void downloadZip(@PathVariable("name") String name, @RequestParam("data") String dataStr, HttpServletResponse response) throws IOException { response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(name, "utf-8")); ZIPWriter writer = Compress.zip(); List<Map<String, String>> data = (List) JSON.parseArray(dataStr, Map.class); data.forEach(map -> writer.addTextFile(map.get("name"), map.get("text"))); writer.write(response.getOutputStream()); }