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:technology.tikal.customers.model.contact.ContactOfy.java

@Override
public void update(Contact source) {
    if (source == null) {
        throw new IllegalArgumentException("no se puede actualizar a partir de un null");
    }/*w w w. j  a v a  2  s. c  o m*/
    BeanUtils.copyProperties(source, this);
    if (this.infoRef != null && this.infoRef.get() != null) {
        this.infoRef.get().update(source);
    } else {
        this.transientInfo = new ContactInfoOfy(this, source);
    }
}

From source file:org.excalibur.client.commands.DeployCommandOptions.java

public Requirements getRequirements() {
    Requirements requirements = new Requirements();
    BeanUtils.copyProperties(this, requirements);

    return requirements;
}

From source file:com.seachangesimulations.platform.domain.Plugin.java

/**
 * Returns a copy of the plugin passed in, and all objects associated with
 * it./*  w  w  w. java2 s  .  c  om*/
 * 
 * @param originalPluginId
 * @return
 */
public static Plugin getPluginCopyForRoleplay(Long rpId, Long originalPluginId) {

    Plugin originalPlugin = new Plugin().getById(originalPluginId);

    Plugin newPlugin = new Plugin();

    BeanUtils.copyProperties(originalPlugin, newPlugin);

    newPlugin.setId(null);
    newPlugin.setVersion(null);
    newPlugin.setCustomized(true);
    newPlugin.save();
    System.out.println("id is " + originalPlugin.getId());

    // Get base list of objects associated with this plugin.
    List<PluginObjectAssociation> poas = new PluginObjectAssociation().getAllForPlugin(originalPlugin.getId(),
            null, null);

    for (PluginObjectAssociation poa : poas) {
        System.out.println(poa.getObjectType());

        BasePluginObject bpo = null;
        String newObjectType = null;

        if (PluginObjectDocument.class.getCanonicalName().equalsIgnoreCase(poa.getObjectType())) {

            bpo = getDocumentCopy(poa.getObjectId(), rpId);
            newObjectType = PluginObjectDocument.class.getCanonicalName();

        }

        /* Create and save the new association */
        PluginObjectAssociation newPoa = new PluginObjectAssociation();
        newPoa.setPluginId(newPlugin.getId());
        newPoa.setRpId(rpId);
        newPoa.setObjectIndex(poa.getObjectIndex());
        newPoa.setObjectName(poa.getObjectName());
        newPoa.setObjectId(bpo.getId());
        newPoa.setObjectType(newObjectType);
        newPoa.setAssociationType(PluginObjectAssociation.RP_PLUGIN_ASSOCIATION);

        newPoa.save();
    }

    return newPlugin;

}

From source file:com.hybris.integration.service.tmall.impl.RefundServiceImpl.java

@Override
public Boolean returngoodsAgree(String integrationId, ReturngoodsAgreeRequest request)
        throws ApiException, TmallAppException {
    RpReturngoodsAgreeRequest req = new RpReturngoodsAgreeRequest();
    BeanUtils.copyProperties(request, req);
    RpReturngoodsAgreeResponse response = getClient(integrationId).execute(req, getToken(integrationId));

    if (response != null && !StringUtils.isEmpty(response.getErrorCode())) {
        response = getClient(integrationId).execute(req, getToken(integrationId));

        if (response != null && !StringUtils.isEmpty(response.getErrorCode())) {
            LOGGER.error("Tmall API taobao.rp.returngoods.agree failed request:" + response.getBody());
            throw new TmallAppException(ResponseCode.REQUEST_TMALL_ERROR.getCode(), response.getSubMsg());
        }/*from   w  w w . j a  v a  2 s. c  om*/
    }
    return response.isSuccess();
}

From source file:org.mybatisorm.EntityManager.java

/**
 * object? null?  field?  AND  where ? ?  ?? 1 row select ?,
 * parameter ?? ? setting .//w ww. j  a v a  2 s.  c o  m
 * 
 * @param parameter
 * @return select   true,  false
 */
public boolean load(Object parameter) {
    Object result = get(parameter);
    if (result != null) {
        BeanUtils.copyProperties(result, parameter);
        return true;
    }
    return false;
}

From source file:com.expedia.seiso.domain.entity.ItemTests.java

private void exerciseEquals(Object item) {
    log.trace("Exercising equals()");

    // The following is legitimate testing, as opposed to simple coverage grabs.
    assertTrue(item.equals(item));/*from   w  ww  . ja v  a  2  s.c o  m*/

    val copy = BeanUtils.instantiate(item.getClass());
    // FIXME This is true when we don't set anything on the POJO. [WLW]
    assertFalse(item.equals(copy));

    BeanUtils.copyProperties(item, copy);
    assertTrue(item.equals(copy));

    assertFalse(item.equals(null));
    assertFalse(item.equals("dlafkjs"));
}

From source file:com.iselect.kernal.pageflow.service.PageFlowServiceImpl.java

private PageRequestDto convertRequestModelToDto(PageRequestModel requestModel) {
    if (requestModel == null) {
        return null;
    }//from w  ww .jav a 2  s.  co m
    PageRequestDto requestDto = dtoFactory.createPageRequest();
    BeanUtils.copyProperties(requestModel, requestDto);
    List<PageResponseModel> responseModels = requestModel.getPageResponses();
    for (PageResponseModel responseModel : responseModels) {
        PageResponseDto responseDto = dtoFactory.createPageResponse();
        BeanUtils.copyProperties(responseModel, responseDto);
    }
    return requestDto;
}

From source file:com.seachangesimulations.platform.domain.Plugin.java

private static BasePluginObject getDocumentCopy(Long podId, Long rpId) {

    PluginObjectDocument pod = new PluginObjectDocument().getById(podId);

    PluginObjectDocument newPod = new PluginObjectDocument();

    try {//ww w  .j a  va 2  s  . c  o  m
        BeanUtils.copyProperties(pod, newPod);
    } catch (Exception e) {
        e.printStackTrace();
    }
    newPod.setRoleplayId(rpId);
    newPod.setId(null);
    newPod.setVersion(null);
    newPod.save();

    return newPod;
}

From source file:org.agatom.springatom.cmp.wizards.data.result.WizardResult.java

public WizardResult merge(final WizardResult localResult) {
    BeanUtils.copyProperties(localResult, this);
    return this;
}

From source file:com.jeans.iservlet.service.rest.impl.SoftwareRestServiceImpl.java

@Override
@Transactional/*from w  w  w.  j a  v  a  2  s .co m*/
public SoftwareResource[] update(SoftwareResource resource) {
    SoftwareResource[] updates = new SoftwareResource[2];
    if (resource.getId() < 0) {
        updates[UPDATED] = ResourceFactory.createEmptyResource(SoftwareResource.class);
        updates[ORIGIN] = ResourceFactory.createEmptyResource(SoftwareResource.class);
        BeanUtils.copyProperties(resource, updates[UPDATED]);
        BeanUtils.copyProperties(resource, updates[ORIGIN]);
        updates[UPDATED].setId(0);
    } else {
        Software sw = swDao.getById(Software.class, resource.getId());
        if (null != sw && sw.getState() != AssetConstants.DISUSE) {
            AssetChangeLog acl = new AssetChangeLog(sw, sw.getState(), sw.getState(), getRequest());
            updates[ORIGIN] = ResourceFactory.createResource(Software.class, SoftwareResource.class, sw);
            // 1. name?
            if (!StringUtils.isBlank(resource.getName())) {
                sw.setName(StringUtils.left(StringUtils.trimToEmpty(resource.getName()), 32));
            }
            // 2. catalog?
            byte catalog = resource.getCatalog();
            if ((catalog >= AssetConstants.OPERATING_SYSTEM_SOFTWARE
                    && catalog <= AssetConstants.APPLICATION_SOFTWARE)
                    || catalog == AssetConstants.OTHER_SOFTWARE) {
                sw.setCatalog(catalog);
            }
            // 3. vender[32], modelOrVersion[64], assetUsage[255], comment[255], license[64], null?
            if (null != resource.getVendor()) {
                sw.setVendor(StringUtils.left(StringUtils.trimToEmpty(resource.getVendor()), 32));
            }
            if (null != resource.getModelOrVersion()) {
                sw.setModelOrVersion(
                        StringUtils.left(StringUtils.trimToEmpty(resource.getModelOrVersion()), 64));
            }
            if (null != resource.getAssetUsage()) {
                sw.setAssetUsage(StringUtils.left(StringUtils.trimToEmpty(resource.getAssetUsage()), 255));
            }
            if (null != resource.getComment()) {
                sw.setComment(StringUtils.left(StringUtils.trimToEmpty(resource.getComment()), 255));
            }
            if (null != resource.getLicense()) {
                sw.setLicense(StringUtils.left(StringUtils.trimToEmpty(resource.getLicense()), 64));
            }
            // 4. purchaseTimenull?
            if (null != resource.getPurchaseTime()) {
                sw.setPurchaseTime(resource.getPurchaseTime());
            }
            // 5. quantity?0?
            if (resource.getQuantity() > 0) {
                sw.setQuantity(resource.getQuantity());
            }
            // 6. costnull?0?
            if (null != resource.getCost() && resource.getCost().doubleValue() >= 0) {
                sw.setCost(resource.getCost());
            }
            // 7. state0=, 1=, 3=
            byte state = resource.getState();
            if (state == AssetConstants.IN_USE || state == AssetConstants.IDLE
                    || state == AssetConstants.DISUSE) {
                acl.setNewState(state);
                sw.setState(state);
            }
            // 8. softwareType?
            byte softwareType = resource.getSoftwareType();
            if (softwareType >= AssetConstants.COMMERCIAL_SOFTWARE
                    && softwareType <= AssetConstants.OTHER_TYPE_SOFTWARE) {
                sw.setSoftwareType(softwareType);
            }
            // 9. expiredTimenull?
            if (null != resource.getExpiredTime()) {
                sw.setExpiredTime(resource.getExpiredTime());
            }
            swDao.update(sw);
            if (acl.isValid()) {
                aclDao.save(acl);
            }
            updates[UPDATED] = ResourceFactory.createResource(Software.class, SoftwareResource.class, sw);
        }
    }
    return updates;
}