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:mx.edu.um.mateo.inventario.dao.impl.FacturaAlmacenDaoHibernate.java

private void audita(FacturaAlmacen factura, Usuario usuario, String actividad, Date fecha) {
    XFacturaAlmacen xfactura = new XFacturaAlmacen();
    BeanUtils.copyProperties(factura, xfactura);
    xfactura.setId(null);/* w ww  .  j  a v  a2 s . c om*/
    xfactura.setFacturaAlmacenId(factura.getId());
    xfactura.setAlmacenId(factura.getAlmacen().getId());
    xfactura.setClienteId(factura.getCliente().getId());
    xfactura.setEstatusId(factura.getEstatus().getId());
    xfactura.setFechaCreacion(fecha);
    xfactura.setActividad(actividad);
    xfactura.setCreador((usuario != null) ? usuario.getUsername() : "sistema");
    currentSession().save(xfactura);
}

From source file:org.syncope.core.workflow.ActivitiUserWorkflowAdapter.java

private WorkflowFormTO getFormTO(final Task task, final TaskFormData formData) {

    WorkflowFormTO formTO = new WorkflowFormTO();
    formTO.setTaskId(task.getId());//from w ww  .j  ava  2s. c o  m
    formTO.setKey(formData.getFormKey());

    BeanUtils.copyProperties(task, formTO);

    WorkflowFormPropertyTO propertyTO;
    for (FormProperty fProp : formData.getFormProperties()) {
        propertyTO = new WorkflowFormPropertyTO();
        BeanUtils.copyProperties(fProp, propertyTO, PROPERTY_IGNORE_PROPS);
        propertyTO.setType(fromActivitiFormType(fProp.getType()));

        if (propertyTO.getType() == WorkflowFormPropertyType.Date) {
            propertyTO.setDatePattern((String) fProp.getType().getInformation("datePattern"));
        }
        if (propertyTO.getType() == WorkflowFormPropertyType.Enum) {
            propertyTO.setEnumValues((Map<String, String>) fProp.getType().getInformation("values"));
        }

        formTO.addProperty(propertyTO);
    }

    return formTO;
}

From source file:mx.edu.um.mateo.inventario.dao.impl.FacturaAlmacenDaoHibernate.java

private void audita(Salida salida, Usuario usuario, String actividad, Date fecha) {
    XSalida xsalida = new XSalida();
    BeanUtils.copyProperties(salida, xsalida);
    xsalida.setId(null);//from w w  w .  j a  va  2 s  . co m
    xsalida.setSalidaId(salida.getId());
    xsalida.setAlmacenId(salida.getAlmacen().getId());
    xsalida.setClienteId(salida.getCliente().getId());
    xsalida.setEstatusId(salida.getEstatus().getId());
    xsalida.setFechaCreacion(fecha);
    xsalida.setActividad(actividad);
    xsalida.setCreador((usuario != null) ? usuario.getUsername() : "sistema");
    currentSession().save(xsalida);
}

From source file:mx.edu.um.mateo.inventario.dao.impl.FacturaAlmacenDaoHibernate.java

private void audita(Entrada entrada, Usuario usuario, String actividad, Date fecha) {
    XEntrada xentrada = new XEntrada();
    BeanUtils.copyProperties(entrada, xentrada);
    xentrada.setId(null);// w  w w . j av  a2  s. c  om
    xentrada.setEntradaId(entrada.getId());
    xentrada.setProveedorId(entrada.getProveedor().getId());
    xentrada.setEstatusId(entrada.getEstatus().getId());
    xentrada.setAlmacenId(entrada.getAlmacen().getId());
    xentrada.setFechaCreacion(fecha);
    xentrada.setActividad(actividad);
    xentrada.setCreador((usuario != null) ? usuario.getUsername() : "sistema");
    currentSession().save(xentrada);
}

From source file:com.oneops.controller.cms.CMSClient.java

/**
 * Update dpmt state./*from   w w  w.  j  a v  a 2s.c om*/
 *
 * @param exec     the exec
 * @param dpmt     the dpmt
 * @param newState the new state
 * @throws InterruptedException
 */
public void updateDpmtState(DelegateExecution exec, CmsDeployment dpmt, String newState) {

    if (dpmt.getDeploymentState().equalsIgnoreCase("active")) {
        CmsDeployment clone = new CmsDeployment();
        BeanUtils.copyProperties(dpmt, clone);
        dpmt = clone; // Need to clone dpmt before setting the state, otherwise mybatis pulls the same instance that doesn't reflect actual db state
        long failedWos = 0;
        try {
            failedWos = cmsDpmtProcessor.getDeploymentRecordCount(dpmt.getDeploymentId(), "failed", null);
        } finally {
            if (failedWos > 0) {
                clone.setDeploymentState(FAILED);
            } else {
                clone.setDeploymentState(COMPLETE);
            }
        }
    }
    // lets do the retries here
    logger.info("Client: put:update deployment " + dpmt.getDeploymentId() + " state to "
            + dpmt.getDeploymentState());

    try {
        dpmt.setFlagsToNull();
        cmsDpmtProcessor.updateDeployment(dpmt);
        deploymentNotifier.sendDpmtNotification(dpmt);
    } catch (CmsBaseException e) {
        logger.error("CmsBaseException in updateDeployment", e);
        e.printStackTrace();
        throw e;
    }
}

From source file:au.org.ala.biocache.dao.SearchDAOImpl.java

@Override
public SearchResultDTO findByFulltextSpatialQuery(SpatialSearchRequestParams searchParams,
        boolean includeSensitive, Map<String, String[]> extraParams) {
    SearchResultDTO searchResults = new SearchResultDTO();
    SpatialSearchRequestParams original = new SpatialSearchRequestParams();
    BeanUtils.copyProperties(searchParams, original);
    try {//from   w  w  w.j a v  a 2  s  .c om
        //String queryString = formatSearchQuery(query);            
        formatSearchQuery(searchParams);
        //add context information
        updateQueryContext(searchParams);
        String queryString = buildSpatialQueryString(searchParams);
        //logger.debug("The spatial query " + queryString);
        SolrQuery solrQuery = initSolrQuery(searchParams, true, extraParams); // general search settings
        solrQuery.setQuery(queryString);

        QueryResponse qr = runSolrQuery(solrQuery, searchParams);
        //need to set the original q to the processed value so that we remove the wkt etc that is added from paramcache object
        Class resultClass = includeSensitive ? au.org.ala.biocache.dto.SensitiveOccurrenceIndex.class
                : OccurrenceIndex.class;
        searchResults = processSolrResponse(original, qr, solrQuery, resultClass);
        searchResults.setQueryTitle(searchParams.getDisplayString());
        searchResults.setUrlParameters(original.getUrlParams());
        //now update the fq display map...
        searchResults.setActiveFacetMap(searchUtils.addFacetMap(searchParams.getFq(), getAuthIndexFields()));

        logger.info("spatial search query: " + queryString);
    } catch (Exception ex) {
        logger.error("Error executing query with requestParams: " + searchParams.toString() + " EXCEPTION: "
                + ex.getMessage());
        searchResults.setStatus("ERROR"); // TODO also set a message field on this bean with the error message(?)
        searchResults.setErrorMessage(ex.getMessage());
    }

    return searchResults;
}

From source file:de.ingrid.interfaces.csw.admin.EditIBusHarvesterController.java

@RequestMapping(value = TEMPLATE_EDIT_HARVESTER_4, method = RequestMethod.POST)
public String step4Post(final HttpServletRequest request, final HttpSession session, final ModelMap modelMap,
        @ModelAttribute("harvester") final IBusHarvesterCommandObject harvester,
        @ModelAttribute("rd") final RequestDefinition rd, final Errors errors) throws Exception {

    if (WebUtils.hasSubmitParameter(request, "back")) {
        return "redirect:" + TEMPLATE_EDIT_HARVESTER_3;
    }/* w w  w  .j  av  a2  s. c  o  m*/

    if (_validatorStep4.validate(errors).hasErrors()) {
        return "/edit_ibus_harvester_4";
    }

    for (RequestDefinition def : harvester.getRequestDefinitions()) {
        if (def.getPlugId().equals(rd.getPlugId())) {
            BeanUtils.copyProperties(rd, def);
            break;
        }
    }

    updateAndSaveConfiguration((HarvesterConfiguration) harvester);

    return "redirect:" + TEMPLATE_EDIT_HARVESTER_3;
}

From source file:com.jeans.iservlet.service.asset.impl.AssetServiceImpl.java

@Override
@Transactional//www .  ja  va 2  s .c o m
public int createNewAssets(Map<String, Object> props) {
    byte type = (byte) props.get("type");
    int number = (int) props.get("number");
    Asset prototype = Asset.createAsset(props);
    Set<Serializable> ids = new HashSet<Serializable>();
    if (null != prototype) {
        if (number > 1) {
            if (prototype instanceof Hardware) {
                DecimalFormat df = new DecimalFormat("000");
                String prototypeCode = ((Hardware) prototype).getCode();
                for (int n = 1; n <= number; n++) {
                    Hardware hw = new Hardware();
                    BeanUtils.copyProperties(prototype, hw);
                    hw.setCode(prototypeCode + "[" + df.format(n) + "]");
                    ids.add(hwDao.save(hw));
                }
            } else {
                while (number-- > 0) {
                    Software sw = new Software();
                    BeanUtils.copyProperties(prototype, sw);
                    ids.add(swDao.save(sw));
                }
            }
        } else {
            if (type == AssetConstants.HARDWARE_ASSET) {
                ids.add(hwDao.save((Hardware) prototype));
            } else {
                ids.add(swDao.save((Software) prototype));
            }
        }
        ids.remove(null);
    }
    return ids.size();
}

From source file:com.josescalia.tumblr.form.TumblrRssFavList.java

private void btnNew2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNew2ActionPerformed
    //must deselect selected item
    setSelectedItem(null);//from  w w w  . j a  v  a2s .  c o  m
    BeanUtils.copyProperties(new Rss(), formBean);
    System.out.println(formBean);
    UIFormUtil.btnSetupConfig(UIFormUtil.ADD_MODE, pnlButton);
    UIFormUtil.isEnabledAndClearComp(true, true, panelForm);
}

From source file:com.wcna.calms.jpos.services.quote.JPOSQuickQuoteAssetLoadService.java

/***
 * This is used by the prices screen which opens from the proposal summary screen.
 * @param assetDataVo/*from  ww  w.j a va  2  s . c om*/
 * @param appId
 * @param loadMap
 * @return
 */
/////WARNING: PENDING REFACTORING TASK.....THIS METHODS NEEDS TO BE MOVED TO THE SERVICE LAYER...I DID HAVE SOME TROUBLE WHILE I DID TRY TO MOVE IT IN MY FIRST ATTEMPT..
/////CURRENTLY THE SAME CODE IS DUPLICATED IN JPOSQuickQuoteLoadService.java AND JPOSQuickQuoteAssetLoadService.java
////PLEASE DO CHANGE IN BOTH CLASSES IF ANY CHANGES ARE INTRODUCED TO THIS METHOD.

private IJPOSApplicationAssetDataVO loadAssetSubProcess(IJPOSApplicationAssetDataVO assetDataVo, String appId,
        Map<String, Object> loadMap) {

    List<IRentACarBean> rentACarList = null;
    IJPOSQuickQuoteAssetInputForm assetForm = null;
    int modelVariantId = 0;
    if (!StringUtil.isEmpty(appId)) {
        Locale locale = getUserContainer().getLocale();
        assetDataVo = quickQuoteService.loadAsset(Long.valueOf(appId), locale, false);
        rentACarList = quickQuoteService.getRentACarList(Long.valueOf(appId));

        assetForm = new JPOSQuickQuoteAssetVO();
        if (assetDataVo != null) {
            JPOSQuickQuoteAssetVO screenVo = new JPOSQuickQuoteAssetVO();
            screenVo.setNewUsed(assetDataVo.getNewOrUsed());
            screenVo.setRegistrationCode(assetDataVo.getRegPlateId());
            screenVo.setFreeFormatFlag(assetDataVo.getFreeFormatFlag());
            screenVo.setMakeId(assetDataVo.getMakeId());
            screenVo.setModelId(assetDataVo.getModelId());
            screenVo.setModelVariantId(assetDataVo.getModelVariantId());

            if (!"on".equals(screenVo.getFreeFormatFlag())) {
                if (!StringUtil.isEmpty(screenVo.getModelVariantId())) {
                    modelVariantId = formatService.parseInteger(screenVo.getModelVariantId(), locale, false, 0);
                }
            } else {
                if (!IClientConstants.EXECUTE.equals(projectProperties
                        .getProperty(IClientConstants.ONCHANGE_FFE_CHKBOX_IMPL_DISABLE_MAKE_TOGGLE))) {
                    screenVo.setMakeId(assetDataVo.getMakeDesc());
                }
                screenVo.setModelId(assetDataVo.getModelDesc());
                screenVo.setModelVariantId(assetDataVo.getModelVariantDesc());
            }

            screenVo.setTaxIncludingFlag(assetDataVo.getIsTaxable());
            screenVo.setRegistrationNumber(assetDataVo.getRegistrationNumber());
            Date d = assetDataVo.getRegistrationDate();
            if (d != null) {
                screenVo.setRegistrationDate(formatService.formatDate(d, locale));
            }

            screenVo.setAssetType(assetDataVo.getAssetType());

            Double meter = assetDataVo.getMeterValue();
            if (meter == null) {
                meter = new Double(0);
            }
            screenVo.setKilometrage(formatService.formatInteger(meter.intValue(), locale));
            screenVo.setVin(assetDataVo.getVin());

            screenVo.setManufactureDate(formatService.formatDate(assetDataVo.getManufactureDate(), locale));
            screenVo.setMortgageRegDate(formatService.formatDate(assetDataVo.getMortgageRegDate(), locale));

            screenVo.setAssetUsageCode(assetDataVo.getAssetUsageCode());
            screenVo.setApprovedUsedAssetCode(assetDataVo.getApprovedUsedAssetCode());
            screenVo.setEnviroImpactRatingCode(assetDataVo.getEnviroImpactRatingCode());
            screenVo.setEnviroImpactRatingAmount(
                    formatService.formatDouble(assetDataVo.getEnviroImpactRatingAmount(), locale));
            screenVo.setTaxHorsePowerRating(
                    formatService.formatDouble(assetDataVo.getTaxHorsePowerRating(), locale));

            screenVo.setSalePrice(formatService.formatDouble(assetDataVo.getSalePrice(), locale));
            screenVo.setTaxCode(assetDataVo.getTaxCode());
            screenVo.setTaxAmt(formatService.formatDouble(assetDataVo.getTaxAmt(), locale));
            screenVo.setGrossCost(formatService.formatDouble(assetDataVo.getGrossCost(), locale));

            screenVo.setExtraAmt(formatService.formatDouble(assetDataVo.getExtraAmount(), locale));
            screenVo.setExtraTaxCode(assetDataVo.getExtraTaxCode());
            screenVo.setExtraTaxAmt(formatService.formatDouble(assetDataVo.getExtraTaxAmount(), locale));
            screenVo.setExtraTotalCost(assetDataVo.getExtraTotalCost());

            screenVo.setTaxableDFOptionsGross(assetDataVo.getTaxableDFOptionsGross());
            screenVo.setTaxableDFOptionsNet(assetDataVo.getTaxableDFOptionsNet());
            String defaultZero = formatService.formatDouble(0d, locale);
            // this is to avoid validation issues if this is a rent-a-car deal
            if (StringUtils.isBlank(screenVo.getTaxableDFOptionsNet())) {
                screenVo.setTaxableDFOptionsNet(defaultZero);
            }
            if (StringUtils.isBlank(screenVo.getTaxableDFOptionsGross())) {
                screenVo.setTaxableDFOptionsGross(defaultZero);
            }

            screenVo.setTaxableDFOptionsVatAmt(assetDataVo.getTaxableDFOptionsVatAmt());
            screenVo.setTaxableDFOptionsVatRate(assetDataVo.getTaxableDFOptionsVatRate());

            screenVo.setNonTaxableDFOptionsGross(assetDataVo.getNonTaxableDFOptionsGross());
            screenVo.setNonTaxableDFOptionsNet(assetDataVo.getNonTaxableDFOptionsNet());
            if (StringUtils.isBlank(screenVo.getNonTaxableDFOptionsNet())) {
                screenVo.setNonTaxableDFOptionsNet(defaultZero);
            }
            if (StringUtils.isBlank(screenVo.getNonTaxableDFOptionsGross())) {
                screenVo.setNonTaxableDFOptionsGross(defaultZero);
            }

            screenVo.setNonTaxableDFOptionsVatAmt(assetDataVo.getNonTaxableDFOptionsVatAmt());
            screenVo.setNonTaxableDFOptionsVatRate(assetDataVo.getNonTaxableDFOptionsVatRate());

            screenVo.setRoadFundLicenseGross(assetDataVo.getRoadFundLicenseGross());
            screenVo.setRoadFundLicenseNet(assetDataVo.getRoadFundLicenseNet());
            screenVo.setRoadFundLicenseVatAmt(assetDataVo.getRoadFundLicenseVatAmt());
            screenVo.setRoadFundLicenseVatRate(assetDataVo.getRoadFundLicenseVatRate());

            screenVo.setFirstRegistrationGross(assetDataVo.getFirstRegistrationGross());
            screenVo.setFirstRegistrationNet(assetDataVo.getFirstRegistrationNet());
            screenVo.setFirstRegistrationVatAmt(assetDataVo.getFirstRegistrationVatAmt());
            screenVo.setFirstRegistrationVatRate(assetDataVo.getFirstRegistrationVatRate());

            screenVo.setTotalNet(assetDataVo.getTotalNet());
            screenVo.setTotalGross(formatService.formatDouble(assetDataVo.getTotalCost(), locale));
            screenVo.setTotalVatAmt(formatService.formatDouble(assetDataVo.getTotalVat(), locale));

            screenVo.setDiscountNet(assetDataVo.getDiscountNet());
            screenVo.setDiscountVatRate(assetDataVo.getDiscountVatRate());
            screenVo.setDiscountVatAmt(assetDataVo.getDiscountVatAmt());
            screenVo.setDiscountGross(assetDataVo.getDiscountGross());

            if (IConstants.FLAG_YES.equals(assetDataVo.getDiscountAmtIsPct())) {
                screenVo.setDiscountAmtIsPct(IConstants.FLAG_YES);
            } else {
                screenVo.setDiscountAmtIsPct("");
            }

            if (assetDataVo.getDiscountAmt() != null) {
                screenVo.setDiscountAmt(assetDataVo.getDiscountAmt());
            } else {
                screenVo.setDiscountAmt("");
            }

            if (assetDataVo.getDiscountPct() != null) {
                screenVo.setDiscountPct(assetDataVo.getDiscountPct());
            } else {
                screenVo.setDiscountPct("");
            }

            screenVo.setTaxPointDate(formatService.formatDate(assetDataVo.getTaxPointDate(), locale));
            screenVo.setTaxRateValue(formatService.formatDouble(assetDataVo.getTaxRateValue(), locale));

            loadMap.put("assetDetails", screenVo);
            loadMap.put("vehicleOutline", quickQuoteService.getVehicleDescription(Long.valueOf(appId)));

            loadMap.put("rentACarList", rentACarList);

            List<IVehicleFFOBean> ffoList = assetDataVo.getFfoList();
            if (ffoList == null) {
                ffoList = new ArrayList<IVehicleFFOBean>();
            }
            loadMap.put("ffoList", ffoList);
            screenVo.setTotalRvUpliftPercentage(assetDataVo.getTotalRvUpliftPercentage());

            BeanUtils.copyProperties(screenVo, assetForm);
        }

        IAssetPartExchangeVO assetPartExchangeVO = (assetDataVo.getAssetPartExchange() == null)
                ? quickQuoteService.getDefaultPartExchange()
                : assetDataVo.getAssetPartExchange();
        this.quickQuoteService.setAssetDetailsToContainer(0, assetForm, assetDataVo.getFfoList(), rentACarList,
                assetPartExchangeVO);

    }
    return assetDataVo;
}