List of usage examples for org.apache.commons.collections Predicate Predicate
Predicate
From source file:ml.shifu.shifu.util.CommonUtils.java
/** * Get target ColumnConfig.//from w w w.jav a 2 s . c o m * * @param columnConfigList * column config list * @return target ColumnConfig * @throws IllegalArgumentException * if columnConfigList is null or empty. * * @throws IllegalStateException * if no target column can be found. */ public static ColumnConfig getTargetColumnConfig(List<ColumnConfig> columnConfigList) { if (CollectionUtils.isEmpty(columnConfigList)) { throw new IllegalArgumentException("columnConfigList should not be null or empty."); } // I need cast operation because of common-collections doesn't support generic. ColumnConfig cc = (ColumnConfig) CollectionUtils.find(columnConfigList, new Predicate() { @Override public boolean evaluate(Object object) { return ((ColumnConfig) object).isTarget(); } }); if (cc == null) { throw new IllegalStateException( "No target column can be found, please check your column configurations"); } return cc; }
From source file:module.siadap.domain.wrappers.UnitSiadapWrapper.java
public BigDecimal getRelevantEvaluationPercentage() { int totalPeopleWorkingForUnit = getUnitEmployees(true).size(); Collection<PersonSiadapWrapper> relevantEvaluationPersons = getUnitEmployees(true, new Predicate() { @Override/*from w ww . ja va 2 s. c o m*/ public boolean evaluate(Object personObject) { PersonSiadapWrapper personWrapper = (PersonSiadapWrapper) personObject; if (personWrapper.getSiadap() == null || personWrapper.getSiadap().getDefaultSiadapEvaluationUniverse() == null) { return false; } return personWrapper.getSiadap().getDefaultSiadapEvaluationUniverse().hasRelevantEvaluation(); } }); int relevantCount = relevantEvaluationPersons.size(); if ((relevantCount == 0) || (totalPeopleWorkingForUnit == 0)) { return BigDecimal.ZERO; } return new BigDecimal(relevantCount) .divide(new BigDecimal(totalPeopleWorkingForUnit), UnitSiadapWrapper.SCALE, RoundingMode.HALF_EVEN) .multiply(new BigDecimal(100), new MathContext(UnitSiadapWrapper.SCALE)); }
From source file:edu.kit.dama.rest.staging.types.TransferTaskContainer.java
/** * Add a data file/directory to the provided tree. If pDataFile is a file, * the file is added to the 'data' node of the provided file tree. If * pDataFile is a folder, all contained files and directories are added to * the 'data' node of the provided file tree. The tree must be compatible to * the required tree structure. Therefore, it should be created by * createCompatibleTree() before.// w w w. ja va 2 s . c o m * * @param pTree The tree to which the file/directory is added. * @param pTransferInfo The transfer information associated with the tree. * @param pDataFile The file/directory to add. * * @throws edu.kit.lsdf.adalapi.exception.AdalapiException If pDataFile * cannot be accessed. * @throws java.net.MalformedURLException If extracting the URL information * from pDataFile fails. This should never happen. */ public final static void addDataFile(IFileTree pTree, ITransferInformation pTransferInfo, File pDataFile) throws AdalapiException, MalformedURLException { ICollectionNode dataNode = (ICollectionNode) CollectionUtils.find(pTree.getRootNode().getChildren(), new Predicate() { @Override public boolean evaluate(Object o) { return Constants.STAGING_DATA_FOLDER_NAME.equals(((IDataOrganizationNode) o).getName()); } }); //DataOrganizationUtils.printTree(pTree.getRootNode(), true); if (dataNode == null) { throw new IllegalArgumentException("Provided tree has an invalid structure. No '" + Constants.STAGING_DATA_FOLDER_NAME + "' node found."); } AbstractFile dataFile = new AbstractFile(pDataFile); IFileTree newTree = DataOrganizationUtils.createTreeFromFile(pTransferInfo.getDigitalObjectId(), dataFile, dataFile.getUrl(), false); DataOrganizationUtils.merge(dataNode, new LinkedList<ICollectionNode>(), newTree.getRootNode().getChildren() .toArray(new IDataOrganizationNode[newTree.getRootNode().getChildren().size()])); }
From source file:module.siadap.domain.wrappers.UnitSiadapWrapper.java
public Integer getNumberCurrentExcellentsSiadap2WithQuota() { return getNrEvaluationsBasedOnPredicate(getSiadap2AndWorkingRelationWithQuotaUniverse(), new Predicate() { @Override/* ww 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.EXCELLENCY, SiadapUniverse.SIADAP2)) { return true; } return false; } }); }
From source file:module.siadap.domain.wrappers.UnitSiadapWrapper.java
public Integer getNumberCurrentRelevantsSiadap2WithQuota() { return getNrEvaluationsBasedOnPredicate(getSiadap2AndWorkingRelationWithQuotaUniverse(), new Predicate() { @Override/*from w ww .ja v a2 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:edu.kit.dama.rest.staging.types.TransferTaskContainer.java
/** * Add a generated file/directory to the provided tree. If pGeneratedFile is * a file, the file is added to the 'generated' node of the provided file * tree. If pGeneratedFile is a folder, all contained files and directories * are added to the 'generated' 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 pGeneratedFile The file/directory to add. * * @throws edu.kit.lsdf.adalapi.exception.AdalapiException If pGeneratedFile * cannot be accessed./*from w w w . j a va2 s . c o m*/ * @throws java.net.MalformedURLException If extracting the URL information * from pGeneratedFile fails. This should never happen. */ public final static void addGeneratedFile(IFileTree pTree, ITransferInformation pTransferInfo, File pGeneratedFile) throws AdalapiException, MalformedURLException { ICollectionNode generatedNode = (ICollectionNode) CollectionUtils.find(pTree.getRootNode().getChildren(), new Predicate() { @Override public boolean evaluate(Object o) { return Constants.STAGING_GENERATED_FOLDER_NAME .equals(((IDataOrganizationNode) o).getName()); } }); if (generatedNode == null) { throw new IllegalArgumentException("Provided tree has an invalid structure. No '" + Constants.STAGING_GENERATED_FOLDER_NAME + "' node found."); } IFileTree newTree = DataOrganizationUtils.createTreeFromFile(pTransferInfo.getDigitalObjectId(), new AbstractFile(pGeneratedFile), pTransferInfo.getGeneratedFolderUrl(), false); DataOrganizationUtils.merge(generatedNode, new LinkedList<ICollectionNode>(), newTree.getRootNode() .getChildren().toArray(new IDataOrganizationNode[newTree.getRootNode().getChildren().size()])); }
From source file:net.sourceforge.fenixedu.domain.accounting.report.events.EventReportQueueJob.java
public static List<EventReportQueueJob> retrieveAllGeneratedReports() { List<EventReportQueueJob> reports = new ArrayList<EventReportQueueJob>(); CollectionUtils.select(Bennu.getInstance().getQueueJobSet(), new Predicate() { @Override/* w ww .ja v a 2s. c om*/ public boolean evaluate(Object arg0) { return arg0 instanceof EventReportQueueJob; } }, reports); return reports; }
From source file:module.siadap.domain.wrappers.UnitSiadapWrapper.java
public Integer getNumberCurrentExcellentsSiadap2WithoutQuota() { return getNrEvaluationsBasedOnPredicate(getSiadap2AndWorkingRelationWithoutQuotaUniverse(), new Predicate() { @Override/*from w ww. j a v a 2s.c om*/ public boolean evaluate(Object arg0) { PersonSiadapWrapper personSiadapWrapper = (PersonSiadapWrapper) arg0; Siadap siadap = personSiadapWrapper.getSiadap(); if (siadap != null && siadap.hasGivenSiadapGlobalEvaluation( SiadapGlobalEvaluation.EXCELLENCY, SiadapUniverse.SIADAP2)) { return true; } return false; } }); }
From source file:net.sourceforge.fenixedu.domain.accounting.report.events.EventReportQueueJob.java
public static List<EventReportQueueJob> retrieveDoneGeneratedReports() { List<EventReportQueueJob> reports = new ArrayList<EventReportQueueJob>(); CollectionUtils.select(Bennu.getInstance().getQueueJobSet(), new Predicate() { @Override/*from w w w . j av a 2 s . c om*/ public boolean evaluate(Object arg0) { if (!(arg0 instanceof EventReportQueueJob)) { return false; } EventReportQueueJob eventReportQueueJob = (EventReportQueueJob) arg0; return eventReportQueueJob.getDone(); } }, reports); return reports; }
From source file:net.sourceforge.fenixedu.domain.CurricularCourse.java
@SuppressWarnings("unchecked") public List<ExecutionCourse> getExecutionCoursesByExecutionPeriod(final ExecutionSemester executionSemester) { return (List<ExecutionCourse>) CollectionUtils.select(getAssociatedExecutionCoursesSet(), new Predicate() { @Override/* w w w. j a v a2 s . c om*/ public boolean evaluate(Object o) { ExecutionCourse executionCourse = (ExecutionCourse) o; return executionCourse.getExecutionPeriod().equals(executionSemester); } }); }