本文整理匯總了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}";
}