List of usage examples for java.util Set forEach
default void forEach(Consumer<? super T> action)
From source file:de.appsolve.padelcampus.controller.events.EventsController.java
@RequestMapping("event/{eventId}/communitygames") public ModelAndView getEventCommunityGames(@PathVariable("eventId") Long eventId) { Event event = eventDAO.findByIdFetchWithGames(eventId); if (event == null) { throw new ResourceNotFoundException(); }/*from ww w .jav a 2s . co m*/ Map<List<Community>, Map<Game, String>> communityGameMap = new HashMap<>(); List<Game> allGames = gameDAO.findByEvent(event); allGames.forEach(game -> { Set<Participant> participants = game.getParticipants(); List<Community> communities = new ArrayList<>(); participants.forEach(participant -> { if (participant instanceof Team) { Team team = (Team) participant; if (team.getCommunity() != null) { communities.add(team.getCommunity()); } } }); if (communities.size() == 2) { Optional<List<Community>> existingCommunityList = communityGameMap.keySet().stream() .filter(communities1 -> communities1.containsAll(communities)).findFirst(); if (existingCommunityList.isPresent()) { List<Community> communityList = existingCommunityList.get(); Map<Game, String> games = communityGameMap.get(communityList); games.put(game, gameUtil.getGameResult(game, findFirstParticipant(participants, communityList), false)); communityGameMap.put(communityList, games); } else { Map<Game, String> gameMap = new HashMap<>(); gameMap.put(game, gameUtil.getGameResult(game, findFirstParticipant(participants, communities), false)); communityGameMap.put(communities, gameMap); } } }); ModelAndView mav = new ModelAndView("events/communityroundrobin/communitygames"); mav.addObject("Model", event); mav.addObject("CommunityGameMap", communityGameMap); return mav; }
From source file:org.artifactory.ui.rest.service.admin.configuration.repositories.replication.ReplicationConfigService.java
private void addMultiPushReplications(Set<LocalReplicationDescriptor> replications, LocalRepoDescriptor repo, MutableCentralConfigDescriptor configDescriptor) throws RepoConfigException { if (!addonsManager.isHaLicensed()) { throw new RepoConfigException("Multi-push replication is only available with an Enterprise license.", SC_FORBIDDEN);// w w w .ja va 2s . c om } String repoKey = repo.getKey(); validator.validateAllTargetReplicationLicenses(repo, Lists.newArrayList(replications)); log.info("Adding multi-push replication configurations for repo {}", repoKey); replications.forEach(configDescriptor::addLocalReplication); }
From source file:org.onosproject.t3.cli.TroubleshootMcastCommand.java
@Override protected void execute() { TroubleshootService service = get(TroubleshootService.class); print("Tracing all Multicast routes in the System"); //Create the generator for the list of traces. VlanId vlanId = vlan == null || vlan.isEmpty() ? VlanId.NONE : VlanId.vlanId(vlan); Generator<Set<StaticPacketTrace>> generator = service.traceMcast(vlanId); int totalTraces = 0; List<StaticPacketTrace> failedTraces = new ArrayList<>(); StaticPacketTrace previousTrace = null; while (generator.iterator().hasNext()) { totalTraces++;/*from www . ja v a 2s . c om*/ //Print also Route if possible or packet Set<StaticPacketTrace> traces = generator.iterator().next(); if (!verbosity1 && !verbosity2 && !verbosity3) { for (StaticPacketTrace trace : traces) { previousTrace = printTrace(previousTrace, trace); if (!trace.isSuccess()) { print("Failure: %s", trace.resultMessage()); failedTraces.add(trace); } else { print("Success"); } } } else { traces.forEach(trace -> { print("Tracing packet: %s", trace.getInitialPacket()); print("%s", T3CliUtils.printTrace(trace, verbosity2, verbosity3)); print("%s", StringUtils.rightPad("", 125, '-')); }); } } if (!verbosity1 && !verbosity2 && !verbosity3) { if (failedTraces.size() != 0) { print("%s", StringUtils.rightPad("", 125, '-')); print("Failed Traces: %s", failedTraces.size()); } previousTrace = null; for (StaticPacketTrace trace : failedTraces) { previousTrace = printTrace(previousTrace, trace); print("Failure: %s", trace.resultMessage()); } print("%s", StringUtils.rightPad("", 125, '-')); print("Summary"); print("Total Traces %s, errors %s", totalTraces, failedTraces.size()); print("%s", StringUtils.rightPad("", 125, '-')); } }
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.PhotoInspectorImpl.java
private void saveTags(Photo photo) { LOGGER.debug("updating tags of {}", photo); // Find the new tags. Set<String> oldTags = photo.getData().getTags().stream().map(Tag::getName).collect(Collectors.toSet()); Set<String> newTags = tagPicker.filter(oldTags); LOGGER.debug(tagPicker.getTags());/* w ww. j ava 2 s . c om*/ LOGGER.debug("old tags {} will be updated to new tags {}", oldTags, newTags); if (oldTags.equals(newTags)) { LOGGER.debug("tags have not changed of photo {}", photo); return; } // Replace tags with new ones. photo.getData().getTags().clear(); newTags.forEach(tag -> photo.getData().getTags().add(new Tag(null, tag))); savePhoto(photo); onUpdate(); }
From source file:org.onosproject.cli.net.IntentsListCommand.java
private StringBuilder formatFilteredCps(Set<FilteredConnectPoint> fCps, String prefix) { StringBuilder builder = new StringBuilder(); builder.append(prefix);//from www .ja va 2 s .c o m builder.append(FILTERED_CPS); fCps.forEach(fCp -> builder.append('\n').append(formatFilteredCp(fCp))); return builder; }
From source file:org.springframework.cloud.gcp.autoconfigure.core.cloudfoundry.GcpCloudFoundryEnvironmentPostProcessor.java
@Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { if (!StringUtils.isEmpty(environment.getProperty(VCAP_SERVICES_ENVVAR))) { Map<String, Object> vcapMap = this.parser.parseMap(environment.getProperty(VCAP_SERVICES_ENVVAR)); Properties gcpCfServiceProperties = new Properties(); Set<GcpCfService> servicesToMap = new HashSet<>(Arrays.asList(GcpCfService.values())); if (vcapMap.containsKey(GcpCfService.MYSQL.getCfServiceName()) && vcapMap.containsKey(GcpCfService.POSTGRES.getCfServiceName())) { LOGGER.warn("Both MySQL and PostgreSQL bound to the app. " + "Not configuring Cloud SQL."); servicesToMap.remove(GcpCfService.MYSQL); servicesToMap.remove(GcpCfService.POSTGRES); }// w w w . j ava2 s .c o m servicesToMap.forEach((service) -> gcpCfServiceProperties.putAll(retrieveCfProperties(vcapMap, service.getGcpServiceName(), service.getCfServiceName(), service.getCfPropNameToGcp()))); // For Cloud SQL, there are some exceptions to the rule. // The instance connection name must be built from three fields. if (gcpCfServiceProperties.containsKey("spring.cloud.gcp.sql.instance-name")) { String instanceConnectionName = gcpCfServiceProperties .getProperty("spring.cloud.gcp.sql.project-id") + ":" + gcpCfServiceProperties.getProperty("spring.cloud.gcp.sql.region") + ":" + gcpCfServiceProperties.getProperty("spring.cloud.gcp.sql.instance-name"); gcpCfServiceProperties.put("spring.cloud.gcp.sql.instance-connection-name", instanceConnectionName); } // The username and password should be in the generic DataSourceProperties. if (gcpCfServiceProperties.containsKey("spring.cloud.gcp.sql.username")) { gcpCfServiceProperties.put("spring.datasource.username", gcpCfServiceProperties.getProperty("spring.cloud.gcp.sql.username")); } if (gcpCfServiceProperties.containsKey("spring.cloud.gcp.sql.password")) { gcpCfServiceProperties.put("spring.datasource.password", gcpCfServiceProperties.getProperty("spring.cloud.gcp.sql.password")); } environment.getPropertySources() .addFirst(new PropertiesPropertySource("gcpCf", gcpCfServiceProperties)); } }
From source file:org.fenixedu.academic.thesis.ui.controller.ConfigurationController.java
@Atomic(mode = TxMode.WRITE) private void edit(ConfigurationBean configurationBean) throws OverlappingIntervalsException { ThesisProposalsConfiguration thesisProposalsConfiguration = FenixFramework .getDomainObject(configurationBean.getExternalId()); DateTimeFormatter formatter = ISODateTimeFormat.dateTime(); DateTime proposalPeriodStartDT = formatter.parseDateTime(configurationBean.getProposalPeriodStart()); DateTime proposalPeriodEndDT = formatter.parseDateTime(configurationBean.getProposalPeriodEnd()); DateTime candidacyPeriodStartDT = formatter.parseDateTime(configurationBean.getCandidacyPeriodStart()); DateTime candidacyPeriodEndDT = formatter.parseDateTime(configurationBean.getCandidacyPeriodEnd()); Interval proposalPeriod = new Interval(proposalPeriodStartDT, proposalPeriodEndDT); Interval candidacyPeriod = new Interval(candidacyPeriodStartDT, candidacyPeriodEndDT); for (ThesisProposalsConfiguration config : thesisProposalsConfiguration.getExecutionDegree() .getThesisProposalsConfigurationSet()) { if (!config.equals(thesisProposalsConfiguration) && (config.getProposalPeriod().overlaps(proposalPeriod) || config.getCandidacyPeriod().overlaps(candidacyPeriod) || config.getProposalPeriod().overlaps(candidacyPeriod) || config.getCandidacyPeriod().overlaps(proposalPeriod))) { throw new OverlappingIntervalsException(); }/*from w w w .j a va2 s.c o m*/ } Set<ThesisProposalsConfiguration> sharedConfigs = thesisProposalsConfiguration.getThesisProposalSet() .stream().flatMap(proposal -> proposal.getThesisConfigurationSet().stream()) .collect(Collectors.toSet()); sharedConfigs.add(thesisProposalsConfiguration); sharedConfigs.forEach(config -> { config.setProposalPeriod(proposalPeriod); config.setCandidacyPeriod(candidacyPeriod); config.setMaxThesisCandidaciesByStudent(configurationBean.getMaxThesisCandidaciesByStudent()); config.setMaxThesisProposalsByUser(configurationBean.getMaxThesisProposalsByUser()); config.setMinECTS1stCycle(configurationBean.getMinECTS1stCycle()); config.setMinECTS2ndCycle(configurationBean.getMinECTS2ndCycle()); }); }
From source file:org.niord.core.schedule.FiringExerciseService.java
/** * Formats the date intervals as text// www . jav a2 s .c om * @param timePart the message part to update * @param languages the languages to include */ private void formatTimeDescription(MessagePart timePart, Set<String> languages, TimeZone timeZone) { DictionaryEntry dateTimeFormat = dictionaryService.findByName("message").getEntries() .get("msg.time.date_time_format"); DictionaryEntry timeFormat = dictionaryService.findByName("message").getEntries() .get("msg.time.time_format"); languages.forEach(lang -> { String dtf = (dateTimeFormat != null && dateTimeFormat.getDesc(lang) != null) ? dateTimeFormat.getDesc(lang).getValue() : "d MMMM yyyy, 'hours' HH:mm"; String tf = (timeFormat != null && timeFormat.getDesc(lang) != null) ? timeFormat.getDesc(lang).getValue() : "HH:mm"; String txt = timePart.getEventDates().stream().map(di -> { SimpleDateFormat sdf1 = new SimpleDateFormat(dtf, new Locale(lang)); SimpleDateFormat sdf2 = TimeUtils.sameDate(di.getFromDate(), di.getToDate(), timeZone) ? new SimpleDateFormat(tf) : sdf1; sdf1.setTimeZone(timeZone); sdf2.setTimeZone(timeZone); return String.format("%s - %s", sdf1.format(di.getFromDate()), sdf2.format(di.getToDate())); }).collect(Collectors.joining(".<br>")); if (StringUtils.isNotBlank(txt)) { txt = txt + "."; timePart.checkCreateDesc(lang).setDetails(txt); } }); }
From source file:org.apereo.portal.layout.dlm.remoting.ChannelListController.java
private Map<String, SortedSet<PortletCategoryBean>> filterRegistryFavoritesOnly( Map<String, SortedSet<PortletCategoryBean>> registry) { final Set<PortletCategoryBean> inpt = registry.get(CATEGORIES_MAP_KEY); final SortedSet<PortletCategoryBean> otpt = new TreeSet<>(); inpt.forEach(categoryIn -> { final PortletCategoryBean categoryOut = filterCategoryFavoritesOnly(categoryIn); if (categoryOut != null) { otpt.add(categoryOut);/*from w ww . jav a 2 s . c o m*/ } }); final Map<String, SortedSet<PortletCategoryBean>> rslt = new TreeMap<>(); rslt.put(CATEGORIES_MAP_KEY, otpt); return rslt; }
From source file:nl.knaw.huygens.alexandria.dropwizard.cli.commands.AlexandriaCommand.java
Multimap<FileStatus, String> readWorkDirStatus(CLIContext context) throws IOException { Multimap<FileStatus, String> fileStatusMap = ArrayListMultimap.create(); Path workDir = workFilePath("."); Set<String> watchedFiles = new HashSet<>(context.getWatchedFiles().keySet()); BiPredicate<Path, BasicFileAttributes> matcher = (filePath, fileAttr) -> fileAttr.isRegularFile() && (isTagmlFile(workDir, filePath) || isViewDefinition(workDir, filePath)); Files.find(workDir, Integer.MAX_VALUE, matcher) .forEach(path -> putFileStatus(workDir, path, fileStatusMap, context, watchedFiles)); watchedFiles.forEach(f -> fileStatusMap.put(FileStatus.deleted, f)); return fileStatusMap; }