Example usage for org.apache.commons.beanutils BeanPropertyValueEqualsPredicate BeanPropertyValueEqualsPredicate

List of usage examples for org.apache.commons.beanutils BeanPropertyValueEqualsPredicate BeanPropertyValueEqualsPredicate

Introduction

In this page you can find the example usage for org.apache.commons.beanutils BeanPropertyValueEqualsPredicate BeanPropertyValueEqualsPredicate.

Prototype

public BeanPropertyValueEqualsPredicate(String propertyName, Object propertyValue) 

Source Link

Document

Constructor which takes the name of the property, its expected value to be used in evaluation, and assumes ignoreNull to be false.

Usage

From source file:com.dotosoft.dot4command.commands.FilterCollectionCommand.java

@Override
public Processing onExecute(C context) {

    Collection dataCollection = (Collection) getProperty(context, fromKey);
    BeanPropertyValueEqualsPredicate predicate = new BeanPropertyValueEqualsPredicate(filterExpression,
            filterValue);//ww  w . j av a  2s  .c o  m
    CollectionUtils.filter(dataCollection, predicate);

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

    return Processing.FINISHED;
}

From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultB2BCommerceB2BUserGroupFacade.java

@Override
public SearchPageData<UserData> getPagedCustomersForUserGroup(final PageableData pageableData,
        final String usergroupUID) {
    final SearchPageData<UserData> searchPageData = this.getPagedUserData(pageableData);
    // update the results with users that already have been selected.
    final UserGroupModel userGroupModel = getB2BCommerceB2BUserGroupService().getUserGroupForUID(usergroupUID,
            UserGroupModel.class);
    validateParameterNotNull(userGroupModel, String.format("No usergroup found for uid %s", usergroupUID));
    for (final UserData userData : searchPageData.getResults()) {
        final UserModel user = getUserService().getUserForUID(userData.getUid());
        userData.setSelected(CollectionUtils.find(user.getGroups(),
                new BeanPropertyValueEqualsPredicate(UserModel.UID, userGroupModel.getUid())) != null);
    }/*w  ww.  j a  v a2 s.  c om*/
    return searchPageData;
}

From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultB2BCommerceUnitFacade.java

@Override
public SearchPageData<UserData> getPagedApproversForUnit(final PageableData pageableData,
        final String unitUid) {
    final SearchPageData<B2BCustomerModel> approvers = getB2BCommerceUnitService()
            .findPagedApproversForUnitByGroupMembership(pageableData, unitUid, B2BConstants.B2BAPPROVERGROUP);
    final SearchPageData<UserData> searchPageData = convertPageData(approvers, getB2BUserConverter());
    // update the results with approvers 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.getApprovers(),
                new BeanPropertyValueEqualsPredicate(B2BCustomerModel.UID, userData.getUid())) != null);
    }//  w ww.  j a  v  a 2  s .  c  o m

    return searchPageData;
}

From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultB2BCommerceUserFacade.java

@Override
public SearchPageData<UserData> getPagedApproversForCustomer(final PageableData pageableData,
        final String uid) {
    final SearchPageData<B2BCustomerModel> approvers = getB2BCommerceUserService()
            .getPagedCustomersByGroupMembership(pageableData, B2BConstants.B2BAPPROVERGROUP);
    final SearchPageData<UserData> searchPageData = convertPageData(approvers, getB2BUserConverter());
    // update the results with approvers that already have been selected.
    final CustomerData customer = this.getCustomerDataForUid(uid);
    validateParameterNotNull(customer, String.format("No customer found for uid %s", uid));
    for (final UserData userData : searchPageData.getResults()) {
        userData.setSelected(CollectionUtils.find(customer.getApprovers(),
                new BeanPropertyValueEqualsPredicate(B2BCustomerModel.UID, userData.getUid())) != null);
    }//w ww . j av a  2s .c om

    return searchPageData;
}

From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultB2BCommerceUnitFacade.java

@Override
public SearchPageData<UserData> getPagedCustomersForUnit(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.getCustomers(),
                new BeanPropertyValueEqualsPredicate(B2BCustomerModel.UID, userData.getUid())) != null);
    }//from www.  j  av  a 2 s .  c  om

    return searchPageData;
}

From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultB2BCommerceCostCenterFacade.java

@Override
public SearchPageData<B2BBudgetData> getPagedBudgetsForCostCenters(final PageableData pageableData,
        final String costCenterCode) {
    final SearchPageData<B2BBudgetData> searchPageData = this.getPagedBudgets(pageableData);
    final B2BCostCenterData costCenter = this.getCostCenterDataForCode(costCenterCode);
    for (final B2BBudgetData budgetData : searchPageData.getResults()) {
        budgetData.setSelected(CollectionUtils.find(costCenter.getB2bBudgetData(),
                new BeanPropertyValueEqualsPredicate(B2BBudgetModel.CODE, budgetData.getCode())) != null);
    }// w  ww . j ava2  s .  c  om

    return searchPageData;
}

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(/*from   ww w. j  a v a  2 s. c o  m*/
                CollectionUtils.find(userGroupModel.getPermissions(), new BeanPropertyValueEqualsPredicate(
                        B2BPermissionModel.CODE, permissionData.getCode())) != null);
    }

    return searchPageData;
}

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.j  a  va  2 s .c o  m

    return searchPageData;
}

From source file:io.coala.experimental.dynabean.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);//from w ww. j av a2 s  . com

    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));
}

From source file:de.hybris.platform.b2bacceleratorfacades.company.impl.DefaultB2BCommerceUnitFacade.java

@Override
public SearchPageData<UserData> getPagedManagersForUnit(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.getManagers(),
                new BeanPropertyValueEqualsPredicate(B2BCustomerModel.UID, userData.getUid())) != null);
    }//from ww w  .j  a  v a  2  s  . c o m

    return searchPageData;
}