Package org.springframework.beans

Examples of org.springframework.beans.BeanWrapper


    public boolean update(Class entityClass, UpdateDataDTO[] data) throws Exception {
        Assert.notNull(entityClass);
        for (UpdateDataDTO dto : data) {
            Assert.isEncrypted(decipherer, dto.getPrimaryKey());
            DomainEntity o = dao.find(entityClass, new UUID(decipherer.decrypt(dto.getPrimaryKey())));
            BeanWrapper w = new BeanWrapperImpl(o);
            w.setPropertyValue(dto.getPath(), dto.getValue());
            dao.update(o);
        }
        return true;
    }
View Full Code Here


    @SuppressWarnings("unchecked")
    protected Errors doValidation(Class clazz, String path, Object value) throws Exception {
        DomainEntity object = (DomainEntity) ClassUtils.instantiateClass(clazz);
        object.initialize(contextHolder);
        BeanWrapper validatable = new BeanWrapperImpl(object);
        validatable.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), false));
        validatable.setPropertyValue(path, value);
        Errors errors = new BeanPropertyBindingResult(object, "target");
        validator.validate(object, errors);
        return errors;
    }
View Full Code Here

    @RemoteMethod
    public boolean update(Class clazz, UpdateDataDTO[] data) throws Exception {
        for (UpdateDataDTO dto : data) {
            UserImpl user = dao.findUser(dto.getPrimaryKey());
            BeanWrapper w = new BeanWrapperImpl(user);
            w.setPropertyValue(dto.getPath(), dto.getValue());
            dao.createUser(user);
        }
        return true;
    }
View Full Code Here

    this.filterConfig = filterConfig;

    // Set bean properties from init parameters.
    try {
      PropertyValues pvs = new FilterConfigPropertyValues(filterConfig, this.requiredProperties);
      BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
      ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext());
      bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader));
      initBeanWrapper(bw);
      bw.setPropertyValues(pvs, true);
    } catch (BeansException ex) {
      String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': "
          + ex.getMessage();
      logger.error(msg, ex);
      throw new NestedServletException(msg, ex);
View Full Code Here

                        @Override
                        public void populateItem(final Item<ICellPopulator<AbstractSchemaTO>> item,
                                final String componentId, final IModel<AbstractSchemaTO> model) {

                            BeanWrapper bwi = new BeanWrapperImpl(model.getObject());
                            Object obj = bwi.getPropertyValue(field);

                            item.add(new Label(componentId, ""));
                            item.add(new AttributeModifier("class", new Model<String>(obj.toString())));
                        }
View Full Code Here

                jobInstanceLoader.registerJob(report);
            }
        }

        final Object job = ctx.getBean(bundle.getJobDetail().getKey().getName());
        final BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(job);
        if (isEligibleForPropertyPopulation(wrapper.getWrappedInstance())) {
            final MutablePropertyValues pvs = new MutablePropertyValues();
            if (this.schedulerContext != null) {
                pvs.addPropertyValues(this.schedulerContext);
            }
            pvs.addPropertyValues(bundle.getJobDetail().getJobDataMap());
            pvs.addPropertyValues(bundle.getTrigger().getJobDataMap());
            if (this.ignoredUnknownProperties == null) {
                wrapper.setPropertyValues(pvs, true);
            } else {
                for (String propName : this.ignoredUnknownProperties) {
                    if (pvs.contains(propName) && !wrapper.isWritableProperty(propName)) {

                        pvs.removePropertyValue(propName);
                    }
                }
                wrapper.setPropertyValues(pvs);
            }
        }
        return job;
    }
View Full Code Here

    return memberCollection.containsKey(id);
  }

  // alternative way of copying values
  public void copyValues(Member source, Member target, Iterable<String> properties) {
    BeanWrapper src = new BeanWrapperImpl(source);
    BeanWrapper trg = new BeanWrapperImpl(target);

    for(String propertyName : properties){
      trg.setPropertyValue(propertyName,src.getPropertyValue(propertyName)
      );
    }

  }
View Full Code Here

    List<T> results = new ArrayList<T>();
    if (reader != null) {
      try {
        for (GenericRecord r : reader) {
          T data = targetClass.newInstance();
          BeanWrapper beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(data);
          for (Schema.Field f : r.getSchema().getFields()) {
            if (beanWrapper.isWritableProperty(f.name())) {
              beanWrapper.setPropertyValue(f.name(), r.get(f.name()));
            }
          }
          results.add(data);
        }
      } catch (InstantiationException e) {
View Full Code Here

        fs.exists(new Path(path + "/test/" + DatasetUtils.getDatasetName(recordClass) + "/.metadata")));
    Collection<T> results = datasetOperations.read(recordClass);
    assertEquals(2, results.size());
    List<T> sorted = new ArrayList<T>(results);
    Collections.sort(sorted);
    BeanWrapper result = new BeanWrapperImpl(sorted.get(0));
    assertTrue(result.isReadableProperty("name"));
    assertTrue(result.getPropertyValue("name").equals("Sven"));
    assertTrue(result.isReadableProperty("id"));
    assertTrue(result.getPropertyValue("id").equals(22L));
    result = new BeanWrapperImpl(sorted.get(1));
    assertTrue(result.isReadableProperty("name"));
    assertTrue(result.getPropertyValue("name").equals("Nisse"));
    assertTrue(result.isReadableProperty("id"));
    assertTrue(result.getPropertyValue("id").equals(48L));
  }
View Full Code Here

  public void usesFieldAccessForReadIfNoAccessorCanBeFound() {

    Sample sample = new Sample();
    sample.firstname = "Dave";

    BeanWrapper wrapper = new DirectFieldAccessFallbackBeanWrapper(sample);

    assertThat(wrapper.getPropertyValue("firstname"), is((Object) "Dave"));
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.BeanWrapper

Copyright © 2018 www.massapicom. 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.