List of usage examples for org.apache.commons.collections Predicate Predicate
Predicate
From source file:module.siadap.domain.wrappers.UnitSiadapWrapper.java
public Integer getNumberCurrentRelevantsSiadap2WithoutQuota() { return getNrEvaluationsBasedOnPredicate(getSiadap2AndWorkingRelationWithoutQuotaUniverse(), new Predicate() { @Override//from ww w .java 2 s .c o m public boolean evaluate(Object arg0) { PersonSiadapWrapper personSiadapWrapper = (PersonSiadapWrapper) arg0; Siadap siadap = personSiadapWrapper.getSiadap(); if (siadap != null && siadap.hasGivenSiadapGlobalEvaluation(SiadapGlobalEvaluation.HIGH, SiadapUniverse.SIADAP2)) { return true; } return false; } }); }
From source file:net.sourceforge.fenixedu.domain.CurricularCourse.java
@SuppressWarnings("unchecked") public List<ExecutionCourse> getExecutionCoursesByExecutionYear(final ExecutionYear executionYear) { return (List<ExecutionCourse>) CollectionUtils.select(getAssociatedExecutionCoursesSet(), new Predicate() { @Override/* w w w. j a va 2s.co m*/ public boolean evaluate(Object o) { ExecutionCourse executionCourse = (ExecutionCourse) o; return executionCourse.getExecutionPeriod().getExecutionYear().equals(executionYear); } }); }
From source file:edu.kit.dama.rest.staging.types.TransferTaskContainer.java
/** * Add a settings file/directory to the provided tree. If pSettingsFile is a * file, the file is added to the 'settings' node of the provided file tree. * If pSettingsFile is a folder, all contained files and directories are * added to the 'settings' node of the provided file tree. The tree must be * compatible to the required tree structure. Therefore, it should be * created by createCompatibleTree() before. * * @param pTree The tree to which the file/directory is added. * @param pTransferInfo The transfer information associated with the tree. * @param pSettingsFile The file/directory to add. * * @throws edu.kit.lsdf.adalapi.exception.AdalapiException If pSettingsFile * cannot be accessed.//from w ww. j av a 2 s . c o m * @throws java.net.MalformedURLException If extracting the URL information * from pSettingsFile fails. This should never happen. */ public final static void addSettingsFile(IFileTree pTree, ITransferInformation pTransferInfo, File pSettingsFile) throws AdalapiException, MalformedURLException { ICollectionNode settingsNode = (ICollectionNode) CollectionUtils.find(pTree.getRootNode().getChildren(), new Predicate() { @Override public boolean evaluate(Object o) { return Constants.STAGING_SETTINGS_FOLDER_NAME.equals(((IDataOrganizationNode) o).getName()); } }); if (settingsNode == null) { throw new IllegalArgumentException("Provided tree has an invalid structure. No '" + Constants.STAGING_SETTINGS_FOLDER_NAME + "' node found."); } IFileTree newTree = DataOrganizationUtils.createTreeFromFile(pTransferInfo.getDigitalObjectId(), new AbstractFile(pSettingsFile), pTransferInfo.getSettingsFolderUrl(), false); DataOrganizationUtils.merge(settingsNode, new LinkedList<ICollectionNode>(), newTree.getRootNode() .getChildren().toArray(new IDataOrganizationNode[newTree.getRootNode().getChildren().size()])); }
From source file:net.sourceforge.fenixedu.domain.CompetenceCourse.java
@SuppressWarnings("unchecked") public List<CurricularCourse> getCurricularCoursesWithActiveScopesInExecutionPeriod( final ExecutionSemester executionSemester) { return (List<CurricularCourse>) CollectionUtils.select(getAssociatedCurricularCoursesSet(), new Predicate() { @Override/*from w ww .ja v a 2 s . c om*/ public boolean evaluate(Object arg0) { CurricularCourse curricularCourse = (CurricularCourse) arg0; for (DegreeModuleScope moduleScope : curricularCourse.getDegreeModuleScopes()) { if (moduleScope.isActiveForExecutionPeriod(executionSemester)) { return true; } } return false; } }); }
From source file:edu.kit.dama.staging.util.DataOrganizationUtils.java
/** * Add pNodeToAdd to pNode. Before the node is added it is checked if there * is already a child of pNode with the name of pNodeToAdd. If there is a * IFileNode with the same name, pNodeToAdd is not added. If there is a * ICollectionNode with the same name, all children of pNodeToAdd are added * recursively using this method. The mentioned checks are then performed * for each node.//from www. ja v a 2s .c om * * @param pNode To node to which a node is added. * @param pNodeToAdd The node to add. */ public static void addNode(ICollectionNode pNode, final IDataOrganizationNode pNodeToAdd) { IDataOrganizationNode result = (IDataOrganizationNode) CollectionUtils.find(pNode.getChildren(), new Predicate() { @Override public boolean evaluate(Object o) { IDataOrganizationNode node = (IDataOrganizationNode) o; if (o instanceof ICollectionNode && pNodeToAdd instanceof IFileNode) { return false; } else if (o instanceof IFileNode && pNodeToAdd instanceof ICollectionNode) { return false; } else {//node types are equal...check them if (node.getName() != null) { return node.getName().equals(pNodeToAdd.getName()); } else if (pNodeToAdd.getName() != null) { return pNodeToAdd.getName().equals(node.getName()); } //both are null return true; } } }); if (result == null) { //no child with same name, just add the node pNode.addChild(pNodeToAdd); } else if (result instanceof ICollectionNode && pNodeToAdd instanceof ICollectionNode) { //child with same name found for (IDataOrganizationNode child : ((ICollectionNode) pNodeToAdd).getChildren()) { addNode((ICollectionNode) result, child); } } }
From source file:module.siadap.domain.wrappers.UnitSiadapWrapper.java
public Integer getNumberCurrentExcellentsSiadap3WithQuota() { return getNrEvaluationsBasedOnPredicate(getSiadap3AndWorkingRelationWithQuotaUniverse(), new Predicate() { @Override//from w w w .j a va 2 s . com public boolean evaluate(Object arg0) { PersonSiadapWrapper personSiadapWrapper = (PersonSiadapWrapper) arg0; Siadap siadap = personSiadapWrapper.getSiadap(); if (siadap != null && siadap.hasGivenSiadapGlobalEvaluation(SiadapGlobalEvaluation.EXCELLENCY, SiadapUniverse.SIADAP3)) { return true; } return false; } }); }
From source file:com.kcs.service.impl.GenerateXmlOtherServiceImpl.java
private List<Datasetfra> filterChildFra(final Datasetfra main, List<Datasetfra> childList) { List<Datasetfra> result = new ArrayList<Datasetfra>(); final Predicate predicate = new Predicate() { @Override//from www . j a va 2 s. c om public boolean evaluate(Object o) { if (Utility.isNotNull(o)) { Datasetfra child = (Datasetfra) o; boolean result = (objEquals(main.getCustCode(), child.getCustCode()) && objEquals(main.getSeq(), child.getSeq()) && objEquals(main.getSysCode(), child.getSysCode())); return result; } return false; } }; result = (List<Datasetfra>) CollectionUtils.select(childList, predicate); return result; }
From source file:module.siadap.domain.wrappers.UnitSiadapWrapper.java
public Integer getNumberCurrentRelevantsSiadap3WithQuota() { return getNrEvaluationsBasedOnPredicate(getSiadap3AndWorkingRelationWithQuotaUniverse(), new Predicate() { @Override//from w w w .j a v a2 s.c om public boolean evaluate(Object arg0) { PersonSiadapWrapper personSiadapWrapper = (PersonSiadapWrapper) arg0; Siadap siadap = personSiadapWrapper.getSiadap(); if (siadap != null && siadap.hasGivenSiadapGlobalEvaluation(SiadapGlobalEvaluation.HIGH, SiadapUniverse.SIADAP3)) { return true; } return false; } }); }
From source file:com.architexa.diagrams.relo.jdt.parts.ClassEditPart.java
protected Predicate getPredicateForShowRef() { Predicate refPred = new Predicate() { Resource classRes = getElementRes(); public boolean evaluate(Object arg0) { // arg0 is a method that references this Type if (!(arg0 instanceof Resource)) return true; // Don't show references from a // method that this class contains Resource parent = (Resource) arg0; while (parent != null) { if (classRes.equals(parent)) return false; parent = (Resource) getRepo().getStatement((Resource) null, RSECore.contains, parent) .getSubject();//from w ww. j a v a 2s. c o m } return true; } }; return refPred; }
From source file:net.sourceforge.fenixedu.domain.student.Student.java
final public Enrolment getDissertationEnrolment(DegreeCurricularPlan degreeCurricularPlan, final ExecutionYear executionYear) { TreeSet<Enrolment> enrolments = getDissertationEnrolments(degreeCurricularPlan); CollectionUtils.filter(enrolments, new Predicate() { @Override// w w w .j a va 2 s. c o m public boolean evaluate(Object enrolment) { return ((Enrolment) enrolment).getExecutionYear().equals(executionYear); } }); return enrolments.isEmpty() ? null : enrolments.last(); }