List of usage examples for org.springframework.beans BeanUtils copyProperties
public static void copyProperties(Object source, Object target, String... ignoreProperties) throws BeansException
From source file:de.steilerdev.myVerein.server.model.Event.java
/** * This function copies the current object, ignoring the member fields specified by the ignored properties vararg. * @param ignoredProperties The member fields ignored during the copying. * @return A copy of the current object, not containing information about the ignored properties. */// ww w .j av a 2s . co m @JsonIgnore @Transient private Event getSendingObject(String... ignoredProperties) { Event sendingObject = new Event(); BeanUtils.copyProperties(this, sendingObject, ignoredProperties); return sendingObject; }
From source file:org.quartz.GWTQuartzManager.server.GWTQuartzSchedulerImpl.java
@Override public Date scheduleJob(GWTCronTrigger GWTTrigger) throws GWTSchedulerException { if (GWTTrigger.getKey() == null) throw new GWTSchedulerException("Key can't be null in Trigger"); TriggerKey triggerKey = new TriggerKey(GWTTrigger.getKey().getName(), GWTTrigger.getKey().getGroup()); if (GWTTrigger.getJobKey() == null) throw new GWTSchedulerException("JobKey can't be null in Trigger"); JobKey jobKey = new JobKey(GWTTrigger.getJobKey().getName(), GWTTrigger.getJobKey().getGroup()); //convert GWTTrigger to Trigger MutableTrigger trigger = new CronTriggerImpl(); BeanUtils.copyProperties(GWTTrigger, trigger, new String[] { "key", "jobKey" }); trigger.setKey(triggerKey);//from ww w.j a v a 2 s. com trigger.setJobKey(jobKey); if (GWTTrigger.getJobDataMapEntryList() != null) { JobDataMap jobDataMap = new JobDataMap(); for (Pair<String, String> entry : GWTTrigger.getJobDataMapEntryList()) { jobDataMap.put(entry.getKey(), entry.getValue()); } trigger.setJobDataMap(jobDataMap); } Date result; try { if (delegate.checkExists(triggerKey)) { result = delegate.rescheduleJob(triggerKey, trigger); } else { result = delegate.scheduleJob(trigger); } } catch (SchedulerException ex) { throw new GWTSchedulerException(ex.getMessage()); } return result; }
From source file:mx.edu.um.mateo.inventario.dao.impl.ProductoDaoHibernate.java
private void audita(Producto producto, Usuario usuario, String actividad, Date fecha) { XProducto xproducto = new XProducto(); BeanUtils.copyProperties(producto, xproducto, new String[] { "id", "version" }); xproducto.setProductoId(producto.getId()); xproducto.setTipoProductoId(producto.getTipoProducto().getId()); xproducto.setAlmacenId(producto.getAlmacen().getId()); xproducto.setFechaCreacion(fecha);/*w ww . jav a2 s.c om*/ xproducto.setActividad(actividad); xproducto.setCreador((usuario != null) ? usuario.getUsername() : "sistema"); currentSession().save(xproducto); }
From source file:com.foya.noms.service.st.ST002Service.java
/** * siteHuntApply//w ww . jav a 2 s . co m * * @param siteHuntApply * @return */ @Transactional public TbSiteWork update(SiteHuntApplyDTO siteHuntApply, String[] orderIdArray, String mdUser) throws UpdateFailException { Date mdTime = new Date(); boolean hasChangeDomain = false; TownDomainTeamDTO domainTeam = null; String workId = siteHuntApply.getWorkId(); TbSiteWork siteWorkTarget = workDao.findByPk(workId); // ?????? add by Charlie 20150415 if (!StringUtils.equals(siteHuntApply.getArea(), siteWorkTarget.getAREA())) { hasChangeDomain = true; domainTeam = townDomainTeamDao.getTownDomainTeamByCityIdTownId(siteHuntApply.getCity(), siteHuntApply.getArea()); } TbSiteWork siteWork = this.getSiteWorkBySiteHuntApplyDTO(siteHuntApply, workId, siteHuntApply.getSiteId()); siteWork.setMD_USER(mdUser); siteWork.setMD_TIME(mdTime); String[] ignoreProperties = { "CR_USER", "CR_TIME", "APP_DEPT", "APL_USER", "APL_TIME", "END_TIME", "OS_VEN", "END_DATE", "CPL_NO", "PERMIT_NO", "LICENSE_NO", "OS_TYPE" }; BeanUtils.copyProperties(siteWork, siteWorkTarget, ignoreProperties); int siteWorkItem = workDao.update(siteWorkTarget); if (siteWorkItem == 0) { log.error("siteWorkItem update count= " + siteWorkItem + " , workId = " + siteWork.getWORK_ID()); throw new UpdateFailException(""); } for (String orderId : orderIdArray) { TbSiteWorkOrder siteWorkOrder = workOrderDao.findOrderByPk(orderId); siteWorkOrder.setORDER_ID(orderId); siteWorkOrder.setPRIORITY(siteHuntApply.getPriority()); siteWorkOrder.setMD_USER(mdUser); siteWorkOrder.setMD_TIME(mdTime); if (hasChangeDomain) { // ?DOMAIN??? add by Charlie 20150415 String deptKey = orderTypeService.getOrdersDeptKey(siteWorkOrder.getORDER_TYPE(), domainTeam.getDOMAIN(), siteWorkTarget.getEQP_TYPE_ID()); TbOrgDept newNept = orderTypeService.getOrderTypeForWorkArea(deptKey, domainTeam); siteWorkOrder.setREP_DEPT(newNept.getDEPT_ID()); } int workOrderItem = workOrderDao.updateSelective(siteWorkOrder); if (workOrderItem == 0) { log.error("workOrderItem update count= " + workOrderItem + " , orderId = " + siteWorkOrder.getORDER_ID()); throw new UpdateFailException(""); } } return siteWorkTarget; }
From source file:net.groupbuy.controller.admin.ProductController.java
/** * /*from w w w.j a v a 2s.com*/ */ @RequestMapping(value = "/update", method = RequestMethod.POST) public String update(Product product, Long productCategoryId, Long brandId, Long[] tagIds, Long[] specificationIds, Long[] specificationProductIds, HttpServletRequest request, RedirectAttributes redirectAttributes) { for (Iterator<ProductImage> iterator = product.getProductImages().iterator(); iterator.hasNext();) { ProductImage productImage = iterator.next(); if (productImage == null || productImage.isEmpty()) { iterator.remove(); continue; } if (productImage.getFile() != null && !productImage.getFile().isEmpty()) { if (!fileService.isValid(FileType.image, productImage.getFile())) { addFlashMessage(redirectAttributes, Message.error("admin.upload.invalid")); return "redirect:edit.jhtml?id=" + product.getId(); } } } product.setProductCategory(productCategoryService.find(productCategoryId)); product.setBrand(brandService.find(brandId)); product.setTags(new HashSet<Tag>(tagService.findList(tagIds))); if (!isValid(product)) { return ERROR_VIEW; } Product pProduct = productService.find(product.getId()); if (pProduct == null) { return ERROR_VIEW; } if (StringUtils.isNotEmpty(product.getSn()) && !productService.snUnique(pProduct.getSn(), product.getSn())) { return ERROR_VIEW; } if (product.getMarketPrice() == null) { BigDecimal defaultMarketPrice = calculateDefaultMarketPrice(product.getPrice()); product.setMarketPrice(defaultMarketPrice); } if (product.getPoint() == null) { long point = calculateDefaultPoint(product.getPrice()); product.setPoint(point); } for (MemberRank memberRank : memberRankService.findAll()) { String price = request.getParameter("memberPrice_" + memberRank.getId()); if (StringUtils.isNotEmpty(price) && new BigDecimal(price).compareTo(new BigDecimal(0)) >= 0) { product.getMemberPrice().put(memberRank, new BigDecimal(price)); } else { product.getMemberPrice().remove(memberRank); } } for (ProductImage productImage : product.getProductImages()) { productImageService.build(productImage); } Collections.sort(product.getProductImages()); if (product.getImage() == null && product.getThumbnail() != null) { product.setImage(product.getThumbnail()); } for (ParameterGroup parameterGroup : product.getProductCategory().getParameterGroups()) { for (Parameter parameter : parameterGroup.getParameters()) { String parameterValue = request.getParameter("parameter_" + parameter.getId()); if (StringUtils.isNotEmpty(parameterValue)) { product.getParameterValue().put(parameter, parameterValue); } else { product.getParameterValue().remove(parameter); } } } for (Attribute attribute : product.getProductCategory().getAttributes()) { String attributeValue = request.getParameter("attribute_" + attribute.getId()); if (StringUtils.isNotEmpty(attributeValue)) { product.setAttributeValue(attribute, attributeValue); } else { product.setAttributeValue(attribute, null); } } Goods goods = pProduct.getGoods(); List<Product> products = new ArrayList<Product>(); if (specificationIds != null && specificationIds.length > 0) { for (int i = 0; i < specificationIds.length; i++) { Specification specification = specificationService.find(specificationIds[i]); String[] specificationValueIds = request .getParameterValues("specification_" + specification.getId()); if (specificationValueIds != null && specificationValueIds.length > 0) { for (int j = 0; j < specificationValueIds.length; j++) { if (i == 0) { if (j == 0) { BeanUtils.copyProperties(product, pProduct, new String[] { "id", "createDate", "modifyDate", "fullName", "allocatedStock", "score", "totalScore", "scoreCount", "hits", "weekHits", "monthHits", "sales", "weekSales", "monthSales", "weekHitsDate", "monthHitsDate", "weekSalesDate", "monthSalesDate", "goods", "reviews", "consultations", "favoriteMembers", "specifications", "specificationValues", "promotions", "cartItems", "orderItems", "giftItems", "productNotifies" }); pProduct.setSpecifications(new HashSet<Specification>()); pProduct.setSpecificationValues(new HashSet<SpecificationValue>()); products.add(pProduct); } else { if (specificationProductIds != null && j < specificationProductIds.length) { Product specificationProduct = productService.find(specificationProductIds[j]); if (specificationProduct == null || (specificationProduct.getGoods() != null && !specificationProduct.getGoods().equals(goods))) { return ERROR_VIEW; } specificationProduct.setSpecifications(new HashSet<Specification>()); specificationProduct.setSpecificationValues(new HashSet<SpecificationValue>()); products.add(specificationProduct); } else { Product specificationProduct = new Product(); BeanUtils.copyProperties(product, specificationProduct); specificationProduct.setId(null); specificationProduct.setCreateDate(null); specificationProduct.setModifyDate(null); specificationProduct.setSn(null); specificationProduct.setFullName(null); specificationProduct.setAllocatedStock(0); specificationProduct.setIsList(false); specificationProduct.setScore(0F); specificationProduct.setTotalScore(0L); specificationProduct.setScoreCount(0L); specificationProduct.setHits(0L); specificationProduct.setWeekHits(0L); specificationProduct.setMonthHits(0L); specificationProduct.setSales(0L); specificationProduct.setWeekSales(0L); specificationProduct.setMonthSales(0L); specificationProduct.setWeekHitsDate(new Date()); specificationProduct.setMonthHitsDate(new Date()); specificationProduct.setWeekSalesDate(new Date()); specificationProduct.setMonthSalesDate(new Date()); specificationProduct.setGoods(goods); specificationProduct.setReviews(null); specificationProduct.setConsultations(null); specificationProduct.setFavoriteMembers(null); specificationProduct.setSpecifications(new HashSet<Specification>()); specificationProduct.setSpecificationValues(new HashSet<SpecificationValue>()); specificationProduct.setPromotions(null); specificationProduct.setCartItems(null); specificationProduct.setOrderItems(null); specificationProduct.setGiftItems(null); specificationProduct.setProductNotifies(null); products.add(specificationProduct); } } } Product specificationProduct = products.get(j); SpecificationValue specificationValue = specificationValueService .find(Long.valueOf(specificationValueIds[j])); specificationProduct.getSpecifications().add(specification); specificationProduct.getSpecificationValues().add(specificationValue); } } } } else { product.setSpecifications(null); product.setSpecificationValues(null); BeanUtils.copyProperties(product, pProduct, new String[] { "id", "createDate", "modifyDate", "fullName", "allocatedStock", "score", "totalScore", "scoreCount", "hits", "weekHits", "monthHits", "sales", "weekSales", "monthSales", "weekHitsDate", "monthHitsDate", "weekSalesDate", "monthSalesDate", "goods", "reviews", "consultations", "favoriteMembers", "promotions", "cartItems", "orderItems", "giftItems", "productNotifies" }); products.add(pProduct); } goods.getProducts().clear(); goods.getProducts().addAll(products); goodsService.update(goods); addFlashMessage(redirectAttributes, SUCCESS_MESSAGE); return "redirect:list.jhtml"; }
From source file:net.groupbuy.controller.admin.OrderController.java
/** * /* w ww . j a va 2s . co m*/ */ @RequestMapping(value = "/update", method = RequestMethod.POST) public String update(Order order, Long areaId, Long paymentMethodId, Long shippingMethodId, RedirectAttributes redirectAttributes) { for (Iterator<OrderItem> iterator = order.getOrderItems().iterator(); iterator.hasNext();) { OrderItem orderItem = iterator.next(); if (orderItem == null || StringUtils.isEmpty(orderItem.getSn())) { iterator.remove(); } } order.setArea(areaService.find(areaId)); order.setPaymentMethod(paymentMethodService.find(paymentMethodId)); order.setShippingMethod(shippingMethodService.find(shippingMethodId)); if (!isValid(order)) { return ERROR_VIEW; } Order pOrder = orderService.find(order.getId()); if (pOrder == null) { return ERROR_VIEW; } if (pOrder.isExpired() || pOrder.getOrderStatus() != OrderStatus.unconfirmed) { return ERROR_VIEW; } Admin admin = adminService.getCurrent(); if (pOrder.isLocked(admin)) { return ERROR_VIEW; } if (!order.getIsInvoice()) { order.setInvoiceTitle(null); order.setTax(new BigDecimal(0)); } for (OrderItem orderItem : order.getOrderItems()) { if (orderItem.getId() != null) { OrderItem pOrderItem = orderItemService.find(orderItem.getId()); if (pOrderItem == null || !pOrder.equals(pOrderItem.getOrder())) { return ERROR_VIEW; } Product product = pOrderItem.getProduct(); if (product != null && product.getStock() != null) { if (pOrder.getIsAllocatedStock()) { if (orderItem.getQuantity() > product.getAvailableStock() + pOrderItem.getQuantity()) { return ERROR_VIEW; } } else { if (orderItem.getQuantity() > product.getAvailableStock()) { return ERROR_VIEW; } } } BeanUtils.copyProperties(pOrderItem, orderItem, new String[] { "price", "quantity" }); if (pOrderItem.getIsGift()) { orderItem.setPrice(new BigDecimal(0)); } } else { Product product = productService.findBySn(orderItem.getSn()); if (product == null) { return ERROR_VIEW; } if (product.getStock() != null && orderItem.getQuantity() > product.getAvailableStock()) { return ERROR_VIEW; } orderItem.setName(product.getName()); orderItem.setFullName(product.getFullName()); if (product.getIsGift()) { orderItem.setPrice(new BigDecimal(0)); } orderItem.setWeight(product.getWeight()); orderItem.setThumbnail(product.getThumbnail()); orderItem.setIsGift(product.getIsGift()); orderItem.setShippedQuantity(0); orderItem.setReturnQuantity(0); orderItem.setProduct(product); orderItem.setOrder(pOrder); } } order.setSn(pOrder.getSn()); order.setOrderStatus(pOrder.getOrderStatus()); order.setPaymentStatus(pOrder.getPaymentStatus()); order.setShippingStatus(pOrder.getShippingStatus()); order.setFee(pOrder.getFee()); order.setPromotionDiscount(pOrder.getPromotionDiscount()); order.setCouponDiscount(pOrder.getCouponDiscount()); order.setAmountPaid(pOrder.getAmountPaid()); order.setPromotion(pOrder.getPromotion()); order.setExpire(pOrder.getExpire()); order.setLockExpire(null); order.setIsAllocatedStock(pOrder.getIsAllocatedStock()); order.setOperator(null); order.setMember(pOrder.getMember()); order.setCouponCode(pOrder.getCouponCode()); order.setCoupons(pOrder.getCoupons()); order.setOrderLogs(pOrder.getOrderLogs()); order.setDeposits(pOrder.getDeposits()); order.setPayments(pOrder.getPayments()); order.setRefunds(pOrder.getRefunds()); order.setShippings(pOrder.getShippings()); order.setReturns(pOrder.getReturns()); orderService.update(order, admin); addFlashMessage(redirectAttributes, SUCCESS_MESSAGE); return "redirect:list.jhtml"; }
From source file:de.steilerdev.myVerein.server.model.User.java
/** * This function copies the current object, ignoring the member fields specified by the ignored properties vararg. * @param ignoredProperties The member fields ignored during the copying. * @return A copy of the current object, not containing information about the ignored properties. *//*from w w w .j a v a2 s. c o m*/ @JsonIgnore @Transient private User getSendingObject(String... ignoredProperties) { User sendingObject = new User(); BeanUtils.copyProperties(this, sendingObject, ignoredProperties); return sendingObject; }
From source file:mx.edu.um.mateo.activos.dao.impl.ActivoDaoHibernate.java
private void audita(Activo activo, Usuario usuario, String actividad, Date fecha) { XActivo xactivo = new XActivo(); BeanUtils.copyProperties(activo, xactivo, new String[] { "id", "version" }); xactivo.setActivoId(activo.getId()); xactivo.setEmpresaId(activo.getEmpresa().getId()); xactivo.setProveedorId(activo.getProveedor().getId()); xactivo.setTipoActivoId(activo.getTipoActivo().getId()); xactivo.setEjercicioId(activo.getCentroCosto().getId().getEjercicio().getId().getIdEjercicio()); xactivo.setOrganizacionId(activo.getEmpresa().getOrganizacion().getId()); xactivo.setIdCosto(activo.getCentroCosto().getId().getIdCosto()); xactivo.setFechaCreacion(fecha);/*w w w.j a v a 2s. com*/ xactivo.setActividad(actividad); xactivo.setCreador((usuario != null) ? usuario.getUsername() : "sistema"); log.debug("Depreciacion fecha: {} - {}", activo.getFechaCompra(), xactivo.getFechaCompra()); currentSession().save(xactivo); }
From source file:mx.edu.um.mateo.inventario.dao.impl.EntradaDaoHibernate.java
private void auditaProducto(Producto producto, Usuario usuario, String actividad, Long entradaId, Long cancelacionId, Date fecha) { XProducto xproducto = new XProducto(); BeanUtils.copyProperties(producto, xproducto, new String[] { "id", "version" }); xproducto.setId(null);/* www . j a v a2 s .c o m*/ xproducto.setProductoId(producto.getId()); xproducto.setEntradaId(entradaId); xproducto.setCancelacionId(cancelacionId); xproducto.setTipoProductoId(producto.getTipoProducto().getId()); xproducto.setAlmacenId(producto.getAlmacen().getId()); xproducto.setFechaCreacion(fecha); xproducto.setActividad(actividad); xproducto.setCreador((usuario != null) ? usuario.getUsername() : "sistema"); currentSession().save(xproducto); }
From source file:mx.edu.um.mateo.inventario.dao.impl.EntradaDaoHibernate.java
private void audita(Entrada entrada, Usuario usuario, String actividad, Date fecha, Boolean conLotes) { XEntrada xentrada = new XEntrada(); BeanUtils.copyProperties(entrada, xentrada, new String[] { "id", "version" }); xentrada.setEntradaId(entrada.getId()); xentrada.setAlmacenId(entrada.getAlmacen().getId()); xentrada.setProveedorId(entrada.getProveedor().getId()); xentrada.setEstatusId(entrada.getEstatus().getId()); xentrada.setFechaCreacion(fecha);//from ww w . j av a 2 s . c o m xentrada.setActividad(actividad); xentrada.setCreador((usuario != null) ? usuario.getUsername() : "sistema"); currentSession().save(xentrada); if (conLotes) { for (LoteEntrada lote : entrada.getLotes()) { XLoteEntrada xlote = new XLoteEntrada(); BeanUtils.copyProperties(lote, xlote, new String[] { "id", "version" }); xlote.setLoteEntradaId(lote.getId()); xlote.setEntradaId(entrada.getId()); xlote.setProductoId(lote.getProducto().getId()); xlote.setActividad(actividad); xlote.setCreador((usuario != null) ? usuario.getUsername() : "sistema"); xlote.setFechaCreacion(fecha); currentSession().save(xlote); } } }