List of usage examples for org.apache.commons.collections Predicate Predicate
Predicate
From source file:net.shopxx.service.impl.PluginServiceImpl.java
public List<PaymentPlugin> getPaymentPlugins(final boolean isEnabled) { List<PaymentPlugin> result = new ArrayList<PaymentPlugin>(); CollectionUtils.select(paymentPlugins, new Predicate() { public boolean evaluate(Object object) { PaymentPlugin paymentPlugin = (PaymentPlugin) object; return paymentPlugin.getIsEnabled() == isEnabled; }//from w w w .j a va 2s . com }, result); Collections.sort(result); return result; }
From source file:com.dp2345.service.impl.GoodsServiceImpl.java
@Override @Transactional//w w w . jav a2s . co m @CacheEvict(value = { "product", "productCategory", "review", "consultation" }, allEntries = true) public Goods update(Goods goods) { Assert.notNull(goods); Set<Product> excludes = new HashSet<Product>(); CollectionUtils.select(goods.getProducts(), new Predicate() { public boolean evaluate(Object object) { Product product = (Product) object; return product != null && product.getId() != null; } }, excludes); List<Product> products = productDao.findList(goods, excludes); for (Product product : products) { staticService.delete(product); } Goods pGoods = super.update(goods); goodsDao.flush(); if (pGoods.getProducts() != null) { for (Product product : pGoods.getProducts()) { staticService.build(product); } } return pGoods; }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.coordinator.degreeCurricularPlanManagement.ReadCurrentCurriculumByCurricularCourseCode.java
@Atomic public static InfoCurriculum run(String executionDegreeCode, String curricularCourseCode) throws FenixServiceException { check(RolePredicates.COORDINATOR_PREDICATE); if (curricularCourseCode == null) { throw new FenixServiceException("nullCurricularCourse"); }/*from w w w . j a va 2 s .c o m*/ CurricularCourse curricularCourse = (CurricularCourse) FenixFramework.getDomainObject(curricularCourseCode); if (curricularCourse == null) { throw new NonExistingServiceException(); } // selects active curricular course scopes List<CurricularCourseScope> activeCurricularCourseScopes = curricularCourse.getActiveScopes(); activeCurricularCourseScopes = (List) CollectionUtils.select(activeCurricularCourseScopes, new Predicate() { @Override public boolean evaluate(Object arg0) { CurricularCourseScope curricularCourseScope = (CurricularCourseScope) arg0; if (curricularCourseScope.isActive().booleanValue()) { return true; } return false; } }); final ExecutionSemester executionSemester = ExecutionSemester.readActualExecutionSemester(); List<ExecutionCourse> associatedExecutionCourses = new ArrayList<ExecutionCourse>(); Collection<ExecutionCourse> executionCourses = curricularCourse.getAssociatedExecutionCoursesSet(); for (ExecutionCourse executionCourse : executionCourses) { if (executionCourse.getExecutionPeriod().equals(executionSemester)) { associatedExecutionCourses.add(executionCourse); } } Curriculum curriculum = curricularCourse.findLatestCurriculum(); InfoCurriculum infoCurriculum = null; if (curriculum != null) { infoCurriculum = InfoCurriculumWithInfoCurricularCourse.newInfoFromDomain(curriculum); } else { infoCurriculum = new InfoCurriculumWithInfoCurricularCourse(); infoCurriculum.setExternalId(null); infoCurriculum.setInfoCurricularCourse(InfoCurricularCourse.newInfoFromDomain(curricularCourse)); } infoCurriculum = createInfoCurriculum(infoCurriculum, activeCurricularCourseScopes, associatedExecutionCourses); return infoCurriculum; }
From source file:com.newlandframework.avatarmq.broker.ProducerMessageHook.java
private void filterByTopic(String topic) { Predicate focusAllPredicate = new Predicate() { public boolean evaluate(Object object) { ConsumerClusters clusters = (ConsumerClusters) object; return clusters.findSubscriptionData(topic) != null; }//from ww w . jav a2s .c o m }; AnyPredicate any = new AnyPredicate(new Predicate[] { focusAllPredicate }); Closure joinClosure = new Closure() { public void execute(Object input) { if (input instanceof ConsumerClusters) { ConsumerClusters clusters = (ConsumerClusters) input; clustersSet.add(clusters); } } }; Closure ignoreClosure = new Closure() { public void execute(Object input) { } }; Closure ifClosure = ClosureUtils.ifClosure(any, joinClosure, ignoreClosure); CollectionUtils.forAllDo(focusTopicGroup, ifClosure); }
From source file:de.forsthaus.backend.dao.impl.LanguageDAOImpl.java
@Override public Language getLanguageByLocale(final String lanLocale) { return (Language) CollectionUtils.find(LANGUAGES, new Predicate() { @Override/*from w ww. jav a 2 s .c o m*/ public boolean evaluate(Object object) { return StringUtils.equals(lanLocale, ((Language) object).getLanLocale()); } }); }
From source file:net.sourceforge.fenixedu.domain.reports.FlunkedReportFile.java
@Override public void renderReport(Spreadsheet spreadsheet) { spreadsheet.setHeader("nmero aluno"); spreadsheet.setHeader("ciclo estudos"); setDegreeHeaders(spreadsheet);// w w w . ja v a2 s . c o m for (final Degree degree : Degree.readNotEmptyDegrees()) { if (checkDegreeType(getDegreeType(), degree)) { for (final Registration registration : degree.getRegistrationsSet()) { LinkedList<RegistrationState> states = new LinkedList<RegistrationState>(); states.addAll(registration.getRegistrationStatesSet()); CollectionUtils.filter(states, new Predicate() { @Override public boolean evaluate(Object item) { return ((RegistrationState) item).getExecutionYear() != null && ((RegistrationState) item).getExecutionYear().equals(getExecutionYear()); } }); Collections.sort(states, RegistrationState.DATE_COMPARATOR); if (!states.isEmpty() && states.getLast().getStateType().equals(RegistrationStateType.FLUNKED)) { final Row row = spreadsheet.addRow(); row.setCell(registration.getNumber()); CycleType cycleType = registration.getCycleType(states.getLast().getExecutionYear()); row.setCell(cycleType != null ? cycleType.toString() : ""); setDegreeCells(row, degree); } } } } }
From source file:net.sourceforge.fenixedu.domain.reimbursementGuide.ReimbursementGuide.java
public ReimbursementGuideSituation getActiveReimbursementGuideSituation() { return (ReimbursementGuideSituation) CollectionUtils.find(getReimbursementGuideSituationsSet(), new Predicate() { @Override/*from w ww . j av a 2s .co m*/ public boolean evaluate(Object obj) { ReimbursementGuideSituation situation = (ReimbursementGuideSituation) obj; return situation.getState().getState().equals(State.ACTIVE); } }); }
From source file:de.hybris.platform.b2b.services.impl.DefaultB2BCustomerServiceTest.java
@Test public void testAddMember() throws Exception { final B2BCustomerModel user = login("GC CEO"); final B2BUnitModel unitToBeAssigned = b2bUnitService.getUnitForUid("GC Sales UK"); Assert.assertNotNull(unitToBeAssigned); b2bCustomerService.addMember(user, unitToBeAssigned); Assert.assertNotNull(CollectionUtils.find(user.getGroups(), new Predicate() { @Override/*from ww w . j a va2s . c o m*/ public boolean evaluate(final Object result) { return ((PrincipalGroupModel) result).getUid().equals("GC Sales UK"); } })); }
From source file:net.shopxx.service.impl.PluginServiceImpl.java
public List<StoragePlugin> getStoragePlugins(final boolean isEnabled) { List<StoragePlugin> result = new ArrayList<StoragePlugin>(); CollectionUtils.select(storagePlugins, new Predicate() { public boolean evaluate(Object object) { StoragePlugin storagePlugin = (StoragePlugin) object; return storagePlugin.getIsEnabled() == isEnabled; }//from www. j av a 2 s.c o m }, result); Collections.sort(result); return result; }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.teacher.services.EditTeacherAdviseService.java
protected void run(Teacher teacher, String executionPeriodID, final Integer studentNumber, Double percentage, AdviseType adviseType, RoleType roleType) throws FenixServiceException { ExecutionSemester executionSemester = FenixFramework.getDomainObject(executionPeriodID); Collection<Registration> students = Bennu.getInstance().getRegistrationsSet(); Registration registration = (Registration) CollectionUtils.find(students, new Predicate() { @Override//from w ww. j a v a 2 s. co m public boolean evaluate(Object arg0) { Registration tempStudent = (Registration) arg0; return tempStudent.getNumber().equals(studentNumber); } }); if (registration == null) { throw new FenixServiceException("errors.invalid.student-number"); } TeacherService teacherService = teacher.getTeacherServiceByExecutionPeriod(executionSemester); if (teacherService == null) { teacherService = new TeacherService(teacher, executionSemester); } List<Advise> advises = registration.getAdvisesByTeacher(teacher); Advise advise = null; if (advises == null || advises.isEmpty()) { advise = new Advise(teacher, registration, adviseType, executionSemester, executionSemester); } else { advise = advises.iterator().next(); } TeacherAdviseService teacherAdviseService = advise .getTeacherAdviseServiceByExecutionPeriod(executionSemester); if (teacherAdviseService == null) { teacherAdviseService = new TeacherAdviseService(teacherService, advise, percentage, roleType); } else { teacherAdviseService.updatePercentage(percentage, roleType); } }