List of usage examples for org.apache.commons.collections CollectionUtils find
public static Object find(Collection collection, Predicate predicate)
From source file:com.epam.cme.storefront.controllers.pages.AbstractSearchPageController.java
protected List<FacetData<SearchStateData>> refineFacets(final List<FacetData<SearchStateData>> facets, final Map<String, FacetData<SearchStateData>> selectedFacets) { final List<FacetData<SearchStateData>> refinedFacets = new ArrayList<FacetData<SearchStateData>>(); for (final FacetData<SearchStateData> facet : facets) { facet.setTopValues(Collections.<FacetValueData<SearchStateData>>emptyList()); final List<FacetValueData<SearchStateData>> facetValues = new ArrayList<FacetValueData<SearchStateData>>( facet.getValues());//from w ww .j a v a 2 s .c o m for (final FacetValueData<SearchStateData> facetValueData : facetValues) { if (selectedFacets.containsKey(facet.getName())) { final boolean foundFacetWithName = null != CollectionUtils.find( selectedFacets.get(facet.getName()).getValues(), new BeanPropertyValueEqualsPredicate("name", facetValueData.getName(), true)); facetValueData.setSelected(foundFacetWithName); } } if (selectedFacets.containsKey(facet.getName())) { facetValues.addAll(selectedFacets.get(facet.getName()).getValues()); selectedFacets.remove(facet.getName()); } refinedFacets.add(facet); } if (!selectedFacets.isEmpty()) { refinedFacets.addAll(selectedFacets.values()); } return refinedFacets; }
From source file:com.yqboots.dict.core.DataDictManagerImpl.java
/** * {@inheritDoc}/* www .j a va 2s .c o m*/ */ @Override public String getText(final String name, final String value, boolean valueIncluded) { final List<DataDict> all = getDataDicts(name, LocaleContextHolder.getLocale()); final DataDict item = (DataDict) CollectionUtils.find(all, o -> { final DataDict dict = (DataDict) o; return StringUtils.equals(dict.getValue(), value); }); if (item == null) { LOG.warn("No data dict for {} with value [{}]", name, value); return value; } return valueIncluded ? StringUtils.join(new String[] { item.getValue(), item.getText() }, " - ") : item.getText(); }
From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultB2BCommerceUserFacade.java
@Override public SearchPageData<B2BPermissionData> getPagedPermissionsForCustomer(final PageableData pageableData, final String uid) { final SearchPageData<B2BPermissionModel> permissions = getB2BCommercePermissionService() .getPagedPermissions(pageableData); final SearchPageData<B2BPermissionData> searchPageData = convertPageData(permissions, getB2BPermissionConverter()); final CustomerData customer = this.getCustomerDataForUid(uid); validateParameterNotNull(customer, String.format("No customer found for uid %s", uid)); for (final B2BPermissionData permissionData : searchPageData.getResults()) { permissionData.setSelected(//w ww . j a v a2 s . com CollectionUtils.find(customer.getPermissions(), new BeanPropertyValueEqualsPredicate( B2BPermissionModel.CODE, permissionData.getCode())) != null); } return searchPageData; }
From source file:edu.kit.sharing.test.SharingTestService.java
@Override public Response deleteReference(String pDomain, String pDomainUniqueId, String pGroupId, HttpContext hc) { final SecurableResourceId rid = new SecurableResourceId(pDomain, pDomainUniqueId); final GroupId gid = new GroupId(pGroupId); ReferenceId rr = (ReferenceId) CollectionUtils.find(references, new Predicate() { @Override/*from w ww . j a v a 2s . c o m*/ public boolean evaluate(Object o) { ReferenceId r = (ReferenceId) o; return r.getSecurableResourceId() == rid && r.getGroupId() == gid; } }); references.remove(rr); return Response.ok().build(); }
From source file:hr.fer.zemris.vhdllab.service.workspace.ProjectMetadataTest.java
@Test public void addFile3() { File file = new File("file_name", null, "data"); metadata.addFile(file);//from w w w . j a va2s .co m File found = (File) CollectionUtils.find(metadata.getFiles(), new Predicate() { @Override public boolean evaluate(Object object) { File f = (File) object; return f.getName().equals("file_name"); } }); assertEquals(hierarchy.getProject(), found.getProject()); }
From source file:net.sourceforge.fenixedu.domain.Branch.java
private Boolean hasCurricularCourseCommonBranchInAnyCurricularCourseScope(CurricularCourse curricularCourse, final Branch commonBranch) { return ((CurricularCourseScope) CollectionUtils.find(curricularCourse.getScopesSet(), new Predicate() { @Override/*from www. j a v a 2 s. co m*/ public boolean evaluate(Object o) { CurricularCourseScope ccs = (CurricularCourseScope) o; return ccs.getBranch().equals(commonBranch); } }) != null); }
From source file:edu.kit.dama.ui.simon.panel.SimonMainPanel.java
/** * Reload the view and refresh the status of all probes. *//*from w ww . j a v a2s .c o m*/ private void reload() { LOGGER.debug("Reloading main panel"); //remove all tabs and clear all categories for (Tab tab : tabs) { tabSheet.removeTab(tab); probesByCategory.clear(); tabsByCategory.clear(); } //get all probes AbstractProbe[] probes = SimonConfigurator.getSingleton().getProbes(); LOGGER.debug(" - Obtaining categories for {} probes", probes.length); for (AbstractProbe probe : probes) { //refresh the status probe.refreshProbeStatus(); //obtain category and assign probe to according list String currentProbesCategory = probe.getCategory(); List<AbstractProbe> probesInCategory = probesByCategory.get(currentProbesCategory); if (probesInCategory == null) { LOGGER.debug(" - Obtained new category {}", currentProbesCategory); probesInCategory = new LinkedList<>(); probesInCategory.add(probe); LOGGER.debug(" - Adding probe {} to new category", probe.getName()); probesByCategory.put(currentProbesCategory, probesInCategory); } else { LOGGER.debug(" - Adding probe {} to existing category {}", new Object[] { probe.getName(), currentProbesCategory }); probesInCategory.add(probe); } } //sort all category keys by name Set<String> keys = probesByCategory.keySet(); String[] aKeys = keys.toArray(new String[keys.size()]); Arrays.sort(aKeys); LOGGER.debug(" - Building category tabs"); for (String key : aKeys) { tabsByCategory.put(key, createCategoryTab(probesByCategory.get(key))); } tabsByCategory.put("Overview", buildOverviewTab(aKeys)); tabs.add(tabSheet.addTab(tabsByCategory.get("Overview"), "Overview")); for (String key : aKeys) { Tab categoryTab = tabSheet.addTab(tabsByCategory.get(key), key); List<AbstractProbe> probeList = probesByCategory.get(key); if (CollectionUtils.find(probeList, new Predicate() { @Override public boolean evaluate(Object o) { return ((AbstractProbe) o).getCurrentStatus().equals(AbstractProbe.PROBE_STATUS.FAILED); } }) != null) { categoryTab.setIcon(new ThemeResource("img/icons/warning.png")); } tabs.add(categoryTab); } LOGGER.debug("Layout successfully created."); }
From source file:net.sourceforge.fenixedu.dataTransferObject.CurricularCourseScopesForPrintDTO.java
private CurricularYearForPrintDTO getSelectedCurricularYear(final InfoCurricularCourseScope scope, DegreeCurricularPlanForPrintDTO selectedCurricularPlan) { CurricularYearForPrintDTO selectedCurricularYear = (CurricularYearForPrintDTO) CollectionUtils .find(selectedCurricularPlan.getYears(), new Predicate() { @Override//from w w w .j a va2s . c om public boolean evaluate(Object arg0) { CurricularYearForPrintDTO curricularYearForPrintDTO = (CurricularYearForPrintDTO) arg0; if (curricularYearForPrintDTO.getYear() .equals(scope.getInfoCurricularSemester().getInfoCurricularYear().getYear())) { return true; } return false; } }); if (selectedCurricularYear == null) { selectedCurricularYear = new CurricularYearForPrintDTO( scope.getInfoCurricularSemester().getInfoCurricularYear().getYear()); selectedCurricularPlan.getYears().add(selectedCurricularYear); } return selectedCurricularYear; }
From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultB2BCommerceUnitFacade.java
@Override public B2BUnitNodeData getParentUnitNode() { final B2BUnitModel parentUnit = getB2BCommerceUnitService().getParentUnit(); return (B2BUnitNodeData) CollectionUtils.find(getBranchNodes(), new BeanPropertyValueEqualsPredicate("id", parentUnit.getUid())); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.student.finalDegreeWork.FinalDegreeWorkAttributionDA.java
@EntryPoint public ActionForward prepare(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final ExecutionYear executionYear) throws Exception { final DynaActionForm finalDegreeWorkAttributionForm = (DynaActionForm) form; finalDegreeWorkAttributionForm.set("executionYearOID", executionYear.getExternalId().toString()); final Set<ExecutionYear> executionYears = new TreeSet<ExecutionYear>( ExecutionYear.REVERSE_COMPARATOR_BY_YEAR); executionYears.addAll(rootDomainObject.getExecutionYearsSet()); request.setAttribute("executionYears", executionYears); final FinalDegreeWorkGroup group = findGroup(executionYear); if (group != null) { final InfoGroup infoGroup = InfoGroup.newInfoFromDomain(group); final ExecutionDegree executionDegree = group.getExecutionDegree(); if (executionDegree.getScheduling() == null || executionDegree.getScheduling().getAttributionByTeachers() != Boolean.TRUE) { return mapping.findForward("NoConfirmationInProcessException"); }/*from w w w . j a va2s.c om*/ Collections.sort(infoGroup.getGroupProposals(), new BeanComparator("orderOfPreference")); request.setAttribute("infoGroup", infoGroup); InfoGroupProposal infoGroupProposal = (InfoGroupProposal) CollectionUtils.find( infoGroup.getGroupProposals(), new PREDICATE_FIND_PROPOSAL_ATTRIBUTED_TO_GROUP_BY_TEACHER(infoGroup.getExternalId())); if (infoGroupProposal != null) { finalDegreeWorkAttributionForm.set("attributedByTeacher", infoGroupProposal.getFinalDegreeWorkProposal().getExternalId().toString()); } String confirmAttributions[] = new String[infoGroup.getGroupStudents().size()]; for (int i = 0; i < infoGroup.getGroupStudents().size(); i++) { InfoGroupStudent infoGroupStudent = infoGroup.getGroupStudents().get(i); if (infoGroupStudent != null && infoGroupStudent.getFinalDegreeWorkProposalConfirmation() != null) { confirmAttributions[i] = infoGroupStudent.getFinalDegreeWorkProposalConfirmation() .getExternalId().toString(); confirmAttributions[i] += infoGroupStudent.getStudent().getExternalId(); } } finalDegreeWorkAttributionForm.set("confirmAttributions", confirmAttributions); request.setAttribute("finalDegreeWorkAttributionForm", finalDegreeWorkAttributionForm); } return mapping.findForward("showFinalDegreeWorkList"); }