List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:com.orange.clara.cloud.servicedbdumper.dbdumper.core.CoreDeleter.java
@Override @Transactional/* www. j ava2 s. c o m*/ public void deleteAll(DbDumperServiceInstance dbDumperServiceInstance) { List<DatabaseDumpFile> databaseDumpFileList = new ArrayList<>( dbDumperServiceInstance.getDatabaseDumpFiles()); databaseDumpFileList.forEach(this::delete); }
From source file:org.jacpfx.vertx.spring.SpringSingleVerticleConfiguration.java
@Override /**/*from w ww . ja v a2 s . com*/ * Ensure that only one spring verticle per spring context will be deployed, in case the "autoremovetherSpringVerticles" is set to true * */ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { // assume the annotation is present, otherwise hew would never call this final SpringVerticle annotation = currentSpringVerticleClass.getAnnotation(SpringVerticle.class); if (annotation.autoremoveOtherSpringVerticles()) { final String[] verticleBeanNames = beanFactory.getBeanNamesForAnnotation(SpringVerticle.class); if (verticleBeanNames.length > 1) { final List<String> beansToRemove = getBeanNamesToRemove(verticleBeanNames, beanFactory); beansToRemove.forEach(((BeanDefinitionRegistry) beanFactory)::removeBeanDefinition); } } }
From source file:com.epam.ta.reportportal.core.user.impl.DeleteUserHandler.java
@Override public OperationCompletionRS deleteUser(String userId, String principal) { User user = userRepository.findOne(userId); BusinessRule.expect(user, Predicates.notNull()).verify(ErrorType.USER_NOT_FOUND, userId); BusinessRule.expect(userId.equalsIgnoreCase(principal), Predicates.equalTo(false)) .verify(ErrorType.INCORRECT_REQUEST, "You cannot delete own account"); try {//from w w w . ja v a2 s . c o m List<Project> userProjects = projectRepository.findUserProjects(userId); userProjects .forEach(project -> ProjectUtils.excludeProjectRecipients(Lists.newArrayList(user), project)); projectRepository.removeUserFromProjects(userId); projectRepository.save(userProjects); } catch (Exception exp) { throw new ReportPortalException("Error while updating projects", exp); } try { uatClient.revokeUserTokens(userId); userRepository.delete(user); } catch (Exception exp) { throw new ReportPortalException("Error while deleting user", exp); } return new OperationCompletionRS("User with ID = '" + userId + "' successfully deleted."); }
From source file:org.sahli.asciidoc.confluence.publisher.maven.plugin.AsciidocConfluencePublisherMojo.java
private void copyTemplatesToTarget(List<Resource> resources) { resources.forEach(templateResource -> { try {/* ww w .jav a2 s .c o m*/ copyInputStreamToFile(templateResource.getInputStream(), new File(this.asciidocConfluenceTemplates, templateResource.getFilename())); } catch (IOException e) { throw new RuntimeException("Could not write template to target file", e); } }); }
From source file:se.uu.it.cs.recsys.dataloader.impl.PreviousYearsCourseLoader.java
private void loadCoursesToDB(List<Course> targets) { targets.forEach(target -> { se.uu.it.cs.recsys.persistence.entity.Course entry = new se.uu.it.cs.recsys.persistence.entity.Course(); entry.setCode(target.getCode()); entry.setName(target.getName()); entry.setTaughtYear(target.getTaughtYear().shortValue()); entry.setStartPeriod(target.getStartPeriod().shortValue()); entry.setEndPeriod(target.getEndPeriod().shortValue()); entry.setCredit(this.supportedCourseCreditRepository.findByCredit(target.getCredit())); entry.setLevel(this.supportedCourseLevelRepository.findByLevel(target.getLevel().toString())); se.uu.it.cs.recsys.persistence.entity.Course savedEntry = this.courseRepository.save(entry); if (savedEntry == null) { LOGGER.error("Failed to save course: {}", entry); }/*from w ww . j av a 2 s . co m*/ }); }
From source file:com.greglturnquist.spring.social.ecobee.EcobeeThermostatsController.java
@RequestMapping(value = "/ecobee", method = RequestMethod.GET) public String home(Principal currentUser, Model model) throws Exception { Connection<Ecobee> connection = connectionRepository.findPrimaryConnection(Ecobee.class); if (connection == null) { return "redirect:/connect/ecobee"; }// w w w . j a v a2s . c o m if (connection.hasExpired()) { log.info("Token has expired. Time to refresh"); connection.refresh(); } model.addAttribute("authentication", SecurityContextHolder.getContext().getAuthentication()); final List<Thermostat> allThermostats = connection.getApi().thermostatOperations().getAllThermostats(); allThermostats.forEach( t -> t.getRemoteSensors().forEach(s -> s.getCapability().forEach(c -> log.info(c.toString())))); model.addAttribute("thermostats", allThermostats); return "ecobee/thermostats"; }
From source file:org.ng200.openolympus.services.UserService.java
@PreAuthorize(SecurityExpressionConstants.IS_ADMIN) public void deleteUsers(List<User> users) { // TODO: use SQL users.forEach(this::deleteUser); }
From source file:com.watchrabbit.crawler.manager.service.ManagerServiceImpl.java
@Override public void orderExecution(List<String> ids) { ids.forEach(this::orderExecution); }
From source file:io.gravitee.repository.redis.management.internal.impl.ApiRedisRepositoryImpl.java
@Override public Set<RedisApi> findByGroups(List<String> groups) { Set<Object> keys = new HashSet<>(); groups.forEach(group -> keys.addAll(redisTemplate.opsForSet().members(REDIS_KEY + ":group:" + group))); List<Object> apiObjects = redisTemplate.opsForHash().multiGet(REDIS_KEY, keys); return apiObjects.stream().filter(Objects::nonNull).map(event -> convert(event, RedisApi.class)) .collect(Collectors.toSet()); }
From source file:hydrograph.ui.validators.impl.DatabaseKeyValidation.java
@Override public boolean validate(Object object, String propertyName, Map<String, List<FixedWidthGridRow>> inputSchemaMap, boolean isJobFileImported) { if (object != null) { List<String> tmpList = new LinkedList<>(); Map<String, Object> keyFieldsList = (LinkedHashMap<String, Object>) object; if (keyFieldsList != null && !keyFieldsList.isEmpty() && keyFieldsList.containsKey(Constants.LOAD_TYPE_NEW_TABLE_KEY)) { if (inputSchemaMap != null) { for (java.util.Map.Entry<String, List<FixedWidthGridRow>> entry : inputSchemaMap.entrySet()) { List<FixedWidthGridRow> gridRowList = entry.getValue(); gridRowList.forEach(gridRow -> tmpList.add(gridRow.getFieldName())); }//from w w w.j a va2 s .c o m } for (Entry<String, Object> grid : keyFieldsList.entrySet()) { String[] keyValues = StringUtils.split((String) grid.getValue(), ","); for (String values : keyValues) { if (!tmpList.contains(values)) { errorMessage = "Target Fields Should be present in Available Fields"; return false; } } } return true; } else if (keyFieldsList != null && !keyFieldsList.isEmpty() && keyFieldsList.containsKey(Constants.LOAD_TYPE_INSERT_KEY)) { return true; } else if (keyFieldsList != null && !keyFieldsList.isEmpty() && keyFieldsList.containsKey(Constants.LOAD_TYPE_REPLACE_KEY)) { return true; } } return true; }