List of usage examples for java.util Set stream
default Stream<E> stream()
From source file:com.hortonworks.streamline.streams.security.service.SecurityCatalogService.java
Set<Role> getAllUserRoles(User user) { Set<Role> userRoles = user.getRoles().stream().map(this::getRole).filter(Optional::isPresent) .map(Optional::get).collect(Collectors.toSet()); Set<Role> childRoles = userRoles.stream().flatMap(role -> getChildRoles(role.getId()).stream()) .collect(Collectors.toSet()); return Sets.union(userRoles, childRoles); }
From source file:org.fenixedu.academic.thesis.ui.controller.ConfigurationController.java
@RequestMapping(value = "", method = RequestMethod.GET) public String listConfigurations(Model model) { TreeSet<ExecutionYear> executionYearsList = new TreeSet<ExecutionYear>( ExecutionYear.REVERSE_COMPARATOR_BY_YEAR); executionYearsList.addAll(Bennu.getInstance().getExecutionYearsSet()); model.addAttribute("executionYearsList", executionYearsList); Set<ThesisProposalsConfiguration> configurationsSet = ThesisProposalsSystem.getInstance() .getThesisProposalsConfigurationSet(); List<ThesisProposalsConfiguration> configurationsList = configurationsSet.stream().filter( (x) -> ThesisProposalsSystem.canManage(x.getExecutionDegree().getDegree(), Authenticate.getUser())) .collect(Collectors.toList()); Collections.sort(configurationsList, ThesisProposalsConfiguration.COMPARATOR_BY_YEAR_AND_EXECUTION_DEGREE); model.addAttribute("configurationsList", configurationsList); List<ThesisProposalParticipantType> participantTypeList = ThesisProposalsSystem.getInstance() .getThesisProposalParticipantTypeSet().stream().collect(Collectors.toList()); Collections.sort(participantTypeList, ThesisProposalParticipantType.COMPARATOR_BY_WEIGHT); model.addAttribute("participantTypeList", participantTypeList); model.addAttribute("isManager", Group.managers().isMember(Authenticate.getUser())); return "/configuration/list"; }
From source file:com.thinkbiganalytics.feedmgr.service.template.DefaultFeedManagerTemplateService.java
/** * Return a list of Processors and their properties for the incoming template * * @param nifiTemplateId a NiFi template id * @return a list of Processors and their properties for the incoming template *//*from w ww. j av a 2 s.c om*/ public List<RegisteredTemplate.Processor> getNiFiTemplateProcessorsWithProperties(String nifiTemplateId) { Set<ProcessorDTO> processorDTOs = nifiRestClient.getProcessorsForTemplate(nifiTemplateId); List<RegisteredTemplate.Processor> processorProperties = processorDTOs.stream() .map(processorDTO -> registeredTemplateUtil.toRegisteredTemplateProcessor(processorDTO, true)) .collect(Collectors.toList()); return processorProperties; }
From source file:com.thinkbiganalytics.metadata.jobrepo.nifi.provenance.NifiStatsJmsReceiver.java
private void assignNiFiBulletinErrors(List<JpaNifiFeedProcessorStats> stats) { //might need to query with the 'after' parameter //group the FeedStats by processorId_flowfileId Map<String, Map<String, List<JpaNifiFeedProcessorStats>>> processorFlowFilesStats = stats.stream() .filter(s -> s.getProcessorId() != null) .collect(Collectors.groupingBy(NifiFeedProcessorStats::getProcessorId, Collectors.groupingBy(NifiFeedProcessorStats::getLatestFlowFileId))); Set<String> processorIds = processorFlowFilesStats.keySet(); //strip out those processorIds that are part of a reusable flow Set<String> nonReusableFlowProcessorIds = processorIds.stream() .filter(processorId -> !provenanceEventFeedUtil.isReusableFlowProcessor(processorId)) .collect(Collectors.toSet()); //find all errors for the processors List<BulletinDTO> errors = nifiBulletinExceptionExtractor.getErrorBulletinsForProcessorId(processorIds, lastBulletinId);/*from w ww . j ava 2 s .c om*/ if (errors != null && !errors.isEmpty()) { Set<JpaNifiFeedProcessorStats> statsToUpdate = new HashSet<>(); // first look for matching feed flow and processor ids. otherwise look for processor id matches that are not part of reusable flows errors.stream().forEach(b -> { stats.stream().forEach(stat -> { if (stat.getLatestFlowFileId() != null && b.getSourceId().equalsIgnoreCase(stat.getProcessorId()) && b.getMessage().contains(stat.getLatestFlowFileId())) { stat.setErrorMessageTimestamp(getAdjustBulletinDateTime(b)); stat.setErrorMessages(b.getMessage()); addFeedProcessorError(stat); statsToUpdate.add(stat); } else if (nonReusableFlowProcessorIds.contains(b.getSourceId()) && b.getSourceId().equalsIgnoreCase(stat.getProcessorId())) { stat.setErrorMessageTimestamp(getAdjustBulletinDateTime(b)); stat.setErrorMessages(b.getMessage()); addFeedProcessorError(stat); statsToUpdate.add(stat); } }); }); lastBulletinId = errors.stream().mapToLong(b -> b.getId()).max().getAsLong(); if (!statsToUpdate.isEmpty()) { notifyClusterOfFeedProcessorErrors(statsToUpdate); if (persistErrors) { nifiEventStatisticsProvider.save(new ArrayList<>(statsToUpdate)); } } } }
From source file:com.thinkbiganalytics.feedmgr.nifi.CleanupStaleFeedRevisions.java
/** * Cleanup all versioned feed process groups * if the {@link #processGroupId} == 'all' then it will clean up everything, otherwise it will cleanup just the children under the {@link #processGroupId} *//*from ww w. j ava 2 s .c o m*/ public void cleanup() { deletedProcessGroups.clear(); Set<String> categoriesToCleanup = new HashSet<>(); if ("all".equalsIgnoreCase(processGroupId)) { ProcessGroupDTO root = restClient.getNiFiRestClient().processGroups().findRoot(); root.getContents().getProcessGroups().stream().forEach(categoryGroup -> { categoriesToCleanup.add(categoryGroup.getId()); }); } else { categoriesToCleanup.add(processGroupId); } categoriesToCleanup.stream().forEach(categoryProcessGroupId -> doCleanup(categoryProcessGroupId)); log.info("Successfully Cleaned up versioned ProcessGroups, deleting {} groups ", deletedProcessGroups.size()); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.SingleCellStatisticsController.java
/** * Initialize main view./*from w w w .j a va 2 s . c o m*/ */ private void initMainView() { // the view is kept in the parent controllers AnalysisPanel analysisPanel = singleCellAnalysisController.getAnalysisPanel(); analysisPanel.getConditionList().setModel(new DefaultListModel()); // customize tables analysisPanel.getStatTable().getTableHeader().setReorderingAllowed(false); analysisPanel.getStatTable().getTableHeader().setReorderingAllowed(false); analysisPanel.getComparisonTable().setFillsViewportHeight(true); analysisPanel.getComparisonTable().setFillsViewportHeight(true); // init binding groupsBindingList = ObservableCollections.observableList(new ArrayList<SingleCellAnalysisGroup>()); JListBinding jListBinding = SwingBindings.createJListBinding(AutoBinding.UpdateStrategy.READ_WRITE, groupsBindingList, analysisPanel.getAnalysisGroupList()); bindingGroup.addBinding(jListBinding); // fill in combo box List<Double> significanceLevels = new ArrayList<>(); for (SignificanceLevel significanceLevel : SignificanceLevel.values()) { significanceLevels.add(significanceLevel.getValue()); } ObservableList<Double> significanceLevelsBindingList = ObservableCollections .observableList(significanceLevels); JComboBoxBinding jComboBoxBinding = SwingBindings.createJComboBoxBinding( AutoBinding.UpdateStrategy.READ_WRITE, significanceLevelsBindingList, analysisPanel.getSignLevelComboBox()); bindingGroup.addBinding(jComboBoxBinding); bindingGroup.bind(); // add the NONE (default) correction method // when the none is selected, CellMissy does not correct for multiple hypotheses analysisPanel.getCorrectionComboBox().addItem("none"); // fill in combo box: get all the correction methods from the factory Set<String> correctionBeanNames = MultipleComparisonsCorrectionFactory.getInstance() .getCorrectionBeanNames(); correctionBeanNames.stream().forEach((correctionBeanName) -> { analysisPanel.getCorrectionComboBox().addItem(correctionBeanName); }); // do the same for the statistical tests Set<String> statisticsCalculatorBeanNames = StatisticsTestFactory.getInstance() .getStatisticsCalculatorBeanNames(); statisticsCalculatorBeanNames.stream().forEach((testName) -> { analysisPanel.getStatTestComboBox().addItem(testName); }); //significance level to 0.05 analysisPanel.getSignLevelComboBox().setSelectedIndex(1); // add parameters to perform analysis on analysisPanel.getParameterComboBox().addItem("cell speed"); analysisPanel.getParameterComboBox().addItem("cell direct"); /** * Add a group to analysis */ analysisPanel.getAddGroupButton().addActionListener((ActionEvent e) -> { // from selected conditions make a new group and add it to the list addGroupToAnalysis(); }); /** * Remove a Group from analysis */ analysisPanel.getRemoveGroupButton().addActionListener((ActionEvent e) -> { // remove the selected group from list removeGroupFromAnalysis(); }); /** * Execute a Mann Whitney Test on selected Analysis Group */ analysisPanel.getPerformStatButton().addActionListener((ActionEvent e) -> { int selectedIndex = analysisPanel.getAnalysisGroupList().getSelectedIndex(); String statisticalTestName = analysisPanel.getStatTestComboBox().getSelectedItem().toString(); String param = analysisPanel.getParameterComboBox().getSelectedItem().toString(); // check that an analysis group is being selected if (selectedIndex != -1) { SingleCellAnalysisGroup selectedGroup = groupsBindingList.get(selectedIndex); // compute statistics computeStatistics(selectedGroup, statisticalTestName, param); // show statistics in tables showSummary(selectedGroup); // set the correction combobox to the one already chosen analysisPanel.getCorrectionComboBox().setSelectedItem(selectedGroup.getCorrectionMethodName()); if (selectedGroup.getCorrectionMethodName().equals("none")) { // by default show p-values without adjustment showPValues(selectedGroup, false); } else { // show p values with adjustement showPValues(selectedGroup, true); } } else { // ask user to select a group singleCellAnalysisController.showMessage("Please select a group to perform analysis on.", "You must select a group first", JOptionPane.INFORMATION_MESSAGE); } }); /** * Refresh p value table with current selected significance of level */ analysisPanel.getSignLevelComboBox().addActionListener((ActionEvent e) -> { if (analysisPanel.getSignLevelComboBox().getSelectedIndex() != -1) { String statisticalTest = analysisPanel.getStatTestComboBox().getSelectedItem().toString(); Double selectedSignLevel = (Double) analysisPanel.getSignLevelComboBox().getSelectedItem(); SingleCellAnalysisGroup selectedGroup = groupsBindingList .get(analysisPanel.getAnalysisGroupList().getSelectedIndex()); boolean isAdjusted = !selectedGroup.getCorrectionMethodName().equals("none"); singleCellStatisticsAnalyzer.detectSignificance(selectedGroup, statisticalTest, selectedSignLevel, isAdjusted); boolean[][] significances = selectedGroup.getSignificances(); JTable pValuesTable = analysisPanel.getComparisonTable(); for (int i = 1; i < pValuesTable.getColumnCount(); i++) { pValuesTable.getColumnModel().getColumn(i) .setCellRenderer(new PValuesTableRenderer(new DecimalFormat("#.####"), significances)); } pValuesTable.repaint(); } }); /** * Apply correction for multiple comparisons: choose the algorithm! */ analysisPanel.getCorrectionComboBox().addActionListener((ActionEvent e) -> { int selectedIndex = analysisPanel.getAnalysisGroupList().getSelectedIndex(); if (selectedIndex != -1) { SingleCellAnalysisGroup selectedGroup = groupsBindingList.get(selectedIndex); String correctionMethod = analysisPanel.getCorrectionComboBox().getSelectedItem().toString(); // if the correction method is not "NONE" if (!correctionMethod.equals("none")) { // adjust p values singleCellStatisticsAnalyzer.correctForMultipleComparisons(selectedGroup, correctionMethod); // show p - values with the applied correction showPValues(selectedGroup, true); } else { // if selected correction method is "NONE", do not apply correction and only show normal p-values showPValues(selectedGroup, false); } } }); /** * Perform statistical test: choose the test!! */ analysisPanel.getPerformStatButton().addActionListener((ActionEvent e) -> { // get the selected test to be executed String selectedTest = analysisPanel.getStatTestComboBox().getSelectedItem().toString(); String param = analysisPanel.getParameterComboBox().getSelectedItem().toString(); // analysis group int selectedIndex = analysisPanel.getAnalysisGroupList().getSelectedIndex(); if (selectedIndex != -1) { SingleCellAnalysisGroup selectedGroup = groupsBindingList.get(selectedIndex); computeStatistics(selectedGroup, selectedTest, param); } }); //multiple comparison correction: set the default correction to none analysisPanel.getCorrectionComboBox().setSelectedIndex(0); analysisPanel.getStatTestComboBox().setSelectedIndex(0); analysisPanel.getParameterComboBox().setSelectedIndex(0); }
From source file:nu.yona.server.subscriptions.service.BuddyService.java
private void loadAllUsersAnonymizedAtOnce(Set<Buddy> buddyEntities) { UserAnonymized.getRepository().findAll(buddyEntities.stream().map(Buddy::getUserAnonymizedId) .filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList())); }
From source file:fi.helsinki.opintoni.integration.coursepage.CoursePageRestClient.java
@Override public List<CoursePageNotification> getCoursePageNotifications(Set<String> courseImplementationIds, LocalDateTime from, Locale locale) { if (courseImplementationIds.isEmpty()) { return newArrayList(); }//from w w w .j a v a 2 s . c o m ResponseEntity<List<CoursePageNotification>> responseEntity = restTemplate.exchange( "{baseUrl}/course_implementation_activity" + "?course_implementation_id={courseImplementationIds}×tamp={from}&langcode={locale}", HttpMethod.GET, null, new ParameterizedTypeReference<List<CoursePageNotification>>() { }, baseUrl, courseImplementationIds.stream().collect(Collectors.joining(",")), from.format(DateFormatter.COURSE_PAGE_DATE_TIME_FORMATTER), locale.getLanguage()); return Optional.ofNullable(responseEntity.getBody()).orElse(newArrayList()); }
From source file:nu.yona.server.subscriptions.service.BuddyService.java
private void loadAllBuddiesAnonymizedAtOnce(Set<Buddy> buddyEntities) { buddyAnonymizedRepository .findAll(buddyEntities.stream().map(Buddy::getBuddyAnonymizedId).collect(Collectors.toList())); }