Example usage for org.apache.commons.beanutils PropertyUtils copyProperties

List of usage examples for org.apache.commons.beanutils PropertyUtils copyProperties

Introduction

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

Prototype

public static void copyProperties(Object dest, Object orig)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException 

Source Link

Document

Copy property values from the "origin" bean to the "destination" bean for all cases where the property names are the same (even though the actual getter and setter methods might have been customized via BeanInfo classes).

For more details see PropertyUtilsBean.

Usage

From source file:com.jada.admin.customAttribute.CustomAttributeGroupMaintAction.java

public ActionForward create(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Throwable {

    CustomAttributeGroupMaintActionForm form = (CustomAttributeGroupMaintActionForm) actionForm;
    Site site = getAdminBean(request).getSite();
    initSiteProfiles(form, site);//from   w  w  w .ja v  a  2  s .  c  o m
    CustomAttributeGroup customAttributeGroup = new CustomAttributeGroup();
    PropertyUtils.copyProperties(form, customAttributeGroup);
    form.setMode("C");

    FormUtils.setFormDisplayMode(request, form, FormUtils.CREATE_MODE);
    ActionForward actionForward = actionMapping.findForward("success");
    return actionForward;
}

From source file:com.npower.dm.setup.task.digester.ModelFamilyItemObjectCreationFactory.java

public Object createObject(Attributes attributes) throws Exception {
    ModelFamilyItem result = new ModelFamilyItem();
    String parentID = attributes.getValue("parent");
    if (StringUtils.isNotEmpty(parentID)) {
        parentID = parentID.trim();/*ww  w . j  av a 2 s . c o  m*/
        ModelFamilyManager manager = ModelFamilyManager.getInstance();
        ModelFamilyItem family = manager.findModelFamily(parentID);
        if (family != null) {
            PropertyUtils.copyProperties(result, family);

            List<String> cpTemplatesFiles = new ArrayList<String>();
            cpTemplatesFiles.addAll(family.getCpTemplatesFiles());
            result.setCpTemplatesFiles(cpTemplatesFiles);

            List<String> ddfFiles = new ArrayList<String>();
            ddfFiles.addAll(family.getDdfFiles());
            result.setDdfFiles(ddfFiles);

            List<FirmwareItem> firmwares = new ArrayList<FirmwareItem>();
            firmwares.addAll(family.getFirmwares());
            result.setFirmwares(firmwares);

            List<String> profileMappingFiles = new ArrayList<String>();
            profileMappingFiles.addAll(family.getProfileMappingFiles());
            result.setProfileMappingFiles(profileMappingFiles);

            Map<String, String> specifications = new LinkedHashMap<String, String>();
            specifications.putAll(family.getSpecifications());
            result.setSpecifications(specifications);

            List<String> tacs = new ArrayList<String>();
            tacs.addAll(family.getTacs());
            result.setTacs(tacs);

        }
        result.setParentID(parentID);
    }
    return result;
}

From source file:com.jada.admin.contactus.ContactUsMaintAction.java

public ActionForward create(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Throwable {

    AdminBean adminBean = getAdminBean(request);
    Site site = adminBean.getSite();//from  w  w w . j ava 2  s .  c  o m
    ContactUsMaintActionForm form = (ContactUsMaintActionForm) actionForm;
    initSiteProfiles(form, site);
    ContactUs contactUs = new ContactUs();
    PropertyUtils.copyProperties(form, contactUs);
    form.setMode("C");
    form.setActive(String.valueOf(Constants.ACTIVE_YES));
    initSearchInfo(form, site.getSiteId());

    FormUtils.setFormDisplayMode(request, form, FormUtils.CREATE_MODE);
    ActionForward actionForward = actionMapping.findForward("success");
    return actionForward;
}

From source file:com.npower.dm.setup.task.digester.ModelItemObjectCreationFactory.java

public Object createObject(Attributes attributes) throws Exception {
    ModelItem result = new ModelItem();

    String familyID = attributes.getValue("family");
    if (StringUtils.isNotEmpty(familyID)) {
        familyID = familyID.trim();/*w  ww.j  a  va 2 s  .c om*/
        ModelFamilyManager manager = ModelFamilyManager.getInstance();
        ModelFamilyItem family = manager.findModelFamily(familyID);
        if (family != null) {
            PropertyUtils.copyProperties(result, family);

            List<String> cpTemplatesFiles = new ArrayList<String>();
            cpTemplatesFiles.addAll(family.getCpTemplatesFiles());
            result.setCpTemplatesFiles(cpTemplatesFiles);

            List<String> ddfFiles = new ArrayList<String>();
            ddfFiles.addAll(family.getDdfFiles());
            result.setDdfFiles(ddfFiles);

            List<FirmwareItem> firmwares = new ArrayList<FirmwareItem>();
            firmwares.addAll(family.getFirmwares());
            result.setFirmwares(firmwares);

            List<String> profileMappingFiles = new ArrayList<String>();
            profileMappingFiles.addAll(family.getProfileMappingFiles());
            result.setProfileMappingFiles(profileMappingFiles);

            Map<String, String> specifications = new LinkedHashMap<String, String>();
            specifications.putAll(family.getSpecifications());
            result.setSpecifications(specifications);

            List<String> tacs = new ArrayList<String>();
            tacs.addAll(family.getTacs());
            result.setTacs(tacs);
        }
        result.setFamilyID(familyID);
    }
    return result;
}

From source file:com.bdx.rainbow.mapp.action.YZ0002Action.java

@Override
public void doAction(YZ0002Request request, YZ0002Response response)
        throws BusinessException, SystemException, Exception {
    /**// w  w  w . j  a va2s.com
    Drc drc = null;
            
    if(StringUtils.isBlank(request.getCode()) == false)
    {
       if(StringUtil.isBlank(request.getCode()))
    throw new Exception("???");
               
       drc = drugService.selectDrcByCode(request.getCode());
               
       if(drc == null)
       {
    drc = drugService.findDrcFromCFDA(request.getCode());
       }
               
    }
            
    if(drc != null)
    {
               
       PropertyUtils.copyProperties(response, drc);
       try{
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    long expiryDate = sdf.parse(drc.getExpiryDate()).getTime();
    response.setIfExpiry((System.currentTimeMillis()>expiryDate));
       }
       catch(Exception e)
       {
    log.debug("");
       }
    }
    */

    TBasicSkuItem drc = null;

    if (StringUtils.isBlank(request.getCode()) == false) {
        if (StringUtil.isBlank(request.getCode()))
            throw new Exception("???");

        drc = medicineService.selectDrcByCode(request.getCode());

        if (drc == null) {
            drc = medicineService.findDrcFromCFDA(request.getCode());
        }

    }

    if (drc != null) {
        PropertyUtils.copyProperties(response, drc);
        response.setLicenseNumber(drc.getApprovalNum());
        response.setLastTime(drc.getLastFlowTime());
        response.setFlow(drc.getLastFlow());
        response.setTitle(drc.getItemName());
        response.setPrepnType(drc.getForm());
        response.setPrepnUnit(drc.getFormUnit());
        response.setProductionBatch(drc.getBatchNo());
        response.setStatus(drc.getFlow());
        response.setJgmCode(drc.getItemBarcode());
        response.setManufacturer(drc.getManufactory());
        response.setExpiryDate(drc.getExpireDate());
        response.setSpecifications(drc.getSpec());

        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            long expiryDate = sdf.parse(drc.getExpireDate()).getTime();
            response.setIfExpiry((System.currentTimeMillis() > expiryDate));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

From source file:br.gov.jfrj.siga.cp.bl.CpBL.java

public CpIdentidade alterarIdentidade(CpIdentidade ident, Date dtExpiracao, CpIdentidade identidadeCadastrante)
        throws AplicacaoException {
    try {/*from   w w w  .  j a  v  a  2  s.  c o  m*/
        Date dt = dao().consultarDataEHoraDoServidor();
        CpIdentidade idNova = new CpIdentidade();
        try {
            PropertyUtils.copyProperties(idNova, ident);
        } catch (Exception e) {
            throw new AplicacaoException("Erro ao copiar as propriedades da identidade anterior.");
        }
        idNova.setIdIdentidade(null);
        idNova.setDtExpiracaoIdentidade(dtExpiracao);

        dao().iniciarTransacao();
        CpIdentidade id = (CpIdentidade) dao().gravarComHistorico(idNova, ident, dt, identidadeCadastrante);
        dao().commitTransacao();
        return id;
    } catch (Exception e) {
        dao().rollbackTransacao();
        throw new AplicacaoException("No foi possvel cancelar a identidade.", 9, e);
    }
}

From source file:com.glaf.base.modules.sys.springmvc.SysSchedulerController.java

@RequestMapping(params = "method=saveModify")
public ModelAndView saveModify(HttpServletRequest request, ModelMap modelMap, SchedulerFormBean schedulerForm) {
    Scheduler scheduler = new SchedulerEntity();

    Map<String, Object> params = RequestUtils.getParameterMap(request);
    logger.debug(params);/*from   w  w w. java2  s . com*/
    try {
        PropertyUtils.copyProperties(scheduler, schedulerForm);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    Date startDate = ParamUtil.getDate(params, "startDate");
    Date endDate = ParamUtil.getDate(params, "endDate");
    scheduler.setStartDate(startDate);
    scheduler.setEndDate(endDate);
    if (StringUtils.isNotEmpty(scheduler.getJobClass())) {
        try {
            Class<?> clazz = Class.forName(scheduler.getJobClass());
            Object object = clazz.newInstance();
            if (!(object instanceof org.quartz.Job)) {

            }
        } catch (Exception ex) {
            logger.debug(ex);
        }
    }

    SysUser user = RequestUtil.getLoginUser(request);
    String actorId = user.getAccount();
    scheduler.setCreateBy(actorId);
    sysSchedulerService.save(scheduler);

    return this.showList(request, modelMap);
}

From source file:com.bdx.rainbow.service.basic.impl.EnterpriseService.java

@Override
public Map<String, Object> getEnterpriseInfos(DubboEnterpriseInfo condition, Integer start, Integer limit)
        throws Exception {
    TBasicEnterpriseInfoExample where = convertCondition(condition);
    if (start >= 0 && limit > 0) {
        where.setLimitClauseStart(start);
        where.setLimitClauseCount(limit);
    }// w  ww  . j av  a  2s . c o  m
    where.setOrderByClause("CREATE_TIME desc");
    List<TBasicEnterpriseInfo> list = tBasicEnterpriseInfoMapper.selectByExample(where);
    List<DubboEnterpriseInfo> dubboList = null;
    DubboEnterpriseInfo dubboEnterpriseInfo = null;
    int total = tBasicEnterpriseInfoMapper.countByExample(where);
    if (list != null && list.size() != 0) {
        dubboList = new ArrayList<DubboEnterpriseInfo>(list.size());
        for (TBasicEnterpriseInfo enterpriseInfo : list) {
            dubboEnterpriseInfo = new DubboEnterpriseInfo();
            PropertyUtils.copyProperties(dubboEnterpriseInfo, enterpriseInfo);
            dubboList.add(dubboEnterpriseInfo);
        }
    }

    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put("list", dubboList);
    resultMap.put("total", total);
    return resultMap;
}

From source file:com.glweb.module.member.MembershipManager.java

/**
 * @param  User/*from  w w  w.  j  a  va2 s  .co m*/
 * @return true/false
 */
public User updateUser(User newUser) {
    User _user = null;

    try {
        _user = getUser(newUser.getId());

        PropertyUtils.copyProperties(_user, newUser);

        _user.setLastModifiedDate(new Date());
        getUserDAO().updateUser(_user);
    } catch (GLWebPersistenceException e) {
        getLogger().error(e.getMessage(), e);
        return null;
    } catch (Exception e) {
        getLogger().error(e.getMessage(), e);
        return null;
    }

    return getUser(newUser.getId());
}

From source file:com.bstek.dorado.view.loader.PackagesConfigParser.java

protected void neatenPackagesConfig(PackagesConfig packagesConfig) throws Exception {
    Map<String, Pattern> patterns = packagesConfig.getPatterns();
    Map<String, Pattern> patternMap = new HashMap<String, Pattern>();
    for (Package pkg : packagesConfig.getPackages().values()) {
        Pattern pattern = null;/*  w w  w .jav a2s .c om*/
        String patternName = pkg.getPattern(), baseUri = pkg.getBaseUri(), patternBaseUri = null;
        if (StringUtils.isNotEmpty(patternName)) {
            pattern = patterns.get(patternName);
            if (pattern != null) {
                patternBaseUri = pattern.getBaseUri();

                if (pattern != null && baseUri != null && !baseUri.equals(patternBaseUri)) {
                    String key = patternName + '$' + baseUri;
                    Pattern pattern2 = patternMap.get(key);
                    if (pattern2 == null) {
                        String newPatternName;
                        int i = 2;
                        do {
                            newPatternName = pattern.getName() + '$' + i;
                            i++;
                        } while (patterns.containsKey(newPatternName));

                        pattern2 = new Pattern(newPatternName);
                        PropertyUtils.copyProperties(pattern2, pattern);
                        pattern2.setBaseUri(baseUri);
                        patternMap.put(key, pattern2);
                        patterns.put(newPatternName, pattern2);
                    }
                    pkg.setPattern(pattern2.getName());
                }
            }
        }
    }
}