本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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");
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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 );
}
}
示例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;
}
示例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;
}
示例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;
}
示例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}";
}
示例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;
}
示例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}";
}