Example usage for org.apache.commons.collections CollectionUtils select

List of usage examples for org.apache.commons.collections CollectionUtils select

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils select.

Prototype

public static Collection select(Collection inputCollection, Predicate predicate) 

Source Link

Document

Selects all elements from input collection which match the given predicate into an output collection.

Usage

From source file:com.kcs.service.impl.GenerateXml2ServiceImpl.java

private List<Datasetipi> filterChildIpi(final Datasetipi main, List<Datasetipi> childList) {
    List<Datasetipi> result = new ArrayList<Datasetipi>();
    final Predicate predicate = new Predicate() {
        @Override//w  w w.j a  va 2 s  .co  m
        public boolean evaluate(Object o) {
            if (Utility.isNotNull(o)) {
                Datasetipi child = (Datasetipi) o;
                boolean result = (objEquals(main.getCustCode(), child.getCustCode()));
                return result;
            }
            return false;
        }
    };
    result = (List<Datasetipi>) CollectionUtils.select(childList, predicate);
    return result;
}

From source file:com.kcs.service.impl.GenerateXmlOtherServiceImpl.java

private List<Datasetswa> filterChildSwa(final Datasetswa main, List<Datasetswa> childList) {
    List<Datasetswa> result = new ArrayList<Datasetswa>();
    final Predicate predicate = new Predicate() {
        @Override/*from   w  w w  .  ja v a 2  s . co  m*/
        public boolean evaluate(Object o) {
            if (Utility.isNotNull(o)) {
                Datasetswa child = (Datasetswa) o;
                boolean result = (objEquals(main.getCustCode(), child.getCustCode())
                        && objEquals(main.getSeq(), child.getSeq())
                        && objEquals(main.getSysCode(), child.getSysCode()));
                return result;
            }
            return false;
        }
    };
    result = (List<Datasetswa>) CollectionUtils.select(childList, predicate);
    return result;
}

From source file:ar.com.fdvs.dj.core.layout.AbstractLayoutManager.java

/**
 * Sets the columns width by reading some report options like the
 * printableArea and useFullPageWidth.//from ww  w .  j a  v a 2s .  c  o  m
 * columns with fixedWidth property set in TRUE will not be modified
 */
protected void setColumnsFinalWidth() {
    log.debug("Setting columns final width.");
    float factor = 1;
    int printableArea = report.getOptions().getColumnWidth();

    //Create a list with only the visible columns.
    List visibleColums = getVisibleColumns();

    if (report.getOptions().isUseFullPageWidth()) {
        int columnsWidth = 0;
        int notRezisableWidth = 0;

        //Store in a variable the total with of all visible columns
        for (Iterator iterator = visibleColums.iterator(); iterator.hasNext();) {
            AbstractColumn col = (AbstractColumn) iterator.next();
            columnsWidth += col.getWidth().intValue();
            if (col.getFixedWidth().booleanValue())
                notRezisableWidth += col.getWidth().intValue();
        }

        factor = (float) (printableArea - notRezisableWidth) / (float) (columnsWidth - notRezisableWidth);

        log.debug("printableArea = " + printableArea + ", columnsWidth = " + columnsWidth + ", columnsWidth = "
                + columnsWidth + ", notRezisableWidth = " + notRezisableWidth + ", factor = " + factor);

        int acumulated = 0;
        int colFinalWidth = 0;

        //Select the non-resizable columns
        Collection resizableColumns = CollectionUtils.select(visibleColums, new Predicate() {
            public boolean evaluate(Object arg0) {
                return !((AbstractColumn) arg0).getFixedWidth().booleanValue();
            }

        });

        //Finally, set the new width to the resizable columns
        for (Iterator iter = resizableColumns.iterator(); iter.hasNext();) {
            AbstractColumn col = (AbstractColumn) iter.next();

            if (!iter.hasNext()) {
                col.setWidth(new Integer(printableArea - notRezisableWidth - acumulated));
            } else {
                colFinalWidth = (new Float(col.getWidth().intValue() * factor)).intValue();
                acumulated += colFinalWidth;
                col.setWidth(new Integer(colFinalWidth));
            }
        }
    }

    // If the columns width changed, the X position must be setted again.
    int posx = 0;
    for (Iterator iterator = visibleColums.iterator(); iterator.hasNext();) {
        AbstractColumn col = (AbstractColumn) iterator.next();
        col.setPosX(new Integer(posx));
        posx += col.getWidth().intValue();
    }
}

From source file:net.sourceforge.fenixedu.domain.CurricularCourse.java

@SuppressWarnings("unchecked")
public boolean hasActiveScopeInGivenSemesterForCommonAndGivenBranch(final Integer semester,
        final Branch branch) {

    Collection<CurricularCourseScope> scopes = getScopesSet();

    List<CurricularCourseScope> result = (List<CurricularCourseScope>) CollectionUtils.select(scopes,
            new Predicate() {
                @Override/*from  ww w .j av  a 2s .c o m*/
                public boolean evaluate(Object obj) {
                    CurricularCourseScope curricularCourseScope = (CurricularCourseScope) obj;
                    return ((curricularCourseScope.getBranch().getBranchType().equals(BranchType.COMNBR)
                            || curricularCourseScope.getBranch().equals(branch))
                            && curricularCourseScope.getCurricularSemester().getSemester().equals(semester)
                            && curricularCourseScope.isActive().booleanValue());
                }
            });

    return !result.isEmpty();
}

From source file:net.shopxx.entity.Goods.java

@SuppressWarnings("unchecked")
@Transient/*ww  w.j  a v  a2  s.  c om*/
public Set<Promotion> getValidPromotions() {
    if (!Goods.Type.general.equals(getType()) || CollectionUtils.isEmpty(getPromotions())) {
        return Collections.emptySet();
    }

    return new HashSet<Promotion>(CollectionUtils.select(getPromotions(), new Predicate() {
        public boolean evaluate(Object object) {
            Promotion promotion = (Promotion) object;
            return promotion != null && promotion.hasBegun() && !promotion.hasEnded()
                    && CollectionUtils.isNotEmpty(promotion.getMemberRanks());
        }
    }));
}

From source file:net.sourceforge.fenixedu.domain.Teacher.java

public List<Professorship> getDegreeProfessorshipsByExecutionPeriod(final ExecutionSemester executionSemester) {
    return (List<Professorship>) CollectionUtils.select(getProfessorships(), new Predicate() {
        @Override//from w w w .  ja  v a2s . c  om
        public boolean evaluate(Object arg0) {
            Professorship professorship = (Professorship) arg0;
            return professorship.getExecutionCourse().getExecutionPeriod() == executionSemester
                    && !professorship.getExecutionCourse().isMasterDegreeDFAOrDEAOnly();
        }
    });
}

From source file:de.tub.citydb.modules.citykml.common.xlink.resolver.DBXlinkSplitter.java

private BuildingSurface CompareGeom(String GmlID) {
    final String id = GmlID;

    Predicate predicate = new Predicate() {

        public boolean evaluate(Object object) {

            if (((BuildingSurface) object).getPId() != null && ((BuildingSurface) object).getPId().equals(id))
                return true;
            else/*  w  w  w .  j  a va2  s . c o  m*/
                return ((BuildingSurface) object).getId().equals(id);
        }
    };

    Collection<BuildingSurface> filtered = CollectionUtils.select(list, predicate);

    return (filtered.size() > 0) ? new ArrayList<BuildingSurface>(filtered).get(0) : null;

}

From source file:com.kcs.service.impl.GenerateXmlOtherServiceImpl.java

private List<Datasetfxa> filterChildFxa(final Datasetfxa main, List<Datasetfxa> childList) {
    List<Datasetfxa> result = new ArrayList<Datasetfxa>();
    final Predicate predicate = new Predicate() {
        @Override/*from w  w  w.ja  v a  2 s  .co  m*/
        public boolean evaluate(Object o) {
            if (Utility.isNotNull(o)) {
                Datasetfxa child = (Datasetfxa) o;
                boolean result = (objEquals(main.getCustCode(), child.getCustCode())
                        && objEquals(main.getSeq(), child.getSeq())
                        && objEquals(main.getSysCode(), child.getSysCode()));
                return result;
            }
            return false;
        }
    };
    result = (List<Datasetfxa>) CollectionUtils.select(childList, predicate);
    return result;
}

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/*from   w  w w  .  j  av  a2  s. c o m*/
        public boolean evaluate(Object o) {
            ExecutionCourse executionCourse = (ExecutionCourse) o;
            return executionCourse.getExecutionPeriod().equals(executionSemester);
        }
    });
}

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/*from   ww  w.  j  a  v  a 2s .co m*/
        public boolean evaluate(Object o) {
            ExecutionCourse executionCourse = (ExecutionCourse) o;
            return executionCourse.getExecutionPeriod().getExecutionYear().equals(executionYear);
        }
    });
}