List of usage examples for java.util HashSet addAll
boolean addAll(Collection<? extends E> c);
From source file:org.gradoop.flink.model.impl.operators.matching.single.cypher.planning.planner.greedy.GreedyPlanner.java
/** * Joins the query plans represented by the specified plan table entries. * * The method considers if the right entry is a variable length path and in that case * creates an {@link ExpandEmbeddingsNode}. In any other case, a regular * {@link JoinEmbeddingsNode} is used to join the query plans. * * @param leftEntry left entry//from w w w . ja v a 2 s . co m * @param rightEntry right entry * @param joinVariables join variables * @return an entry that represents the join of both input entries */ private PlanTableEntry joinEntries(PlanTableEntry leftEntry, PlanTableEntry rightEntry, List<String> joinVariables) { PlanNode node; if (rightEntry.getType() == PATH) { assert joinVariables.size() == 1; node = createExpandNode(leftEntry, rightEntry, joinVariables.get(0)); } else { node = new JoinEmbeddingsNode(leftEntry.getQueryPlan().getRoot(), rightEntry.getQueryPlan().getRoot(), joinVariables, vertexStrategy, edgeStrategy); } // update processed variables HashSet<String> processedVariables = Sets.newHashSet(leftEntry.getProcessedVariables()); processedVariables.addAll(rightEntry.getProcessedVariables()); // create resulting predicates // TODO: this might be moved to the join/expand node in issue #510 CNF predicates = mergePredicates(leftEntry, rightEntry); return new PlanTableEntry(GRAPH, processedVariables, predicates, new QueryPlanEstimator(new QueryPlan(node), queryHandler, graphStatistics)); }
From source file:org.cgiar.ccafs.marlo.action.projects.DeliverableListAction.java
public List<Deliverable> getDeliverables(boolean open, boolean closed) { try {/*from w ww . java2s. com*/ if (open) { if (this.isPlanningActive()) { List<Deliverable> openA = deliverables.stream() .filter(a -> a.isActive() && a.getDeliverableInfo(this.getActualPhase()) != null && ((a.getDeliverableInfo(this.getActualPhase()).getStatus() == null || a.getDeliverableInfo(this.getActualPhase()).getStatus() == Integer .parseInt(ProjectStatusEnum.Ongoing.getStatusId()) || (a.getDeliverableInfo(this.getActualPhase()).getStatus() == Integer .parseInt(ProjectStatusEnum.Extended.getStatusId()) || a.getDeliverableInfo(this.getActualPhase()).getStatus() .intValue() == 0 || a.getDeliverableInfo(this.getActualPhase()).getStatus() .intValue() == -1)))) .collect(Collectors.toList()); return openA; } else { List<Deliverable> openA = deliverables.stream() .filter(a -> a.isActive() && a.getDeliverableInfo(this.getActualPhase()) != null && ((a.getDeliverableInfo(this.getActualPhase()).getStatus() == null || a.getDeliverableInfo(this.getActualPhase()).getStatus() == Integer .parseInt(ProjectStatusEnum.Ongoing.getStatusId()) || (a.getDeliverableInfo(this.getActualPhase()).getStatus() == Integer .parseInt(ProjectStatusEnum.Extended.getStatusId()) || a.getDeliverableInfo(this.getActualPhase()).getStatus() .intValue() == 0)))) .collect(Collectors.toList()); openA.addAll(deliverables.stream().filter(d -> d.isActive() && d.getDeliverableInfo(this.getActualPhase()) != null && d.getDeliverableInfo(this.getActualPhase()).getYear() == this.getCurrentCycleYear() && d.getDeliverableInfo(this.getActualPhase()).getStatus() != null && d.getDeliverableInfo(this.getActualPhase()).getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Complete.getStatusId())) .collect(Collectors.toList())); openA.addAll(deliverables.stream() .filter(d -> d.isActive() && d.getDeliverableInfo(this.getActualPhase()) != null && d.getDeliverableInfo(this.getActualPhase()).getNewExpectedYear() != null && d.getDeliverableInfo(this.getActualPhase()).getNewExpectedYear() .intValue() == this.getCurrentCycleYear() && d.getDeliverableInfo(this.getActualPhase()).getStatus() != null && d.getDeliverableInfo(this.getActualPhase()).getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Complete.getStatusId())) .collect(Collectors.toList())); openA.sort((p1, p2) -> p1.getDeliverableInfo(this.getActualPhase()) .isRequieriedReporting(this.getCurrentCycleYear()) .compareTo(p2.getDeliverableInfo(this.getActualPhase()) .isRequieriedReporting(this.getCurrentCycleYear()))); HashSet<Deliverable> deliverables = new HashSet<>(); deliverables.addAll(openA); openA.clear(); openA.addAll(deliverables); return openA; } } else { if (this.isPlanningActive()) { List<Deliverable> openA = new ArrayList<>(); if (closed) { openA = deliverables.stream().filter(a -> a.isActive() && a.getDeliverableInfo(this.getActualPhase()) != null && ((a.getDeliverableInfo(this.getActualPhase()).getStatus() != null && ((a.getDeliverableInfo(this.getActualPhase()).getStatus() == Integer .parseInt(ProjectStatusEnum.Cancelled.getStatusId())))))) .collect(Collectors.toList()); } else { openA = deliverables.stream().filter(a -> a.isActive() && a.getDeliverableInfo(this.getActualPhase()) != null && ((a.getDeliverableInfo(this.getActualPhase()).getStatus() != null && ((a.getDeliverableInfo(this.getActualPhase()).getStatus() == Integer .parseInt(ProjectStatusEnum.Complete.getStatusId())))))) .collect(Collectors.toList()); } return openA; } else { List<Deliverable> openA = new ArrayList<>(); if (closed) { openA = deliverables.stream().filter(a -> a.isActive() && a.getDeliverableInfo(this.getActualPhase()) != null && ((a.getDeliverableInfo(this.getActualPhase()).getStatus() != null && ((a.getDeliverableInfo(this.getActualPhase()).getStatus() == Integer .parseInt(ProjectStatusEnum.Cancelled.getStatusId())))))) .collect(Collectors.toList()); } else { openA = deliverables.stream().filter(a -> a.isActive() && a.getDeliverableInfo(this.getActualPhase()) != null && ((a.getDeliverableInfo(this.getActualPhase()).getStatus() != null && ((a.getDeliverableInfo(this.getActualPhase()).getStatus() == Integer .parseInt(ProjectStatusEnum.Complete.getStatusId())))))) .collect(Collectors.toList()); } openA.removeAll(deliverables.stream().filter(d -> d.isActive() && d.getDeliverableInfo(this.getActualPhase()) != null && d.getDeliverableInfo(this.getActualPhase()).getYear() == this.getCurrentCycleYear() && d.getDeliverableInfo(this.getActualPhase()).getStatus() != null && d.getDeliverableInfo(this.getActualPhase()).getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Complete.getStatusId())) .collect(Collectors.toList())); openA.removeAll(deliverables.stream() .filter(d -> d.isActive() && d.getDeliverableInfo(this.getActualPhase()) != null && d.getDeliverableInfo(this.getActualPhase()).getNewExpectedYear() != null && d.getDeliverableInfo(this.getActualPhase()).getNewExpectedYear() .intValue() == this.getCurrentCycleYear() && d.getDeliverableInfo(this.getActualPhase()).getStatus() != null && d.getDeliverableInfo(this.getActualPhase()).getStatus().intValue() == Integer .parseInt(ProjectStatusEnum.Complete.getStatusId())) .collect(Collectors.toList())); openA.sort((p1, p2) -> p1.getDeliverableInfo(this.getActualPhase()) .isRequieriedReporting(this.getCurrentCycleYear()) .compareTo(p2.getDeliverableInfo(this.getActualPhase()) .isRequieriedReporting(this.getCurrentCycleYear()))); HashSet<Deliverable> deliverables = new HashSet<>(); deliverables.addAll(openA); openA.clear(); openA.addAll(deliverables); return openA; } } } catch (Exception e) { e.printStackTrace(); return new ArrayList<>(); } }
From source file:org.dragoneronca.nlp.wol.disambiguation.SenseSolver.java
private boolean disambiguateSenseTerm(LightSense sense, int wordHash, Collection<LightSemanticEdge> edges) { Set<LightSense> targetSenses = mapEdgesToSenses(edges); // find cycles HashSet<Path> cycles = new HashSet<>(); for (LightSense targetSense : targetSenses) { if (!targetSense.equals(sense)) { HashSet<LightSense> sinks = Sets.newHashSet(sense); PathFinder cycleFinder = new WolPathFinder(targetSense, sinks, MAX_DEPTH, new HashSet<Integer>()); cycleFinder.run();//from www. j a v a 2 s .c o m cycles.addAll(cycleFinder.getResult()); } } // find quasi-cycles HashSet<Node> sinks = new HashSet<>(); for (LightSense targetSense : targetSenses) { if (!targetSense.equals(sense)) { sinks.add(targetSense); } } PathFinder quasiCycleFinder = new WolPathFinder(sense, sinks, MAX_DEPTH, Sets.newHashSet(wordHash)); quasiCycleFinder.run(); Set<Path> quasiCycles = quasiCycleFinder.getResult(); return updateProbabilities(edges, cycles, quasiCycles); }
From source file:com.android.talkback.formatter.TouchExplorationFormatter.java
/** * Resets cached scrollable state when touch exploration after window state * changes./* w w w . ja v a 2s . c om*/ */ @Override public void onAccessibilityEvent(AccessibilityEvent event) { switch (event.getEventType()) { case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: // Reset cached scrollable state. mLastNodeWasScrollable = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Store window title in the map. List<CharSequence> titles = event.getText(); if (titles.size() > 0) { AccessibilityNodeInfo node = event.getSource(); if (node != null) { int windowType = getWindowType(node); if (windowType == AccessibilityWindowInfo.TYPE_APPLICATION || windowType == AccessibilityWindowInfo.TYPE_SYSTEM) { mWindowTitlesMap.put(node.getWindowId(), titles.get(0)); } node.recycle(); } } } break; case AccessibilityEvent.TYPE_WINDOWS_CHANGED: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Copy key set not to modify original map. HashSet<Integer> windowIdsToBeRemoved = new HashSet<Integer>(); windowIdsToBeRemoved.addAll(mWindowTitlesMap.keySet()); // Enumerate window ids to be removed. List<AccessibilityWindowInfo> windows = mService.getWindows(); for (AccessibilityWindowInfo window : windows) { windowIdsToBeRemoved.remove(window.getId()); } // Delete titles of non-existing window ids. for (Integer windowId : windowIdsToBeRemoved) { mWindowTitlesMap.remove(windowId); } } break; } }
From source file:org.cgiar.ccafs.marlo.action.center.summaries.OutcomesContributionsSummaryAction.java
private TypedTableModel getOutcomesDetailsTableModel() { TypedTableModel model = new TypedTableModel( new String[] { "researchTopicTitle", "researchOutcomeID", "researchOutcomeURL", "researchOutcomeTitle", "researchImpactTitle", "projectOutputs", "projectDeliverables" }, new Class[] { String.class, Long.class, String.class, String.class, String.class, String.class, String.class }); for (CenterTopic researchTopic : researchProgram.getResearchTopics().stream().filter(rt -> rt.isActive()) .collect(Collectors.toList())) { for (CenterOutcome researchOutcome : researchTopic.getResearchOutcomes().stream() .filter(ro -> ro.isActive()).collect(Collectors.toList())) { String researchTopicTitle = null; if (researchTopic.getResearchTopic() != null && !researchTopic.getResearchTopic().trim().isEmpty()) { researchTopicTitle = researchTopic.getResearchTopic(); }// w w w . j a v a 2s . c om Long researchOutcomeID = null; String researchOutcomeURL = null; if (researchOutcome.getId() != null) { researchOutcomeID = researchOutcome.getId(); // TODO: set outcome URL /impactPathway/CIAT/outcomes.do?outcomeID=9&edit=true researchOutcomeURL = config.getBaseUrl() + "/monitoring/CIAT/monitoringOutcome.do?outcomeID=" + researchOutcomeID; } String researchOutcomeTitle = null; researchOutcomeTitle = (researchOutcome.getDescription() != null ? researchOutcome.getDescription() : "title not defined") + (researchOutcome.getShortName() != null && !researchOutcome.getShortName().trim().isEmpty() ? " (" + researchOutcome.getShortName() + ")" : ""); String researchImpactTitle = null; if (researchOutcome.getResearchImpact() != null && researchOutcome.getResearchImpact().getDescription() != null && !researchOutcome.getResearchImpact().getDescription().trim().isEmpty()) { researchImpactTitle = researchOutcome.getResearchImpact().getDescription(); } List<CenterProject> projects = new ArrayList<>(); // CenterProject Outputs String projectOutputs = ""; List<CenterOutput> outputs = new ArrayList<>(); List<CenterOutputsOutcome> centerOutputsOutcomes = new ArrayList<>( researchOutcome.getCenterOutputsOutcomes().stream().filter(ro -> ro.isActive()) .collect(Collectors.toList())); for (CenterOutputsOutcome centerOutputsOutcome : centerOutputsOutcomes) { outputs.add(centerOutputsOutcome.getCenterOutput()); } for (CenterOutput researchOutput : outputs) { for (CenterProjectOutput projectOutput : researchOutput.getProjectOutputs().stream() .filter(po -> po.isActive()).collect(Collectors.toList())) { if (projectOutputs.isEmpty()) { projectOutputs = "P" + projectOutput.getProject().getId() + " - " + projectOutput.getResearchOutput().getComposedName(); } else { projectOutputs += "\nP" + projectOutput.getProject().getId() + " - " + projectOutput.getResearchOutput().getComposedName(); } projects.add(projectOutput.getProject()); } } if (projectOutputs.trim().isEmpty()) { projectOutputs = null; } // CenterProject Deliverables HashSet<CenterProject> hashProjects = new HashSet<>(); hashProjects.addAll(projects); projects = new ArrayList<>(hashProjects); String projectDeliverables = ""; for (CenterProject project : projects) { for (CenterDeliverable deliverable : project.getDeliverables().stream() .filter(d -> d.isActive()).collect(Collectors.toList())) { if (projectDeliverables.isEmpty()) { projectDeliverables = "P" + project.getId() + " - " + "D" + deliverable.getId() + ": " + (deliverable.getName() != null && !deliverable.getName().trim().isEmpty() ? deliverable.getName() : ""); } else { projectDeliverables += "\nP" + project.getId() + " - " + "D" + deliverable.getId() + ": " + (deliverable.getName() != null && !deliverable.getName().trim().isEmpty() ? deliverable.getName() : ""); } } } if (projectDeliverables.trim().isEmpty()) { projectDeliverables = null; } model.addRow(new Object[] { researchTopicTitle, researchOutcomeID, researchOutcomeURL, researchOutcomeTitle, researchImpactTitle, projectOutputs, projectDeliverables }); // Increment outcomes Projects count if (allOutcomesProjects.containsKey(researchOutcome)) { allOutcomesProjects.put(researchOutcome, allOutcomesProjects.get(researchOutcome) + projects.size()); } else { if (projects.size() > 0) { allOutcomesProjects.put(researchOutcome, projects.size()); } } } } return model; }
From source file:org.fenixedu.academic.ui.renderers.student.enrollment.bolonha.ErasmusBolonhaStudentEnrolmentLayout.java
@Override public HtmlComponent createComponent(Object object, Class type) { setBolonhaStudentEnrollmentBean((BolonhaStudentEnrollmentBean) object); if (getBolonhaStudentEnrollmentBean() == null) { return new HtmlText(); }//from w w w.j a v a 2s. co m final HtmlBlockContainer container = new HtmlBlockContainer(); HtmlMultipleHiddenField hiddenEnrollments = new HtmlMultipleHiddenField(); hiddenEnrollments.bind(getRenderer().getInputContext().getMetaObject(), "curriculumModulesToRemove"); hiddenEnrollments.setConverter(new DomainObjectKeyArrayConverter()); hiddenEnrollments.setController(getEnrollmentsController()); HtmlMultipleHiddenField hiddenDegreeModulesToEvaluate = new HtmlMultipleHiddenField(); hiddenDegreeModulesToEvaluate.bind(getRenderer().getInputContext().getMetaObject(), "degreeModulesToEvaluate"); hiddenDegreeModulesToEvaluate .setConverter(getBolonhaStudentEnrollmentBean().getDegreeModulesToEvaluateConverter()); hiddenDegreeModulesToEvaluate.setController(getDegreeModulesToEvaluateController()); HtmlMultipleHiddenField hiddenExtraCurricularEnrollments = new HtmlMultipleHiddenField(); hiddenExtraCurricularEnrollments.bind(getRenderer().getInputContext().getMetaObject(), "extraCurricularEnrolments"); hiddenExtraCurricularEnrollments.setConverter(new ErasmusExtraCurricularEnrolmentConverter()); hiddenExtraCurricularEnrollments.setController(controller); container.addChild(hiddenEnrollments); container.addChild(hiddenDegreeModulesToEvaluate); container.addChild(hiddenExtraCurricularEnrollments); generateGroup(container, getBolonhaStudentEnrollmentBean().getStudentCurricularPlan(), getBolonhaStudentEnrollmentBean().getRootStudentCurriculumGroupBean(), getBolonhaStudentEnrollmentBean().getExecutionPeriod(), 0); HtmlTable groupTable = createGroupTable(container, 0); HtmlTableRow htmlTableRow = groupTable.createRow(); htmlTableRow.setClasses(getRenderer().getGroupRowClasses()); htmlTableRow.createCell().setBody(new HtmlText("Other Curricular Units", false)); HtmlTableCell cell = htmlTableRow.createCell(); cell.setClasses("aright"); HtmlCheckBox checkBox = new HtmlCheckBox(false); final String name = "degreeModuleToEnrolCheckBox"; checkBox.setName(name); checkBox.setUserValue("true"); checkBox.setChecked(true); cell.setBody(checkBox); groupTable = createCoursesTable(container, 0); NoCourseGroupCurriculumGroup group = getBolonhaStudentEnrollmentBean().getStudentCurricularPlan() .getNoCourseGroupCurriculumGroup(NoCourseGroupCurriculumGroupType.STANDALONE); HashSet<CurricularCourse> set = new HashSet<CurricularCourse>(); ErasmusBolonhaStudentEnrollmentBean erasmusBolonhaStudentEnrollmentBean = (ErasmusBolonhaStudentEnrollmentBean) getBolonhaStudentEnrollmentBean(); set.addAll(erasmusBolonhaStudentEnrollmentBean.getCandidacy().getCurricularCoursesSet()); for (Enrolment enrolment : group.getEnrolments()) { set.add(enrolment.getCurricularCourse()); } for (CurricularCourse curricularCourse : set) { if (erasmusBolonhaStudentEnrollmentBean.getStudentCurricularPlan() .getEnrolmentByCurricularCourseAndExecutionPeriod(curricularCourse, erasmusBolonhaStudentEnrollmentBean.getExecutionPeriod()) != null) { if (!group.hasEnrolmentWithEnroledState(curricularCourse, erasmusBolonhaStudentEnrollmentBean.getExecutionPeriod())) { continue; } } if (!isContextValid(curricularCourse)) { continue; } htmlTableRow = groupTable.createRow(); HtmlTableCell cellName = htmlTableRow.createCell(); cellName.setClasses(getRenderer().getCurricularCourseToEnrolNameClasses()); String degreeName = curricularCourse.getName(); if (isAcademicRelationsOfficeMember() && curricularCourse instanceof CurricularCourse) { if (!StringUtils.isEmpty(curricularCourse.getCode())) { degreeName = curricularCourse.getCode() + " - " + degreeName; } degreeName += " (" + BundleUtil.getString(Bundle.STUDENT, "label.grade.scale") + " - " + curricularCourse.getGradeScaleChain().getDescription() + ") "; } cellName.setBody(new HtmlText(degreeName)); // Year final HtmlTableCell yearCell = htmlTableRow.createCell(); yearCell.setClasses(getRenderer().getCurricularCourseToEnrolYearClasses()); yearCell.setColspan(2); yearCell.setBody( new HtmlText(getBolonhaStudentEnrollmentBean().getExecutionPeriod().getQualifiedName())); final HtmlTableCell ectsCell = htmlTableRow.createCell(); ectsCell.setClasses(getRenderer().getCurricularCourseToEnrolEctsClasses()); final StringBuilder ects = new StringBuilder(); ects.append(curricularCourse.getEctsCredits()).append(" ") .append(BundleUtil.getString(Bundle.STUDENT, "label.credits.abbreviation")); ectsCell.setBody(new HtmlText(ects.toString())); HtmlTableCell checkBoxCell = htmlTableRow.createCell(); checkBoxCell.setClasses(getRenderer().getCurricularCourseToEnrolCheckBoxClasses()); checkBox = new HtmlCheckBox(false); checkBox.setName("extraCurricularEnrolments" + curricularCourse.getClass().getCanonicalName() + ":" + curricularCourse.getExternalId()); checkBox.setUserValue( curricularCourse.getClass().getCanonicalName() + ":" + curricularCourse.getExternalId()); checkBoxCell.setBody(checkBox); controller.addCheckBox(checkBox); if (group.hasEnrolmentWithEnroledState(curricularCourse, erasmusBolonhaStudentEnrollmentBean.getExecutionPeriod())) { cellName.setClasses(getRenderer().getEnrolmentNameClasses()); yearCell.setClasses(getRenderer().getEnrolmentYearClasses()); ectsCell.setClasses(getRenderer().getEnrolmentEctsClasses()); checkBoxCell.setClasses(getRenderer().getEnrolmentCheckBoxClasses()); checkBox.setChecked(true); } } return container; }
From source file:net.sourceforge.fenixedu.presentationTier.renderers.student.enrollment.bolonha.ErasmusBolonhaStudentEnrolmentLayout.java
@Override public HtmlComponent createComponent(Object object, Class type) { setBolonhaStudentEnrollmentBean((BolonhaStudentEnrollmentBean) object); if (getBolonhaStudentEnrollmentBean() == null) { return new HtmlText(); }//from w w w . j av a 2 s.c om final HtmlBlockContainer container = new HtmlBlockContainer(); HtmlMultipleHiddenField hiddenEnrollments = new HtmlMultipleHiddenField(); hiddenEnrollments.bind(getRenderer().getInputContext().getMetaObject(), "curriculumModulesToRemove"); hiddenEnrollments.setConverter(new DomainObjectKeyArrayConverter()); hiddenEnrollments.setController(getEnrollmentsController()); HtmlMultipleHiddenField hiddenDegreeModulesToEvaluate = new HtmlMultipleHiddenField(); hiddenDegreeModulesToEvaluate.bind(getRenderer().getInputContext().getMetaObject(), "degreeModulesToEvaluate"); hiddenDegreeModulesToEvaluate .setConverter(getBolonhaStudentEnrollmentBean().getDegreeModulesToEvaluateConverter()); hiddenDegreeModulesToEvaluate.setController(getDegreeModulesToEvaluateController()); HtmlMultipleHiddenField hiddenExtraCurricularEnrollments = new HtmlMultipleHiddenField(); hiddenExtraCurricularEnrollments.bind(getRenderer().getInputContext().getMetaObject(), "extraCurricularEnrolments"); hiddenExtraCurricularEnrollments.setConverter(new ErasmusExtraCurricularEnrolmentConverter()); hiddenExtraCurricularEnrollments.setController(controller); container.addChild(hiddenEnrollments); container.addChild(hiddenDegreeModulesToEvaluate); container.addChild(hiddenExtraCurricularEnrollments); generateGroup(container, getBolonhaStudentEnrollmentBean().getStudentCurricularPlan(), getBolonhaStudentEnrollmentBean().getRootStudentCurriculumGroupBean(), getBolonhaStudentEnrollmentBean().getExecutionPeriod(), 0); HtmlTable groupTable = createGroupTable(container, 0); HtmlTableRow htmlTableRow = groupTable.createRow(); htmlTableRow.setClasses(getRenderer().getGroupRowClasses()); htmlTableRow.createCell().setBody(new HtmlText("Other Curricular Units", false)); HtmlTableCell cell = htmlTableRow.createCell(); cell.setClasses("aright"); HtmlCheckBox checkBox = new HtmlCheckBox(false); final String name = "degreeModuleToEnrolCheckBox"; checkBox.setName(name); checkBox.setUserValue("true"); checkBox.setChecked(true); cell.setBody(checkBox); groupTable = createCoursesTable(container, 0); NoCourseGroupCurriculumGroup group = getBolonhaStudentEnrollmentBean().getStudentCurricularPlan() .getNoCourseGroupCurriculumGroup(NoCourseGroupCurriculumGroupType.STANDALONE); HashSet<CurricularCourse> set = new HashSet<CurricularCourse>(); ErasmusBolonhaStudentEnrollmentBean erasmusBolonhaStudentEnrollmentBean = (ErasmusBolonhaStudentEnrollmentBean) getBolonhaStudentEnrollmentBean(); set.addAll(erasmusBolonhaStudentEnrollmentBean.getCandidacy().getCurricularCoursesSet()); for (Enrolment enrolment : group.getEnrolments()) { set.add(enrolment.getCurricularCourse()); } for (CurricularCourse curricularCourse : set) { if (erasmusBolonhaStudentEnrollmentBean.getStudentCurricularPlan() .getEnrolmentByCurricularCourseAndExecutionPeriod(curricularCourse, erasmusBolonhaStudentEnrollmentBean.getExecutionPeriod()) != null) { if (!group.hasEnrolmentWithEnroledState(curricularCourse, erasmusBolonhaStudentEnrollmentBean.getExecutionPeriod())) { continue; } } if (!isContextValid(curricularCourse)) { continue; } htmlTableRow = groupTable.createRow(); HtmlTableCell cellName = htmlTableRow.createCell(); cellName.setClasses(getRenderer().getCurricularCourseToEnrolNameClasses()); String degreeName = curricularCourse.getName(); if (isAcademicAdminOfficeEmployee() && curricularCourse instanceof CurricularCourse) { if (!StringUtils.isEmpty(curricularCourse.getCode())) { degreeName = curricularCourse.getCode() + " - " + degreeName; } degreeName += " (" + BundleUtil.getString(Bundle.STUDENT, "label.grade.scale") + " - " + curricularCourse.getGradeScaleChain().getDescription() + ") "; } cellName.setBody(new HtmlText(degreeName)); // Year final HtmlTableCell yearCell = htmlTableRow.createCell(); yearCell.setClasses(getRenderer().getCurricularCourseToEnrolYearClasses()); yearCell.setColspan(2); yearCell.setBody( new HtmlText(getBolonhaStudentEnrollmentBean().getExecutionPeriod().getQualifiedName())); final HtmlTableCell ectsCell = htmlTableRow.createCell(); ectsCell.setClasses(getRenderer().getCurricularCourseToEnrolEctsClasses()); final StringBuilder ects = new StringBuilder(); ects.append(curricularCourse.getEctsCredits()).append(" ") .append(BundleUtil.getString(Bundle.STUDENT, "label.credits.abbreviation")); ectsCell.setBody(new HtmlText(ects.toString())); HtmlTableCell checkBoxCell = htmlTableRow.createCell(); checkBoxCell.setClasses(getRenderer().getCurricularCourseToEnrolCheckBoxClasses()); checkBox = new HtmlCheckBox(false); checkBox.setName("extraCurricularEnrolments" + curricularCourse.getClass().getCanonicalName() + ":" + curricularCourse.getExternalId()); checkBox.setUserValue( curricularCourse.getClass().getCanonicalName() + ":" + curricularCourse.getExternalId()); checkBoxCell.setBody(checkBox); controller.addCheckBox(checkBox); if (group.hasEnrolmentWithEnroledState(curricularCourse, erasmusBolonhaStudentEnrollmentBean.getExecutionPeriod())) { cellName.setClasses(getRenderer().getEnrolmentNameClasses()); yearCell.setClasses(getRenderer().getEnrolmentYearClasses()); ectsCell.setClasses(getRenderer().getEnrolmentEctsClasses()); checkBoxCell.setClasses(getRenderer().getEnrolmentCheckBoxClasses()); checkBox.setChecked(true); } } return container; }
From source file:nl.systemsgenetics.genenetworkbackend.hpo.DiseaseGeneHpoData.java
public DiseaseGeneHpoData(HashMap<DiseaseGene, HashSet<String>> diseaseGeneToHpos) { this.diseaseGeneToHpos = diseaseGeneToHpos; geneToHpos = new HashMap<>(); diseaseToGenes = new HashMap<>(); for (Map.Entry<DiseaseGene, HashSet<String>> diseaseGeneToHposEntry : diseaseGeneToHpos.entrySet()) { DiseaseGene diseaseGene = diseaseGeneToHposEntry.getKey(); HashSet<String> hpos = diseaseGeneToHposEntry.getValue(); HashSet<String> geneHpos = geneToHpos.get(diseaseGene.getGene()); if (geneHpos == null) { geneHpos = new HashSet<>(); geneToHpos.put(diseaseGene.getGene(), geneHpos); }//from ww w. ja v a 2 s.c o m geneHpos.addAll(hpos); HashSet<String> diseaseGenes = diseaseToGenes.get(diseaseGene.getDisease()); if (diseaseGenes == null) { diseaseGenes = new HashSet<>(); diseaseToGenes.put(diseaseGene.getDisease(), diseaseGenes); } diseaseGenes.add(diseaseGene.getGene()); } }
From source file:com.fredhopper.connector.index.provider.FhCategorySource.java
protected Set<CategoryModel> collectSuperCategories(final CategoryModel category, final Set<CategoryModel> rootCategories, final Set<CategoryModel> path) { if (category == null || isBlockedCategory(category)) { // If this category is blocked or null then return empty set as this whole branch is not viable return Collections.emptySet(); }/*from w w w . java2 s. c o m*/ if (path.contains(category)) { // Loop detected, category has already been seen. this whole branch is not viable return Collections.emptySet(); } // This category is ok, so add it to our path path.add(category); if (rootCategories.contains(category)) { // We have found the root, so that is the end of this path return path; } else { final List<CategoryModel> superCategories = category.getSupercategories(); if (superCategories == null || superCategories.isEmpty()) { // No super categories, and we haven't found the root yet, so this whole branch is not viable return Collections.emptySet(); } if (superCategories.size() == 1) { // Optimization for 1 super-category we can reuse our 'path' set return collectSuperCategories(superCategories.iterator().next(), rootCategories, path); } else { final HashSet<CategoryModel> result = new HashSet<>(); for (final CategoryModel superCategory : superCategories) { if (!isBlockedCategory(superCategory)) { // Collect the super category branch for each super-category with a copy of the path so far // Combine together the results result.addAll(collectSuperCategories(superCategory, rootCategories, new HashSet<CategoryModel>(path))); } } return result; } } }
From source file:org.hyperic.hq.events.ext.RegisteredTriggers.java
public Collection<RegisterableTriggerInterface> getInterestedTriggers(AbstractEvent event, Integer instanceId) { HashSet<RegisterableTriggerInterface> trigs = new HashSet<RegisterableTriggerInterface>(); // All alerts are disabled, so no triggers should be processing events if (!alertRegulator.alertsAllowed()) { return trigs; }/* w w w .ja v a 2s . com*/ TriggerEventKey key = new TriggerEventKey(event.getClass(), instanceId.intValue()); Map<Integer, RegisterableTriggerInterface> triggersById = triggers.get(key); if (triggersById != null) { trigs.addAll(triggersById.values()); } // Remove disabled triggers from new set so don't have to synchronize // retrieval around concurrent triggers map for (Iterator<RegisterableTriggerInterface> iterator = trigs.iterator(); iterator.hasNext();) { RegisterableTriggerInterface trigger = iterator.next(); if (!trigger.isEnabled()) { if (trigger instanceof ValueChangeTrigger) { if (event instanceof MeasurementEvent) { ((ValueChangeTrigger) trigger).setLast(((MeasurementEvent) event)); } } iterator.remove(); } } return trigs; }