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.gp.cong.logisoft.struts.action.lcl.LclAesDetailsAction.java

public ActionForward editAes(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    LclAesDetailsForm lclAesDetailsForm = (LclAesDetailsForm) form;
    String fileNumber = request.getParameter("trnref");
    String aesId = request.getParameter("id");
    int id = Integer.parseInt(aesId);
    SedFilings sedFilings = new SedFilingsDAO().findById(id);
    PropertyUtils.copyProperties(lclAesDetailsForm, sedFilings);
    if (sedFilings.getStatus().equals("N")) {
        sedFilings.setStatus("New");
    } else if (sedFilings.getStatus().equals("S")) {
        sedFilings.setStatus("Sent");
    }/*from  w  w  w  .j  a va2  s.c om*/
    request.setAttribute("sedFilings", sedFilings);
    return mapping.findForward("aesDetails");
}

From source file:au.org.theark.lims.web.component.biospecimen.batchcreate.form.ManualBatchCreateBiospecimenForm.java

/**
 * /*from   w  w w .j a va  2 s.c o  m*/
 * @return the listEditor of BatchBiospecimen(s)
 */
public AbstractListEditor<BatchBiospecimenVO> buildListEditor() {
    listEditor = new AbstractListEditor<BatchBiospecimenVO>("batchBiospecimenList",
            new PropertyModel(this, "batchBiospecimenList")) {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("serial")
        @Override
        protected void onPopulateItem(final ListItem<BatchBiospecimenVO> item) {
            item.setOutputMarkupId(true);
            item.getModelObject().getBiospecimen()
                    .setLinkSubjectStudy(cpModel.getObject().getLinkSubjectStudy());
            item.getModelObject().getBiospecimen()
                    .setStudy(cpModel.getObject().getLinkSubjectStudy().getStudy());

            biospecimenUidTxtFld = new TextField<String>("biospecimen.biospecimenUid",
                    new PropertyModel(item.getModelObject(), "biospecimen.biospecimenUid"));

            initBioCollectionDdc(item);
            initSampleTypeDdc(item);

            sampleDateTxtFld = new DateTextField("biospecimen.sampleDate",
                    new PropertyModel(item.getModelObject(), "biospecimen.sampleDate"),
                    au.org.theark.core.Constants.DD_MM_YYYY);
            ArkDatePicker sampleDatePicker = new ArkDatePicker();
            sampleDatePicker.bind(sampleDateTxtFld);
            sampleDateTxtFld.add(sampleDatePicker);

            quantityTxtFld = new TextField<Double>("biospecimen.quantity",
                    new PropertyModel(item.getModelObject(), "biospecimen.quantity")) {
                private static final long serialVersionUID = 1L;

                @Override
                public <C> IConverter<C> getConverter(Class<C> type) {
                    DoubleConverter doubleConverter = new DoubleConverter();
                    NumberFormat numberFormat = NumberFormat.getInstance();
                    numberFormat.setMinimumFractionDigits(1);
                    doubleConverter.setNumberFormat(getLocale(), numberFormat);
                    return (IConverter<C>) doubleConverter;
                }
            };
            initUnitDdc(item);
            initTreatmentTypeDdc(item);

            concentrationTxtFld = new TextField<Number>("biospecimen.concentration",
                    new PropertyModel(item.getModelObject(), "biospecimen.concentration"));

            // Added onchange events to ensure model updated when any change made
            item.add(biospecimenUidTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    // Check BiospecimenUID is unique
                    String biospecimenUid = (getComponent().getDefaultModelObject().toString() != null
                            ? getComponent().getDefaultModelObject().toString()
                            : new String());
                    Biospecimen biospecimen = iLimsService.getBiospecimenByUid(biospecimenUid,
                            item.getModelObject().getBiospecimen().getStudy());
                    if (biospecimen != null && biospecimen.getId() != null) {
                        ManualBatchCreateBiospecimenForm.this
                                .error("Biospecimen UID must be unique. Please try again.");
                        target.focusComponent(getComponent());
                    }
                    target.add(feedbackPanel);
                }
            }));

            item.add(bioCollectionDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(sampleTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(sampleDateTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(quantityTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(unitDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(treatmentTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(concentrationTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));

            // Copy button allows entire row details to be copied
            item.add(new AjaxEditorButton(Constants.COPY) {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    target.add(feedbackPanel);
                }

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    BatchBiospecimenVO batchBiospecimenVo = new BatchBiospecimenVO();
                    try {
                        PropertyUtils.copyProperties(batchBiospecimenVo.getBiospecimen(),
                                item.getModelObject().getBiospecimen());
                        batchBiospecimenVo.getBiospecimen().setBiospecimenUid(new String());
                        listEditor.addItem(batchBiospecimenVo);
                        target.add(form);
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        e.printStackTrace();
                    } catch (NoSuchMethodException e) {
                        e.printStackTrace();
                    }
                }
            }.setDefaultFormProcessing(false));

            item.add(new AjaxEditorButton(Constants.DELETE) {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    target.add(feedbackPanel);
                }

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    listEditor.removeItem(item);
                    target.add(form);
                }
            }.setDefaultFormProcessing(false).setVisible(item.getIndex() > 0));

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }

    };
    return listEditor;
}

From source file:com.jada.admin.site.SiteLoader.java

public void loadCurrency() throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    String sql = "from Currency where siteId = :siteId order by currencyCode";
    Query query = em.createQuery(sql);
    query.setParameter("siteId", Constants.SITE_SYSTEM);
    Iterator<?> iterator = query.getResultList().iterator();
    while (iterator.hasNext()) {
        Currency master = (Currency) iterator.next();
        Currency currency = new Currency();
        PropertyUtils.copyProperties(currency, master);
        currency.setSite(site);/* www . java2 s .  c o  m*/
        currency.setCurrencyId(null);
        currency.setRecUpdateBy(userId);
        currency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        currency.setRecCreateBy(userId);
        currency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        em.persist(currency);
    }
}

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

@Override
public Map<String, Object> getMoreEnterpriseLicense(DubboEnterpriseLicense condition, Integer start,
        Integer limit) throws Exception {
    Map<String, Object> paramMap = new HashMap<String, Object>();
    if (condition != null) {
        if (StringUtils.isNotEmpty(condition.getOrganizationCode())) {
            paramMap.put("organizationCode", condition.getOrganizationCode());
        }//  ww  w  .j  a  va  2s.c o  m
        if (StringUtils.isNotEmpty(condition.getLicenseCode())) {
            paramMap.put("licenseCode", "%" + condition.getLicenseCode() + "%");
        }
        if (StringUtils.isNotEmpty(condition.getStatus())) {
            paramMap.put("status", condition.getStatus());
        }
        if (StringUtils.isNotEmpty(condition.getEnterpriseName())) {
            paramMap.put("enterpriseName", "%" + condition.getEnterpriseName() + "%");
        }
        if (StringUtils.isNotEmpty(condition.getLicenseCode())) {
            paramMap.put("licenseCode", "%" + condition.getLicenseCode() + "%");
        }

        if (condition.getValidDate() != null) {
            paramMap.put("validDate", condition.getValidDate());
        }
        if (condition.getInvalidDate() != null) {
            paramMap.put("invalidDate", condition.getInvalidDate());
        }

        if (condition.getInvalidDateStart() != null) {
            paramMap.put("invalidDateStart", condition.getInvalidDateStart());
        }
        if (condition.getInvalidDateEnd() != null) {
            paramMap.put("invalidDateEnd", condition.getInvalidDateEnd());
        }

        if (condition.getValidDateStart() != null) {
            paramMap.put("validDateStart", condition.getValidDateStart());
        }
        if (condition.getValidDateEnd() != null) {
            paramMap.put("validDateEnd", condition.getValidDateEnd());
        }

    }

    if (start >= 0 && limit > 0) {
        paramMap.put("limitClauseStart", start);
        paramMap.put("limitClauseCount", limit);
    }

    int total = selfEnterpriseMapper.countEnterpriseLicenses(paramMap);
    List<DubboEnterpriseLicense> list = null;
    if (total != 0) {
        List<SelfEnterpriseLicense> listSrc = selfEnterpriseMapper.getEnterpriseLicenses(paramMap);
        list = new ArrayList<DubboEnterpriseLicense>();
        DubboEnterpriseLicense enterpriseLicense = null;
        for (SelfEnterpriseLicense tmp : listSrc) {
            enterpriseLicense = new DubboEnterpriseLicense();
            PropertyUtils.copyProperties(enterpriseLicense, tmp);
            list.add(enterpriseLicense);
        }
    }

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

From source file:com.gp.cong.logisoft.struts.action.lcl.LclAesDetailsAction.java

public ActionForward editSchedB(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    LclAesDetailsForm lclAesDetailsForm = (LclAesDetailsForm) form;
    String fileNumber = request.getParameter("trnref");
    String shpdr = fileNumber.substring(0, fileNumber.indexOf('-'));
    request.setAttribute("shpdr", shpdr);
    String aesId = request.getParameter("id");
    int id = Integer.parseInt(aesId);
    SedSchedulebDetails schedB = new SedSchedulebDetailsDAO().findById(id);
    PropertyUtils.copyProperties(lclAesDetailsForm, schedB);
    request.setAttribute("schedB", schedB);
    List list = new SedSchedulebDetailsDAO().findByTrnref(fileNumber);
    request.setAttribute("schedList", list);
    request.setAttribute("sed", list.size());
    request.setAttribute("trnref", fileNumber);
    request.setAttribute("exportCodeList", new SedFilingBC().getFieldList(69, "Export Code"));
    request.setAttribute("licenseCodeList", new SedFilingBC().getFieldList(67, "License Code"));
    request.setAttribute("stateCodeList", new SedFilingBC().getFieldList(70, "Vehicle State"));
    request.setAttribute("newItemFlag", true);
    return mapping.findForward("schedBDetails");
}

From source file:com.jada.admin.site.SiteLoader.java

public void loadMenu() throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    String sql = "from Menu where siteId = :siteId order by menuSetName";
    Query query = em.createQuery(sql);
    query.setParameter("siteId", Constants.SITE_SYSTEM);
    Iterator<?> iterator = query.getResultList().iterator();
    while (iterator.hasNext()) {
        Menu master = (Menu) iterator.next();
        Menu menu = new Menu();
        PropertyUtils.copyProperties(menu, master);
        //           menu.setSite(site);
        menu.setMenuId(null);/*from ww w .j ava  2s . c  o  m*/
        menu.setRecUpdateBy(userId);
        menu.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        menu.setRecCreateBy(userId);
        menu.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        menu.setCategory(null);
        menu.setContent(null);
        menu.setItem(null);
        menu.setMenuLanguages(null);
        em.persist(menu);
    }
}

From source file:com.jada.admin.site.SiteLoader.java

public void loadTax() throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    String sql = "from Tax where siteId = :siteId";
    Query query = em.createQuery(sql);
    query.setParameter("siteId", Constants.SITE_SYSTEM);
    Iterator<?> iterator = query.getResultList().iterator();
    while (iterator.hasNext()) {
        Tax master = (Tax) iterator.next();
        Tax tax = new Tax();
        Set<Country> countries = tax.getCountries();
        Set<State> states = tax.getStates();
        PropertyUtils.copyProperties(tax, master);
        tax.setSite(site);/*from   ww  w.j a  va2 s  . c  o  m*/
        tax.setTaxId(null);
        tax.setRecUpdateBy(userId);
        tax.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        tax.setRecCreateBy(userId);
        tax.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        tax.setTaxLanguages(null);
        tax.setCountries(countries);
        tax.setStates(states);
        Iterator<?> it = null;
        if (master.getCountries() != null) {
            it = master.getCountries().iterator();
            while (it.hasNext()) {
                Country mc = (Country) it.next();
                Country country = CountryDAO.loadByCountryName(site.getSiteId(), mc.getCountryName());
                tax.getCountries().add(country);
            }
        }
        if (master.getStates() != null) {
            it = master.getStates().iterator();
            while (it.hasNext()) {
                State mc = (State) it.next();
                State state = StateDAO.loadByStateName(site.getSiteId(), mc.getStateName());
                tax.getStates().add(state);
            }
        }
        em.persist(tax);
    }
}

From source file:ec.gob.ceaaces.controller.FuncionarioController.java

private void nuevoRedirect() {
    if (funcionarioSeleccionado == null) {
        return;//from  www.jav  a 2  s.  c  o  m
    }

    this.contrataciones.clear();

    // cargarDatosIniciales();

    if (funcionarioSeleccionado.getId() == null) {
        funcionarioSeleccionado = new FuncionarioDTO();
        idPais = -99L;
    }

    if (this.funcionarioSeleccionado.getId() != null) {
        this.personaFuncionario = new PersonaDTO();

        try {
            PropertyUtils.copyProperties(personaFuncionario, funcionarioSeleccionado);
        } catch (IllegalAccessException e1) {
            e1.printStackTrace();
        } catch (InvocationTargetException e1) {
            e1.printStackTrace();
        } catch (NoSuchMethodException e1) {
            e1.printStackTrace();
        }

        cargarPaises();

        if (funcionarioSeleccionado.getIesDTO() == null) {
            personaFuncionario.setIesDTO(this.iesSeleccionada);
            funcionarioSeleccionado.setIesDTO(this.iesSeleccionada);
        }

        if (funcionarioSeleccionado.getPaisOrigen() != null) {
            idPais = funcionarioSeleccionado.getPaisOrigen().getId();
        } else {
            idPais = -99L;
        }

        if (funcionarioSeleccionado.getSedeIesDTO() != null) {
            idSedeSeleccionada = funcionarioSeleccionado.getSedeIesDTO().getId();
        }

        if (funcionarioSeleccionado.getDiscapacidad() != null) {
            discapacidad = funcionarioSeleccionado.getDiscapacidad().getValue();
        } else {
            funcionarioSeleccionado.setDiscapacidad(DiscapacidadEnum.NINGUNA);
            discapacidad = funcionarioSeleccionado.getDiscapacidad().getValue();
        }

        if (funcionarioSeleccionado.getSexo() != null) {
            genero = funcionarioSeleccionado.getSexo().getValue();
        } else {
            genero = funcionarioSeleccionado.getSexo().getValue();
        }

        if (funcionarioSeleccionado.getTipoFuncionario() != null) {
            tipoFunc = funcionarioSeleccionado.getTipoFuncionario().getValue();
        }

        if (funcionarioSeleccionado.getContratacionDTO() != null) {

            for (int i = 0; i < funcionarioSeleccionado.getContratacionDTO().size(); i++) {
                if (funcionarioSeleccionado.getContratacionDTO().get(i).getActivo()) {
                    contrataciones.add(funcionarioSeleccionado.getContratacionDTO().get(i));
                }
            }
            contrataciones.removeAll(Collections.singleton(null));
        }

    }
    activarTab();
}

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

public CpIdentidade trocarSenhaDeIdentidade(String senhaAtual, String senhaNova, String senhaConfirma,
        String nomeUsuario, CpIdentidade idCadastrante) throws NoSuchAlgorithmException, AplicacaoException {
    if (senhaAtual == null || senhaAtual.trim().length() == 0) {
        throw new AplicacaoException("Senha atual no confere");
    }/*from  w w  w  . ja  va2s. com*/
    final String hashAtual = GeraMessageDigest.executaHash(senhaAtual.getBytes(), "MD5");

    final CpIdentidade id = dao().consultaIdentidadeCadastrante(nomeUsuario, true);
    // se o usurio no existir
    if (id == null)
        throw new AplicacaoException("O usurio no est cadastrado.");

    boolean podeTrocar = id.getDscSenhaIdentidade().equals(hashAtual);

    if (!podeTrocar) {
        // tenta o modo administrador...
        String servico = "SIGA: Sistema Integrado de Gesto Administrativa;GI: Mdulo de Gesto de Identidade;DEF_SENHA: Definir Senha";
        try {
            if (Cp.getInstance().getConf().podeUtilizarServicoPorConfiguracao(idCadastrante.getDpPessoa(),
                    idCadastrante.getDpPessoa().getLotacao(), servico)) {

                if (hashAtual.equals(idCadastrante.getDscSenhaIdentidade())) {
                    podeTrocar = true;
                } else {
                    throw new AplicacaoException("Senha atual no confere");
                }

                try {
                    Correio.enviar(id.getDpPessoa().getEmailPessoaAtual(), "Troca de Senha",
                            "O Administrador do sistema alterou a senha do seguinte usurio, para efetuar "
                                    + "uma manuteno no sistema: " + "\n" + "\n - Nome: "
                                    + id.getDpPessoa().getNomePessoa() + "\n - Matricula: "
                                    + id.getDpPessoa().getSigla() + "\n - Senha: " + senhaNova
                                    + "\n\n Antes de utiliza-lo novamente, altere a sua senha "
                                    + "ou solicite uma nova atravs da opo 'esqueci minha senha'"
                                    + "\n\n Ateno: esta  uma "
                                    + "mensagem automtica. Por favor, no responda.");
                } catch (Exception e) {
                    System.out.println(
                            "Erro: No foi possvel enviar e-mail para o usurio informando que o administrador do sistema alterou sua senha."
                                    + "\n" + "\n - Nome: " + id.getDpPessoa().getNomePessoa()
                                    + "\n - Matricula: " + id.getDpPessoa().getSigla());
                }
            }
        } catch (Exception e1) {

        }
    }

    if (podeTrocar && senhaNova.equals(senhaConfirma)) {
        try {
            Date dt = dao().consultarDataEHoraDoServidor();
            CpIdentidade idNova = new CpIdentidade();
            PropertyUtils.copyProperties(idNova, id);
            idNova.setIdIdentidade(null);
            idNova.setDtCriacaoIdentidade(dt);
            final String hashNova = GeraMessageDigest.executaHash(senhaNova.getBytes(), "MD5");
            idNova.setDscSenhaIdentidade(hashNova);

            BASE64Encoder encoderBase64 = new BASE64Encoder();
            String chave = encoderBase64.encode(id.getDpPessoa().getIdInicial().toString().getBytes());
            String senhaCripto = encoderBase64.encode(Criptografia.criptografar(senhaNova, chave));
            idNova.setDscSenhaIdentidadeCripto(null);
            idNova.setDscSenhaIdentidadeCriptoSinc(null);

            dao().iniciarTransacao();
            dao().gravarComHistorico(idNova, id, dt, idCadastrante);
            dao().commitTransacao();
            return idNova;
        } catch (final Exception e) {
            dao().rollbackTransacao();
            throw new AplicacaoException("Ocorreu um erro durante a gravao", 0, e);
        }
    } else {
        throw new AplicacaoException("Senha Atual no confere e/ou Senha nova diferente de confirmao");
    }
}

From source file:com.hive.surveymanage.controller.IndustryEntityController.java

/**
 * ?/*from ww w  .j  av  a2  s  . c  o  m*/
 * @param model
 * @param productId
 * @return
 */
@RequestMapping("/viewBarcodeInfo.action")
public String viewBarcodeInfo(Model model, @RequestParam(value = "entityId") Long entityId) {
    IndustryEntity induEntity = null;
    IndustryEntityBean vo = null;
    try {
        induEntity = industryEntityService.get(entityId);
        String queryPath = SystemCommon_Constant.QRCODE_PATH;
        vo = new IndustryEntityBean();
        PropertyUtils.copyProperties(vo, induEntity);
        vo.setQueryPath(queryPath + entityId);
    } catch (Exception e) {
        e.printStackTrace();
    }
    model.addAttribute("vo", vo);
    return PREFIX + "/viewBarcode";
}