Examples of BeanMap


Examples of org.apache.commons.beanutils.BeanMap

   * @param mode
   * @return
   */
  public static List<Criterion> getLikeCriterions(Object entity, String[] properties, MatchMode mode) {
    List<Criterion> criterions = CollectUtils.newArrayList();
    BeanMap map = new BeanMap(entity);
    for (int i = 0; i < properties.length; i++) {
      Object value = map.get(properties[i]);
      if ((value instanceof String) && (StringUtils.isNotEmpty((String) value))) {
        criterions.add(Restrictions.like(properties[i], (String) value, mode));
      }
    }
    return criterions;
View Full Code Here

Examples of org.apache.commons.beanutils.BeanMap

    if (value instanceof String) {
      if (StringUtils.isNotEmpty((String) value)) {
        criterions.add(likeCriterion(nestedName + path, (String) value, mode));
      }
    } else if (value instanceof Entity) {
      BeanMap foreignerMap = new BeanMap(value);
      Object foreignKey = foreignerMap.get("id");
      // 该值不能为空,而且要么不是String类型,要么是不空String类型变量.
      if (ValidEntityKeyPredicate.getInstance().evaluate(foreignKey)) {
        // 在查询中添加该键值.
        criterions.add(eqCriterion(nestedName + path + ".id", foreignKey));
      }
View Full Code Here

Examples of org.apache.commons.beanutils.BeanMap

      component = (Component) PropertyUtils.getProperty(entity, property);
    } catch (Exception e) {
      return Collections.emptyList();
    }
    if (null == component) { return Collections.emptyList(); }
    BeanMap map = new BeanMap(component);
    Set<String> properties = map.keySet();
    Set<String> excludeSet = null;
    if (null == excludePropertes) {
      excludeSet = Collections.emptySet();
    } else {
      excludeSet = CollectUtils.newHashSet();
      excludeSet.addAll(Arrays.asList(excludePropertes));
    }
    for (Iterator<String> iter = properties.iterator(); iter.hasNext();) {
      String propertyName = iter.next();
      String cascadeName = property + "." + propertyName;
      if (excludeSet.contains(cascadeName) || "class".equals(propertyName)) {
        continue;
      }
      if (!PropertyUtils.isWriteable(component, propertyName)) {
        continue;
      }
      Object value = map.get(propertyName);

      addCriterion(nestedName, entity, excludePropertes, cascadeName, value, criterions, mode,
          ignoreZero);
    }
    return criterions;
View Full Code Here

Examples of org.apache.commons.beanutils.BeanMap

    if (null == entity) { return; }
    boolean isEntity = false;
    if (entity instanceof Entity) {
      isEntity = true;
    }
    BeanMap map = new BeanMap(entity);
    List<String> attList = CollectUtils.newArrayList();
    attList.addAll(map.keySet());
    attList.remove("class");
    for (final String attr : attList) {
      if (!PropertyUtils.isWriteable(entity, attr)) {
        continue;
      }
      Object value = map.get(attr);
      if (null == value) {
        continue;
      } else {
        // evict invalid entity key
        if (isEntity && attr.equals("id")) {
          if (!ValidEntityKeyPredicate.getInstance().evaluate(value)) {
            map.put(attr, null);
          }
        }
        // evict invalid entity
        if (value instanceof Entity && !ValidEntityPredicate.getInstance().evaluate(value)) {
          map.put(attr, null);
        } else if (value instanceof Component) {
          // evict component recursively
          evictEmptyProperty(value);
        }
      }
View Full Code Here

Examples of org.apache.commons.beanutils.BeanMap

   *            忽略数字和字符串的默认值
   * @return
   */
  @SuppressWarnings("unchecked")
  public static boolean isEmpty(Entity<?> entity, boolean ignoreDefault) {
    BeanMap map = new BeanMap(entity);
    List<String> attList = CollectUtils.newArrayList();
    attList.addAll(map.keySet());
    attList.remove("class");
    try {
      for (final String attr : attList) {
        if (!PropertyUtils.isWriteable(entity, attr)) {
          continue;
        }
        Object value = map.get(attr);
        if (null == value) {
          continue;
        }
        if (ignoreDefault) {
          if (value instanceof Number) {
View Full Code Here

Examples of org.apache.commons.beanutils.BeanMap

  void displayResults(Object result) {
    if (null == result)
      return;

    BeanMap beanMap = new BeanMap(result);
    int i = 0;
    for (Iterator<?> itProperty = beanMap.keyIterator(); itProperty.hasNext(); i++) {
      String propertyName = "" + itProperty.next();
      Object propertyValue = beanMap.get(propertyName);

      if ("class".equals(propertyName))
        continue;

      if (null == propertyValue)
        continue;

      Class<?> propertyClass = null;

      try {
        propertyClass = beanMap.getType(propertyName);
      } catch (Exception e) {
        getLog().warn("Failure on property " + propertyName, e);
      }

      if (null == propertyClass) {
View Full Code Here

Examples of org.apache.commons.beanutils.BeanMap

  protected void displayResults(Object result) {
    if (null == result)
      return;

    BeanMap beanMap = new BeanMap(result);

    for (Iterator<?> itProperty = beanMap.keyIterator(); itProperty.hasNext();) {
      String propertyName = "" + itProperty.next();
      Object propertyValue = beanMap.get(propertyName);

      if ("class".equals(propertyName))
        continue;

      if (null == propertyValue)
        continue;

      Class<?> propertyClass = null;

      try {
        propertyClass = beanMap.getType(propertyName);
      } catch (Exception e) {
        getLog().warn("Failure on property " + propertyName, e);
      }

      if (null == propertyClass) {
View Full Code Here

Examples of org.apache.commons.collections.BeanMap

            Class<?> objectClass =
                Class.forName(getClassName(), true, getClassLoader());
            Object object = objectClass.newInstance();

            // Set all configured bean properties
            BeanMap map = new BeanMap(object);
            for (Object key : map.keySet()) {
                String value = properties.getProperty(key.toString());
                if (value != null) {
                    map.put(key, value);
                }
            }

            if (validate) {
                // Check that no invalid property names were configured
                for (Object key : properties.keySet()) {
                    if (!map.containsKey(key)
                            && properties.getProperty(key.toString()) != null) {
                        String msg =
                            "Configured class " + object.getClass().getName()
                            + " does not contain the property " + key
                            + ". Please fix the repository configuration.";
View Full Code Here

Examples of org.apache.commons.collections.BeanMap

     * @throws Exception if the test repository could not be retrieved
     */
    private static Repository getIntegratedInstance() throws Exception {
        Class test =
            Class.forName("org.apache.jackrabbit.test.AbstractJCRTest");
        Map helper = new BeanMap(test.getField("helper").get(null));
        final Repository repository =
            (Repository) helper.get("repository");
        final Credentials superuser =
            (Credentials) helper.get("superuserCredentials");
        return new ProxyRepository(new RepositoryFactory() {

            public Repository getRepository() throws RepositoryException {
                return repository;
            }
View Full Code Here

Examples of org.apache.commons.collections.BeanMap

            Class objectClass =
                Class.forName(getClassName(), true, getClassLoader());
            Object object = objectClass.newInstance();

            // Set all configured bean properties
            BeanMap map = new BeanMap(object);
            Iterator iterator = map.keyIterator();
            while (iterator.hasNext()) {
                String name = (String) iterator.next();
                String value = properties.getProperty(name);
                if (value != null) {
                    map.put(name, properties.getProperty(name));
                }
            }

            if (validate) {
                // Check that no invalid property names were configured
                Iterator it = properties.keySet().iterator();
                while (it.hasNext()) {
                    String key = (String) it.next();
                    if (!map.containsKey(key) && properties.getProperty(key) != null) {
                        String msg =
                            "Configured class " + object.getClass().getName()
                            + " does not contain the property " + key
                            + ". Please fix the repository configuration.";
                        log.error(msg);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.