List of usage examples for org.apache.commons.collections CollectionUtils find
public static Object find(Collection collection, Predicate predicate)
From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultB2BCommerceB2BUserGroupFacade.java
@Override public SearchPageData<B2BPermissionData> getPagedPermissionsForUserGroup(final PageableData pageableData, final String usergroupUID) { final SearchPageData<B2BPermissionModel> permissions = getB2BCommercePermissionService() .getPagedPermissions(pageableData); final SearchPageData<B2BPermissionData> searchPageData = convertPageData(permissions, getB2BPermissionConverter()); final B2BUserGroupModel userGroupModel = getCompanyB2BCommerceService().getB2BUserGroupForUid(usergroupUID); validateParameterNotNull(userGroupModel, String.format("No usergroup found for uid %s", usergroupUID)); for (final B2BPermissionData permissionData : searchPageData.getResults()) { permissionData.setSelected(/* w w w. j ava 2s . c o m*/ CollectionUtils.find(userGroupModel.getPermissions(), new BeanPropertyValueEqualsPredicate( B2BPermissionModel.CODE, permissionData.getCode())) != null); } return searchPageData; }
From source file:gov.nih.nci.caarray.domain.protocol.ProtocolApplication.java
/** * Return the parameter value for the parameter with given name in this protocol application. * If there is none, return null.//from w w w . jav a2 s . com * @param parameterName name of parameter for which to find a value. * @return the parameter value for parameter with given name or null if there is none. */ public AbstractParameterValue getValue(final String parameterName) { return (AbstractParameterValue) CollectionUtils.find(getValues(), new Predicate() { public boolean evaluate(Object o) { AbstractParameterValue fv = (AbstractParameterValue) o; return parameterName.equals(fv.getParameter().getName()); } }); }
From source file:fr.dudie.acrachilisync.tools.upgrade.IssueDescriptionReaderV1.java
/** * Extracts the stacktrace MD5 custom field value from the issue. * //from w w w.ja va 2 s. co m * @param pIssue * the issue * @return the stacktrace MD5 * @throws IssueParseException * issue doesn't contains a stack trace md5 custom field */ private String getStacktraceMD5(final Issue pIssue) throws IssueParseException { final int stackCfId = ConfigurationManager.getInstance().CHILIPROJECT_STACKTRACE_MD5_CF_ID; final Predicate findStacktraceMD5 = new CustomFieldIdPredicate(stackCfId); final CustomField field = (CustomField) CollectionUtils.find(pIssue.getCustomFields(), findStacktraceMD5); if (null == field) { throw new IssueParseException( String.format("Issue %d doesn't contains a custom_field id=%d", pIssue.getId(), stackCfId)); } return field.getValue(); }
From source file:net.sourceforge.fenixedu.presentationTier.renderers.student.enrollment.bolonha.ErasmusBolonhaStudentEnrolmentLayout.java
private boolean contains(List<CurricularCourse> curricularCourseList, final IDegreeModuleToEvaluate degreeModule) { if (!CurricularCourse.class.isAssignableFrom(degreeModule.getClass())) { return false; }//ww w.j a v a 2 s .c o m return CollectionUtils.find(curricularCourseList, new Predicate() { @Override public boolean evaluate(Object arg0) { return ((CurricularCourse) degreeModule).isEquivalent((CurricularCourse) arg0); } }) != null; }
From source file:edu.kit.dama.rest.dataworkflow.test.DataWorkflowTestService.java
private DataWorkflowTask getTaskById(final Long id) { DataWorkflowTask result = (DataWorkflowTask) CollectionUtils.find(tasks, new Predicate() { @Override//from w w w.j a v a 2 s. c o m public boolean evaluate(Object o) { return Objects.equals(((DataWorkflowTask) o).getId(), id); } }); if (result == null) { throw new WebApplicationException(404); } return result; }
From source file:jp.co.opentone.bsol.linkbinder.service.correspon.impl.LearningTagServiceImpl.java
@Override public void saveLearningTags(Correspon correspon) throws ServiceAbortException { List<LearningTag> tags = correspon.getLearningTag(); Set<LearningTag> deleteCandidateTags = new HashSet<>(); LearningTagDao dao = getDao(LearningTagDao.class); CorresponLearningTagDao ctDao = getDao(CorresponLearningTagDao.class); try {/*from ww w .j a va2 s. c o m*/ List<CorresponLearningTag> exists = ctDao.findByCorresponId(correspon.getId()); // ?????????? for (CorresponLearningTag ct : exists) { LearningTag found = (LearningTag) CollectionUtils.find(tags, o -> ((LearningTag) o).getId().equals(ct.getTagId())); if (found == null) { ctDao.delete(ct); LearningTag t = new LearningTag(); t.setId(ct.getTagId()); deleteCandidateTags.add(t); } } // ?? for (LearningTag t : correspon.getLearningTag()) { if (t.getId() < 0) { t.setCreatedBy(getCurrentUser()); t.setUpdatedBy(getCurrentUser()); Long id = dao.create(t); t.setId(id); } // ? CorresponLearningTag found = (CorresponLearningTag) CollectionUtils.find(exists, o -> ((CorresponLearningTag) o).getTagId().equals(t.getId())); if (found == null) { CorresponLearningTag ct = new CorresponLearningTag(); ct.setCorresponId(correspon.getId()); ct.setTagId(t.getId()); ct.setCreatedBy(getCurrentUser()); ct.setUpdatedBy(getCurrentUser()); ctDao.create(ct); } } // ????????? deleteCandidateTags.forEach(dao::deleteIfUnused); } catch (StaleRecordException e) { throw new ServiceAbortException( ApplicationMessageCode.CANNOT_PERFORM_BECAUSE_CORRESPON_ALREADY_UPDATED); } catch (KeyDuplicateException e) { throw new ServiceAbortException(e); } }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.masterDegree.administrativeOffice.candidate.ReadExecutionDegreeByDegreeCurricularPlanID.java
/** * @author <a href="mailto:shezad@ist.utl.pt">Shezad Anavarali</a> * // ww w.ja va 2 s . c o m * @param degreeCurricularPlanID * @param executionDegree * @return * @throws ExcepcaoPersistencia */ protected InfoExecutionDegree run(String degreeCurricularPlanID, final String executionYear) { DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); if (executionYear.equals("")) { return InfoExecutionDegree .newInfoFromDomain(degreeCurricularPlan.getExecutionDegreesSet().iterator().next()); } ExecutionDegree executionDegree = (ExecutionDegree) CollectionUtils .find(degreeCurricularPlan.getExecutionDegreesSet(), new Predicate() { @Override public boolean evaluate(Object arg0) { ExecutionDegree executionDegree = (ExecutionDegree) arg0; if (executionDegree.getExecutionYear().getYear().equals(executionYear)) { return true; } return false; } }); return InfoExecutionDegree.newInfoFromDomain(executionDegree); }
From source file:edu.common.dynamicextensions.xmi.XMIUtilities.java
/** * Finds and returns the first model element having the given * <code>name</code> in the <code>modelPackage</code>, returns * <code>null</code> if not found. * * @param modelPackage The modelPackage to search * @param name the name to find./*from w ww . j a v a 2 s.c o m*/ * @return the found model element. */ public static Object find(org.omg.uml.UmlPackage modelPackage, final String name) { return CollectionUtils.find( modelPackage.getModelManagement().getModel().refAllOfType(), new Predicate() { public boolean evaluate(Object object) { return (((ModelElement) object).getName()).equals(name); } }); }
From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultB2BCommerceUnitFacade.java
@Override public SearchPageData<UserData> getPagedAdministratorsForUnit(final PageableData pageableData, final String unitUid) { final SearchPageData<UserData> searchPageData = this.getPagedUserDataForUnit(pageableData, unitUid); // update the results with users that already have been selected. final B2BUnitData unit = this.getUnitForUid(unitUid); validateParameterNotNull(unit, String.format("No unit found for uid %s", unitUid)); for (final UserData userData : searchPageData.getResults()) { userData.setSelected(CollectionUtils.find(unit.getAdministrators(), new BeanPropertyValueEqualsPredicate(B2BCustomerModel.UID, userData.getUid())) != null); }// w w w .ja v a2 s. co m return searchPageData; }
From source file:com.arkea.jenkins.openstack.heat.HOTPlayer.java
@SuppressWarnings("rawtypes") @Override/* ww w . ja v a 2 s. c om*/ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) { // Specific logger with color ConsoleLogger cLog = new ConsoleLogger(listener.getLogger(), "HOT Player", bundle.isDebug()); try { // Variable in context EnvVarsUtils eVU = new EnvVarsUtils(build, listener, cLog); // Global configuration HOTPlayerSettings hPS = (HOTPlayerSettings) Jenkins.getInstance() .getDescriptor(HOTPlayerSettings.class); // Project OpenStack to use ProjectOS projectOS = (ProjectOS) CollectionUtils.find(hPS.getProjects(), new Predicate() { public boolean evaluate(Object o) { return project.equals(((ProjectOS) o).getProject()); } }); // Test if the project is found if (projectOS != null) { // Client OpenStack inject during test or client failed if (clientOS == null || !clientOS.isConnectionOK()) { clientOS = new OpenStack4jClient(projectOS); } // Delete stack if it exists ? if (this.bundle.isExist()) { if (!StackOperationsUtils.deleteStack(eVU.getVar(bundle.getName()), clientOS, cLog, hPS.getTimersOS())) { return false; } } // Create stack if (!StackOperationsUtils.createStack(eVU, bundle, projectOS, clientOS, cLog, hPS.getTimersOS())) { return false; } } else { cLog.logError(Messages.project_notFound(project)); return false; } } catch (Exception e) { cLog.logError(Messages.processing_failed(bundle.getName()) + ExceptionUtils.getStackTrace(e)); return false; } return true; }