当前位置: 首页>>代码示例>>Java>>正文


Java BeanUtils.copyProperties方法代码示例

本文整理汇总了Java中org.apache.commons.beanutils.BeanUtils.copyProperties方法的典型用法代码示例。如果您正苦于以下问题:Java BeanUtils.copyProperties方法的具体用法?Java BeanUtils.copyProperties怎么用?Java BeanUtils.copyProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.beanutils.BeanUtils的用法示例。


在下文中一共展示了BeanUtils.copyProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadUserByUsername

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
@Override
public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException {

    User user = this.userService.findByName(name);
    TzUserDetails userDetails = new TzUserDetails();

    if(user == null){
        throw new UsernameNotFoundException("用户不存在");
    }

    try {
        BeanUtils.copyProperties(userDetails,user);
    } catch (Exception e) {
        e.printStackTrace();
    }

    logger.info("---->身份验证:"+userDetails.getUsername()+":"+userDetails.getPassword());

   return userDetails;
}
 
开发者ID:TZClub,项目名称:OMIPlatform,代码行数:21,代码来源:TzUserDetailsService.java

示例2: convert

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
public static List<ShopProductDto> convert(List<ShopProduct> products,ObjectMapper objectMapper) throws InvocationTargetException, IllegalAccessException {
    if (products == null) {
        return null;
    }
    List<ShopProductDto> productDtos = new ArrayList();
    for (int i = 0; i < products.size(); i++) {
        ShopProductDto tmp = new ShopProductDto();
        BeanUtils.copyProperties(tmp, products.get(i));
        try {
            /*处理图片信息转换*/
           tmp.setImgs(tmp.parseImageList(objectMapper)) ;
            /*处理基础信息转换*/
            tmp.parseBaseProperty(objectMapper);
            /*其他转换操作*/
        } catch (IOException e) {
            e.printStackTrace();
        }
        productDtos.add(tmp);
    }
    return productDtos;
}
 
开发者ID:TZClub,项目名称:OMIPlatform,代码行数:22,代码来源:ShopProductDto.java

示例3: createProxyEntity

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T extends IEntity> T createProxyEntity(T entity) throws Exception {
	EntityProxy entityProxy = createProxy(entity);
	if (entityProxy != null) {
		EntityProxyWrapper entityProxyWrapper = new EntityProxyWrapper(entityProxy);			
		AbstractEntity proxyEntity = createProxyEntity(entityProxy);
		if(proxyEntity!=null) {
			// 注入对象 数值
			BeanUtils.copyProperties(proxyEntity, entity);
			entityProxy.setCollectFlag(true);
			if(entityProxyWrapper != null) {
				proxyEntity.setEntityProxyWrapper(entityProxyWrapper);
				return (T) proxyEntity;
			}
		}
	}
	return null;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:19,代码来源:EntityProxyFactory.java

示例4: edit

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
/**
    * Edits specified LTI tool consumer
    */
   public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws Exception {

initServices();

DynaActionForm ltiConsumerForm = (DynaActionForm) form;
Integer sid = WebUtil.readIntParam(request, "sid", true);

// editing a tool consumer
if (sid != null) {
    ExtServer ltiConsumer = integrationService.getExtServer(sid);
    BeanUtils.copyProperties(ltiConsumerForm, ltiConsumer);
    String lessonFinishUrl = ltiConsumer.getLessonFinishUrl() == null ? "-" : ltiConsumer.getLessonFinishUrl();
    request.setAttribute("lessonFinishUrl", lessonFinishUrl);

// create a tool consumer
} else { 
    //do nothing
}

return mapping.findForward("ltiConsumer");	
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:LtiConsumerManagementAction.java

示例5: insertColumn

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
/**
 * 插入表新列
 * 
 * @param dbInfoId
 * @param columnInfo
 * @throws Exception
 */
public void insertColumn(String dbInfoId, ColumnInfo columnInfo) throws Exception {
	com.bstek.bdf2.core.orm.jdbc.dialect.ColumnInfo dbColumnInfo = new com.bstek.bdf2.core.orm.jdbc.dialect.ColumnInfo();
	BeanUtils.copyProperties(dbColumnInfo, columnInfo);
	String tableName = columnInfo.getTableName();
	String columnName = columnInfo.getColumnName();
	boolean isprimaryKey = columnInfo.isIsprimaryKey();
	List<String> primaryKeys = findTablePrimaryKeys(dbInfoId, tableName);
	if (isprimaryKey) {
		primaryKeys.add(columnName);
		dbColumnInfo.setListPrimaryKey(primaryKeys);
		String pkName = this.findSqlServerPKIndex(dbInfoId, tableName);
		log.debug("pkName:" + pkName);
		if (StringUtils.hasText(pkName)) {
			dbColumnInfo.setPkName(pkName);
		}
	}
	IDialect dBDialect = getDBDialectByDbInfoId(dbInfoId);
	String sql = dBDialect.getNewColumnSql(dbColumnInfo);
	String[] sqls = sql.split(";");
	this.updateSql(dbInfoId, sqls);

}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:30,代码来源:DbService.java

示例6: entity2Dto

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
private static void entity2Dto() {
	EUser u = new EUser();
	u.setId(1l);
	u.setUsername("yoking");
	u.setCreationDate(new Date(System.currentTimeMillis()));
	
	UserDTO user = new UserDTO();
	
	ConvertUtils.register(new DateStringConverter(), String.class);
	try {
		BeanUtils.copyProperties(user, u);
	} catch (IllegalAccessException | InvocationTargetException e) {
		e.printStackTrace();
	}
	
	System.out.println(user);
}
 
开发者ID:yoking-zhang,项目名称:demo,代码行数:18,代码来源:ConverterApp.java

示例7: dto2Entity

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
private static void dto2Entity() {
	UserDTO user = new UserDTO();
	user.setId(1l);
	user.setUsername("joking");
	user.setCreationDate("2016-04-20");
	
	EUser u = new EUser();
	ConvertUtils.register(new DateStringConverter(), Date.class);
	try {
		BeanUtils.copyProperties(u, user);
	} catch (IllegalAccessException | InvocationTargetException e) {
		e.printStackTrace();
	}
	
	System.out.println(u);
}
 
开发者ID:yoking-zhang,项目名称:demo,代码行数:17,代码来源:ConverterApp.java

示例8: createJobExecutionSingleShardingContext

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
/**
     * 根据分片项获取单分片作业运行时上下文.
     * 
     * @param item 分片项
     * @return 单分片作业运行时上下文
     */
    public JobExecutionSingleShardingContext createJobExecutionSingleShardingContext(final int item) {
        JobExecutionSingleShardingContext result = new JobExecutionSingleShardingContext();
        try {
            BeanUtils.copyProperties(result, this);
//        } catch (final IllegalAccessException | InvocationTargetException ex) {
//            throw new JobException(ex);
//        }
        } catch (final IllegalAccessException ex1) {
            throw new JobException(ex1);
        } catch (final InvocationTargetException ex2) {
            throw new JobException(ex2);
        }
        result.setShardingItem(item);
        result.setShardingItemParameter(shardingItemParameters.get(item));
        result.setOffset(offsets.get(item));
        return result;
    }
 
开发者ID:artoderk,项目名称:elastic-jobx,代码行数:24,代码来源:JobExecutionMultipleShardingContext.java

示例9: backupTramitePersistente

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
/**
  * @ejb.interface-method
  * @ejb.permission role-name="${role.auto}"
  * @ejb.permission role-name="${role.todos}"
  * @param tramitePersistente
  * @return
  */
 public void backupTramitePersistente( TramitePersistente tramitePersistente )
 {
 	try
 	{
     	TramitePersistenteBackup result = new TramitePersistenteBackup();
  	BeanUtils.copyProperties( result, tramitePersistente );
Set setDocumentos = tramitePersistente.getDocumentos(); 
for ( Iterator it = setDocumentos.iterator(); it.hasNext(); )
{
	DocumentoPersistente documento = ( DocumentoPersistente ) it.next();
   	DocumentoPersistenteBackup backup = new DocumentoPersistenteBackup();
   	BeanUtils.copyProperties( backup, documento );
   	result.addDocumentoBackup( backup );
}
grabarBackupTramitePersistente ( result );
 	}
 	catch( Exception exc )
 	{
 		throw new EJBException( exc );
 	}
 }
 
开发者ID:GovernIB,项目名称:sistra,代码行数:29,代码来源:TramitePersistenteFacadeEJB.java

示例10: notificacionSinAbrir

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
/**
    * Devuelve notificacion con informacion exclusiva de aviso
    * @param notificacionTelematica
    * @return
    */
   private NotificacionTelematica notificacionSinAbrir(NotificacionTelematica notificacionTelematica) throws Exception {
	
   	NotificacionTelematica not = new NotificacionTelematica();
   	BeanUtils.copyProperties(not,notificacionTelematica);

   	// Eliminamos referencia rds a oficio
   	not.setCodigoRdsOficio(0);
   	not.setClaveRdsOficio(null);
   	
   	// Eliminamos documentos
   	not.getDocumentos().clear();
   	
   	// Eliminamos tramite de subsanacion
   	not.setTramiteSubsanacionDescripcion(null);
   	not.setTramiteSubsanacionIdentificador(null);
   	not.setTramiteSubsanacionVersion(null);
   	not.setTramiteSubsanacionParametros(null);
   	
	return not;
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:26,代码来源:NotificacionTelematicaFacadeEJB.java

示例11: getKeyJsonValueMetaData

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
/**
 * Retrieves the KeyJsonValue represented by the given key from the given namespace.
 */
@RequestMapping( value = "/{namespace}/{key}/metaData", method = RequestMethod.GET, produces = "application/json" )
public @ResponseBody KeyJsonValue getKeyJsonValueMetaData(
    @PathVariable String namespace, @PathVariable String key, HttpServletResponse response )
    throws Exception
{
    if ( !hasAccess( namespace ) )
    {
        throw new WebMessageException( WebMessageUtils.forbidden( "The namespace '" + namespace +
            "' is protected, and you don't have the right authority to access it." ) );
    }

    KeyJsonValue keyJsonValue = keyJsonValueService.getKeyJsonValue( namespace, key );

    if ( keyJsonValue == null )
    {
        throw new WebMessageException( WebMessageUtils
            .notFound( "The key '" + key + "' was not found in the namespace '" + namespace + "'." ) );
    }

    KeyJsonValue metaDataValue = new KeyJsonValue();
    BeanUtils.copyProperties( metaDataValue, keyJsonValue );
    metaDataValue.setValue( null );

    return metaDataValue;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:29,代码来源:KeyJsonValueController.java

示例12: queryActivity

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
/**
 * @param activityRuleVO
 * @return
 */
@ResponseBody
@RequestMapping(value = "/queryActivity", method = RequestMethod.POST)
public Map<String, Object> queryActivity(ActivityRuleVO activityRuleVO) {
    Map<String, Object> result = Maps.newHashMap();
    result.put("result", DTSResultCode.SUCCESS);
    try {
        ActivityRuleEntity activityRuleEntity = new ActivityRuleEntity();
        BeanUtils.copyProperties(activityRuleEntity, activityRuleVO);
        List<ActivityRuleEntity> list = acticityRuleApplication.queryActivityRule(activityRuleEntity);
        result.put("list", list);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        result.put("result", DTSResultCode.FAIL);
        result.put("message", e.getMessage());
    }
    return result;
}
 
开发者ID:adealjason,项目名称:dtsopensource,代码行数:22,代码来源:DTSAdmin.java

示例13: insertProduct

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
@PostMapping("addProduct")
@Transactional(propagation = Propagation.REQUIRED)
public String insertProduct(@RequestBody EditShopProductDto productDto) throws JsonProcessingException, InvocationTargetException, IllegalAccessException {
    /*将商品基础详情转换为json串*/
    String baseProperty = "";
    baseProperty = objectMapper.writeValueAsString(productDto.getBaseProperty());
    productDto.setProBaseProperty(baseProperty);

    /*设置销量*/
    productDto.setProSalveNumber(0);
    /*设置商品为下架*/
    productDto.setProSalve(0);
    /*将图片转为字符串*/
    String proImgs = objectMapper.writeValueAsString(productDto.getImgs());
    productDto.setProImage(proImgs);
    /*存储商品*/
    this.productService.insert(productDto);

    List<ShopProductVersion> spvs = new ArrayList<>();
    for (EditShopProductVersionDto vers : productDto.getProVersion()) {
        ShopProductVersion spv = new ShopProductVersion();
        /*将商品系列中的两个详情转换为json串*/
        String dp = objectMapper.writeValueAsString(vers.getDetailProperty());
        vers.setProDetailProperty(dp);
        vers.setProId(productDto.getProId());
        /*将Dto映射到pojo*/
        BeanUtils.copyProperties(spv, vers);
        spvs.add(spv);
    }
    System.out.println(productDto.getProId());

    /*批量添加到商品系列表中*/
    this.shopProductVersionService.insertList(spvs);

    return "{\"status\":true}";
}
 
开发者ID:TZClub,项目名称:OMIPlatform,代码行数:37,代码来源:ShopProductController.java

示例14: findEditProduct

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
@GetMapping("findEditProduct/{proid}")
public EditShopProductDto findEditProduct(@PathVariable Integer proid) throws InvocationTargetException, IllegalAccessException, IOException {
    EditShopProductDto result = new EditShopProductDto();
    ShopProduct product = this.productService.findByProId(proid);
    /*映射到dto对象*/
    BeanUtils.copyProperties(result, product);
    /*转换为图片信息*/
    JavaType type2 = objectMapper.getTypeFactory().constructParametricType(List.class, FileDto.class);
    List<FileDto> list2 = (ArrayList) objectMapper.readValue(product.getProImage(), type2);
    result.setImgs(list2);

    /*设置基础属性*/
    JavaType type1 = objectMapper.getTypeFactory().constructParametricType(List.class, PropertyPairDto.class);
    List<PropertyPairDto> list1 = (ArrayList) objectMapper.readValue(product.getProBaseProperty(), type1);
    result.setBaseProperty(list1);
    List<ShopProductVersion> versions = product.getMutiProduct();
    /*设置产品系列信息*/
    if (versions != null) {
        List<EditShopProductVersionDto> editVers = new ArrayList<>();
        for (ShopProductVersion ver : versions) {
            EditShopProductVersionDto editVersion = new EditShopProductVersionDto();
            BeanUtils.copyProperties(editVersion, ver);

            /*设置产品详细属性*/
            List<PropertyPairDto> list3 = (ArrayList) objectMapper.readValue(ver.getProDetailProperty(), type1);
            editVersion.setDetailProperty(list3);
            editVers.add(editVersion);
        }
        result.setProVersion(editVers);
    }
    return result;
}
 
开发者ID:TZClub,项目名称:OMIPlatform,代码行数:33,代码来源:ShopProductController.java

示例15: modifyProduct

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
/***
    * 更改商品信息
    * @param productDto
    * @return
    */
   @PostMapping("modifyProduct")
   @Transactional(propagation = Propagation.REQUIRED)
   public String modifyProduct(@RequestBody EditShopProductDto productDto) throws JsonProcessingException, InvocationTargetException, IllegalAccessException {
/*将商品基础详情转换为json串*/
       String baseProperty = "";
       baseProperty = objectMapper.writeValueAsString(productDto.getBaseProperty());
       productDto.setProBaseProperty(baseProperty);

       /*设置销量*/
       //productDto.setProSalveNumber(0);
       /*将图片转为字符串*/
       String proImgs = objectMapper.writeValueAsString(productDto.getImgs());
       productDto.setProImage(proImgs);
       /*存储商品*/
       this.productService.update(productDto);

       for (EditShopProductVersionDto vers : productDto.getProVersion()) {
           ShopProductVersion spv = new ShopProductVersion();
           /*将商品系列中的两个详情转换为json串*/
           String dp = objectMapper.writeValueAsString(vers.getDetailProperty());
           vers.setProDetailProperty(dp);
           vers.setProId(productDto.getProId());
           /*将Dto映射到pojo*/
           BeanUtils.copyProperties(spv, vers);
           /*批量添加到商品系列表中*/
           this.shopProductVersionService.update(spv);
       }
       System.out.println(productDto.getProId());
       return "{\"status\":true}";
   }
 
开发者ID:TZClub,项目名称:OMIPlatform,代码行数:36,代码来源:ShopProductController.java


注:本文中的org.apache.commons.beanutils.BeanUtils.copyProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。