Example usage for org.springframework.beans BeanUtils copyProperties

List of usage examples for org.springframework.beans BeanUtils copyProperties

Introduction

In this page you can find the example usage for org.springframework.beans BeanUtils copyProperties.

Prototype

public static void copyProperties(Object source, Object target) throws BeansException 

Source Link

Document

Copy the property values of the given source bean into the target bean.

Usage

From source file:org.oscarehr.ws.transfer_objects.ProviderPropertyTransfer.java

public static ProviderPropertyTransfer toTransfer(Property property) {
    if (property == null)
        return (null);

    ProviderPropertyTransfer providerPropertyTransfer = new ProviderPropertyTransfer();

    BeanUtils.copyProperties(property, providerPropertyTransfer);

    return (providerPropertyTransfer);
}

From source file:org.oscarehr.ws.transfer_objects.ProviderTransfer.java

public static ProviderTransfer toTransfer(Provider provider) {
    if (provider == null)
        return (null);

    ProviderTransfer providerTransfer = new ProviderTransfer();

    BeanUtils.copyProperties(provider, providerTransfer);

    return (providerTransfer);
}

From source file:org.patientview.radar.util.RadarUtility.java

public static Patient mergePatientRecords(Patient source, Patient link) {

    Patient mergedPatient = new Patient();

    BeanUtils.copyProperties(source, mergedPatient);

    // Properties to mock the source object into the linked one
    mergedPatient.setId(link.getId());//from w  w w.ja v  a 2s .c  o m
    mergedPatient.setUnitcode(link.getUnitcode());
    mergedPatient.setNhsno(link.getNhsno());

    // Properties overridden has radar data
    if (StringUtils.hasText(link.getSurnameAlias())) {
        mergedPatient.setSurnameAlias(link.getSurnameAlias());
    }

    if (StringUtils.hasText(link.getEthnicGp())) {
        mergedPatient.setEthnicGp(link.getEthnicGp());
    }

    if (StringUtils.hasText(link.getTelephone2())) {
        mergedPatient.setTelephone2(link.getTelephone2());
    }

    if (StringUtils.hasText(link.getMobile())) {
        mergedPatient.setMobile(link.getMobile());
    }

    if (link.getRrtModality() != null) {
        mergedPatient.setRrtModality(link.getRrtModality());
    }

    if (StringUtils.hasText(link.getDiagnosis())) {
        mergedPatient.setDiagnosis(link.getDiagnosis());
    }

    if (link.getDiagnosisDate() != null) {
        mergedPatient.setDiagnosisDate(link.getDiagnosisDate());
    }

    if (link.getOtherClinicianAndContactInfo() != null) {
        mergedPatient.setOtherClinicianAndContactInfo(link.getOtherClinicianAndContactInfo());
    }

    if (StringUtils.hasText(link.getComments())) {
        mergedPatient.setComments(link.getComments());
    }

    return mergedPatient;
}

From source file:org.shept.org.springframework.web.servlet.mvc.support.ModelUtils.java

/**
 * Answer a shallow copy of the object//from   ww  w . j ava 2 s .  c  om
 * @param model
 * @return
 */
private static Object shallowCopy(Object model) {
    Object newModel = BeanUtils.instantiate(model.getClass());
    BeanUtils.copyProperties(model, newModel);
    return newModel;
}

From source file:org.springframework.cloud.stream.binding.BindingService.java

@SuppressWarnings("unchecked")
public <T> Collection<Binding<T>> bindConsumer(T input, String inputName) {
    String bindingTarget = this.bindingServiceProperties.getBindingDestination(inputName);
    String[] bindingTargets = StringUtils.commaDelimitedListToStringArray(bindingTarget);
    Collection<Binding<T>> bindings = new ArrayList<>();
    Binder<T, ConsumerProperties, ?> binder = (Binder<T, ConsumerProperties, ?>) getBinder(inputName,
            input.getClass());//from   w w  w . j a va 2  s.  c o m
    ConsumerProperties consumerProperties = this.bindingServiceProperties.getConsumerProperties(inputName);
    if (binder instanceof ExtendedPropertiesBinder) {
        Object extension = ((ExtendedPropertiesBinder) binder).getExtendedConsumerProperties(inputName);
        ExtendedConsumerProperties extendedConsumerProperties = new ExtendedConsumerProperties(extension);
        BeanUtils.copyProperties(consumerProperties, extendedConsumerProperties);
        consumerProperties = extendedConsumerProperties;
    }
    validate(consumerProperties);
    for (String target : bindingTargets) {
        Binding<T> binding = binder.bindConsumer(target, bindingServiceProperties.getGroup(inputName), input,
                consumerProperties);
        bindings.add(binding);
    }
    bindings = Collections.unmodifiableCollection(bindings);
    this.consumerBindings.put(inputName, new ArrayList<Binding<?>>(bindings));
    return bindings;
}

From source file:org.springframework.cloud.stream.binding.BindingService.java

@SuppressWarnings("unchecked")
public <T> Binding<T> bindProducer(T output, String outputName) {
    String bindingTarget = this.bindingServiceProperties.getBindingDestination(outputName);
    Binder<T, ?, ProducerProperties> binder = (Binder<T, ?, ProducerProperties>) getBinder(outputName,
            output.getClass());//from  www  . j  a v a 2s .com
    ProducerProperties producerProperties = this.bindingServiceProperties.getProducerProperties(outputName);
    if (binder instanceof ExtendedPropertiesBinder) {
        Object extension = ((ExtendedPropertiesBinder) binder).getExtendedProducerProperties(outputName);
        ExtendedProducerProperties extendedProducerProperties = new ExtendedProducerProperties<>(extension);
        BeanUtils.copyProperties(producerProperties, extendedProducerProperties);
        producerProperties = extendedProducerProperties;
    }
    validate(producerProperties);
    Binding<T> binding = binder.bindProducer(bindingTarget, output, producerProperties);
    this.producerBindings.put(outputName, binding);
    return binding;
}

From source file:org.springframework.cloud.stream.binding.ChannelBindingService.java

@SuppressWarnings("unchecked")
public Collection<Binding<MessageChannel>> bindConsumer(MessageChannel inputChannel, String inputChannelName) {
    String channelBindingTarget = this.channelBindingServiceProperties.getBindingDestination(inputChannelName);
    String[] channelBindingTargets = StringUtils.commaDelimitedListToStringArray(channelBindingTarget);
    List<Binding<MessageChannel>> bindings = new ArrayList<>();
    Binder<MessageChannel, ConsumerProperties, ?> binder = (Binder<MessageChannel, ConsumerProperties, ?>) getBinderForChannel(
            inputChannelName);/*w w w  .j a  va 2s  .  c  o m*/
    ConsumerProperties consumerProperties = this.channelBindingServiceProperties
            .getConsumerProperties(inputChannelName);
    if (binder instanceof ExtendedPropertiesBinder) {
        Object extension = ((ExtendedPropertiesBinder) binder).getExtendedConsumerProperties(inputChannelName);
        ExtendedConsumerProperties extendedConsumerProperties = new ExtendedConsumerProperties(extension);
        BeanUtils.copyProperties(consumerProperties, extendedConsumerProperties);
        consumerProperties = extendedConsumerProperties;
    }
    validate(consumerProperties);
    for (String target : channelBindingTargets) {
        Binding<MessageChannel> binding = binder.bindConsumer(target,
                channelBindingServiceProperties.getGroup(inputChannelName), inputChannel, consumerProperties);
        bindings.add(binding);
    }
    this.consumerBindings.put(inputChannelName, bindings);
    return bindings;
}

From source file:org.springframework.cloud.stream.binding.ChannelBindingService.java

@SuppressWarnings("unchecked")
public Binding<MessageChannel> bindProducer(MessageChannel outputChannel, String outputChannelName) {
    String channelBindingTarget = this.channelBindingServiceProperties.getBindingDestination(outputChannelName);
    Binder<MessageChannel, ?, ProducerProperties> binder = (Binder<MessageChannel, ?, ProducerProperties>) getBinderForChannel(
            outputChannelName);//w  w w.  j  av  a2s . com
    ProducerProperties producerProperties = this.channelBindingServiceProperties
            .getProducerProperties(outputChannelName);
    if (binder instanceof ExtendedPropertiesBinder) {
        Object extension = ((ExtendedPropertiesBinder) binder).getExtendedProducerProperties(outputChannelName);
        ExtendedProducerProperties extendedProducerProperties = new ExtendedProducerProperties<>(extension);
        BeanUtils.copyProperties(producerProperties, extendedProducerProperties);
        producerProperties = extendedProducerProperties;
    }
    validate(producerProperties);
    Binding<MessageChannel> binding = binder.bindProducer(channelBindingTarget, outputChannel,
            producerProperties);
    this.producerBindings.put(outputChannelName, binding);
    return binding;
}

From source file:org.springframework.cloud.stream.config.BindingServiceProperties.java

public BindingProperties getBindingProperties(String bindingName) {
    BindingProperties bindingProperties = new BindingProperties();
    if (this.bindings.containsKey(bindingName)) {
        BeanUtils.copyProperties(this.bindings.get(bindingName), bindingProperties);
    }/*from ww  w .j  a v  a  2s  . co  m*/
    if (bindingProperties.getDestination() == null) {
        bindingProperties.setDestination(bindingName);
    }
    return bindingProperties;
}

From source file:org.springframework.cloud.stream.config.ChannelBindingServiceProperties.java

public BindingProperties getBindingProperties(String channelName) {
    BindingProperties bindingProperties = new BindingProperties();
    if (this.bindings.containsKey(channelName)) {
        BeanUtils.copyProperties(this.bindings.get(channelName), bindingProperties);
    }/*  w  w w.  j a v  a  2  s .  c o  m*/
    if (bindingProperties.getDestination() == null) {
        bindingProperties.setDestination(channelName);
    }
    return bindingProperties;
}