Java 类org.apache.commons.beanutils.BeanPropertyValueEqualsPredicate 实例源码

项目:dot4command-core    文件:FilterCollectionCommand.java   
@Override
public Processing onExecute(C context) {

    Collection dataCollection = (Collection) getProperty(context, fromKey);
    BeanPropertyValueEqualsPredicate predicate = new BeanPropertyValueEqualsPredicate(
            filterExpression, filterValue);
    CollectionUtils.filter(dataCollection, predicate);

    if(dataCollection.isEmpty()) {
        context.remove(toKey);
    } else {
        context.put((K) toKey, (V) dataCollection);
    }

    return Processing.FINISHED;
}
项目:opencucina    文件:AccessManagerImpl.java   
private boolean userHasPermission(User user, String privilegeName, String typeName,
    Map<String, Object> propertyValues) {
    for (Permission permission : user.getPermissions()) {
        if (CollectionUtils.find(permission.getRole().getPrivileges(),
                    new BeanPropertyValueEqualsPredicate("name", privilegeName)) != null) {
            //found priv match
            Map<String, Collection<BigInteger>> organisedMap = relevantDimensions(typeName,
                    permission);

            if (matches(typeName, organisedMap, propertyValues)) {
                return true;
            }
        }
    }

    return false;
}
项目:opencucina    文件:ProjectionSeedTest.java   
/**
     * JAVADOC Method Level Comments
     */
//    @Test
    public void testGetProjectionsA() {
        List<ProjectionSeed> result = ProjectionSeed.getProjections(Annoited.class);

        assertNotNull("result is null", result);

        ProjectionSeed bytes = (ProjectionSeed) CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "bytes"));

        assertNotNull("seed cannot be null", bytes);
        assertEquals("name.bytes", bytes.getProperty());
        assertNull(CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "number")));

        ProjectionSeed shortname = (ProjectionSeed) CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "short name"));

        assertEquals("name", shortname.getProperty());
        assertNull(CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "lastDate")));
        assertNull(CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "nextDate")));
    }
项目:opencucina    文件:ProjectionSeedTest.java   
/**
   * JAVADOC Method Level Comments
   */
//  @Test
  public void testGetProjectionsB() {
      //these should be the same as the ones above
      List<ProjectionSeed> result = ProjectionSeed.getProjections(Annoited.class, Default.class);

      assertNotNull("result is null", result);

      ProjectionSeed bytes = (ProjectionSeed) CollectionUtils.find(result,
              new BeanPropertyValueEqualsPredicate("alias", "bytes"));

      assertNotNull("seed cannot be null", bytes);
      assertEquals("name.bytes", bytes.getProperty());
      assertNull(CollectionUtils.find(result,
              new BeanPropertyValueEqualsPredicate("alias", "number")));

      ProjectionSeed shortname = (ProjectionSeed) CollectionUtils.find(result,
              new BeanPropertyValueEqualsPredicate("alias", "short name"));

      assertEquals("name", shortname.getProperty());
      assertNull(CollectionUtils.find(result,
              new BeanPropertyValueEqualsPredicate("alias", "lastDate")));
      assertNull(CollectionUtils.find(result,
              new BeanPropertyValueEqualsPredicate("alias", "nextDate")));
  }
项目:opencucina    文件:AccessManagerImpl.java   
private boolean userHasPrivilege(String privilegeName, User user) {
    Collection<Privilege> privileges = new HashSet<Privilege>();

    for (Permission permission : user.getPermissions()) {
        privileges.addAll(permission.getRole().getPrivileges());
    }

    return CollectionUtils.find(privileges,
        new BeanPropertyValueEqualsPredicate("name", privilegeName)) != null;
}
项目:opencucina    文件:HistorisedTypeCriteriaModifierTest.java   
/**
 * Checks that historic criteria are added to search
 */
@Test
public void modifySearchBean() {
    Map<String, Object> params = new HashMap<String, Object>();

    params.put(PersistableEntity.APPLICATION_TYPE, Foo.TYPE);

    SearchBean bean = modifier.doModify(searchbean, params);
    Collection<SearchCriterion> searchCriteria = bean.getCriteria();

    assertEquals(3, searchCriteria.size());

    // Expect three criterion added implicitly
    assertNotNull(CollectionUtils.find(searchCriteria,
            new AndPredicate(new InstanceofPredicate(InSearchCriterion.class),
                new AndPredicate(new BeanPropertyValueEqualsPredicate("name",
                        "token.domainObjectType"),
                    new AndPredicate(new BeanPropertyValueEqualsPredicate("value",
                            Collections.singleton(Foo.TYPE)),
                        new BeanPropertyValueEqualsPredicate("rootAlias",
                            SearchCriterionMarshaller.HISTORY_ALIAS))))));
    assertNotNull(CollectionUtils.find(searchCriteria,
            new AndPredicate(new InstanceofPredicate(JoinCriterion.class),
                new AndPredicate(new BeanPropertyValueEqualsPredicate("lhs", "id"),
                    new BeanPropertyValueEqualsPredicate("rhs", "token.domainObjectId")))));
    assertNotNull(CollectionUtils.find(searchCriteria,
            new AndPredicate(new BeanPropertyValueEqualsPredicate("rootAlias",
                    SearchCriterionMarshaller.HISTORY_ALIAS),
                new AndPredicate(new BeanPropertyValueEqualsPredicate(NAME_ALIAS, ID_PROPERTY),
                    new BeanPropertyValueEqualsPredicate("subSelect",
                        "select max(hr.id) from HistoryRecord hr where hr.token.domainObjectId = foo.id and hr.token.domainObjectType = 'Foo'")))));
}
项目:opencucina    文件:ProjectionSeedTest.java   
/**
     * JAVADOC Method Level Comments
     */
//    @Test
    public void testGetProjectionsC() {
        List<ProjectionSeed> result = ProjectionSeed.getProjections(Annoited.class, Search.class);

        assertNotNull("result is null", result);

        ProjectionSeed bytes = (ProjectionSeed) CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "bytes"));

        assertNotNull("seed cannot be null", bytes);
        assertEquals("name.bytes", bytes.getProperty());
        assertNull(CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "number")));

        ProjectionSeed shortname = (ProjectionSeed) CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "short name"));

        assertEquals("name", shortname.getProperty());

        ProjectionSeed lastDate = (ProjectionSeed) CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "lastDate"));

        assertNotNull("lastDate cannot be null", lastDate);
        assertEquals("lastDate", lastDate.getProperty());
        assertEquals("preference", lastDate.getEntityAlias());
        assertEquals("Preference", lastDate.getEntityClazz());
        assertNull("null as column has been marked with Export",
            CollectionUtils.find(result, new BeanPropertyValueEqualsPredicate("alias", "nextDate")));

        System.err.println(result);
    }
项目:opencucina    文件:ProjectionSeedTest.java   
/**
     * JAVADOC Method Level Comments
     */
//    @Test
    public void testGetProjectionsD() {
        List<ProjectionSeed> result = ProjectionSeed.getProjections(Annoited.class, Default.class);

        assertNotNull("result is null", result);

        ProjectionSeed bytes = (ProjectionSeed) CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "bytes"));

        assertNotNull("seed cannot be null", bytes);
        assertEquals("name.bytes", bytes.getProperty());

        ProjectionSeed number = (ProjectionSeed) CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "number"));

        assertNotNull("number cannot be null", number);
        assertEquals("number", number.getProperty());

        ProjectionSeed shortname = (ProjectionSeed) CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "short name"));

        assertEquals("name", shortname.getProperty());
        assertNull(CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "lastDate")));
        assertNull(CollectionUtils.find(result,
                new BeanPropertyValueEqualsPredicate("alias", "nextDate")));

        System.err.println(result);
    }
项目:opencucina    文件:HistorisedEntityDescriptorCriteriaModifierTest.java   
/**
 * Checks that historic criteria are added to search
 */
@Test
public void modifySearchBean() {
    Map<String, Object> params = new HashMap<String, Object>();

    params.put(PersistableEntity.APPLICATION_TYPE, EntityDescriptor.class.getSimpleName());

    SearchBean bean = modifier.doModify(searchbean, params);
    Collection<SearchCriterion> searchCriteria = bean.getCriteria();

    assertEquals(3, searchCriteria.size());

    // Expect three criterion added implicitly, subjectAlias
    assertNotNull(CollectionUtils.find(searchCriteria,
            new AndPredicate(new InstanceofPredicate(JoinCriterion.class),
                new AndPredicate(new BeanPropertyValueEqualsPredicate("lhs",
                        EntityDescriptor.APPLICATION_TYPE_PROP),
                    new BeanPropertyValueEqualsPredicate("rhs", "token.domainObjectType")))));
    assertNotNull(CollectionUtils.find(searchCriteria,
            new AndPredicate(new InstanceofPredicate(JoinCriterion.class),
                new AndPredicate(new BeanPropertyValueEqualsPredicate("lhs", "id"),
                    new BeanPropertyValueEqualsPredicate("rhs", "token.domainObjectId")))));
    assertNotNull(CollectionUtils.find(searchCriteria,
            new AndPredicate(new BeanPropertyValueEqualsPredicate("rootAlias",
                    SearchCriterionMarshaller.HISTORY_ALIAS),
                new AndPredicate(new BeanPropertyValueEqualsPredicate(NAME_ALIAS, ID_PROPERTY),
                    new BeanPropertyValueEqualsPredicate("subSelect",
                        "select max(hr.id) from HistoryRecord hr where hr.token.domainObjectId = foo.id and hr.token.domainObjectType = " +
                        NameUtils.concat(ALIAS, EntityDescriptor.APPLICATION_TYPE_PROP))))));
}
项目:dotoquiz-tools    文件:PicasawebClient.java   
public List filterPhoto( List photoCollection, String filterExpression, Object filterValue ) throws Exception {
    BeanPropertyValueEqualsPredicate predicate = new BeanPropertyValueEqualsPredicate( filterExpression, filterValue );
    CollectionUtils.filter(photoCollection, predicate);
    return photoCollection;
}
项目:motech    文件:FieldProcessorTest.java   
private FieldDto findFieldWithName(Collection<FieldDto> fields, String name) {
    return (FieldDto) CollectionUtils.find(
            fields, new BeanPropertyValueEqualsPredicate("basic.name", name)
    );
}
项目:coala    文件:DynaBeanTest.java   
@Test
public void testDynaBeans() throws Exception
{
    // for usage, see
    // http://commons.apache.org/proper/commons-beanutils/javadocs/v1.9.2/apidocs/org/apache/commons/beanutils/package-summary.html#package_description

    final DynaBean dynaBean = new LazyDynaBean(); // Create LazyDynaBean
    final MutableDynaClass dynaClass = (MutableDynaClass) dynaBean
            .getDynaClass(); // get DynaClass

    dynaClass.add("amount", java.lang.Integer.class); // add property
    dynaClass.add("myMap", java.util.TreeMap.class); // add mapped property

    final DynaBean employee = dynaClass.newInstance();

    // TODO experiment with Jackson's AnnotationIntrospector to annotate
    // DynaBean#get(...) method with @JsonAnyGetter and #set(...) method
    // with @JsonAnySetter

    employee.set("address", new HashMap<String, String>());
    employee.set("activeEmployee", Boolean.FALSE);
    employee.set("firstName", "Fred");
    employee.set("lastName", "Flintstone");

    LOG.trace("Employee: " + JsonUtil.toPrettyJSON(employee));

    // set all <activeEmployee> attribute values to <true>
    final BeanPropertyValueChangeClosure closure = new BeanPropertyValueChangeClosure(
            "activeEmployee", Boolean.TRUE);

    final Collection<?> employees = Collections.singleton(employee);
    LOG.trace("Mutated employees: " + JsonUtil.toPrettyJSON(employees));

    // update the Collection
    CollectionUtils.forAllDo(employees, closure);

    // filter for beans with <activeEmployee> set to <false>
    final BeanPropertyValueEqualsPredicate predicate = new BeanPropertyValueEqualsPredicate(
            "lastName", "Flintstone");

    // filter the Collection
    CollectionUtils.filter(employees, predicate);
    LOG.trace("Filtered employees: " + JsonUtil.toPrettyJSON(employees));
}