List of usage examples for org.apache.commons.beanutils PropertyUtils copyProperties
public static void copyProperties(Object dest, Object orig) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Copy property values from the "origin" bean to the "destination" bean for all cases where the property names are the same (even though the actual getter and setter methods might have been customized via BeanInfo
classes).
For more details see PropertyUtilsBean
.
From source file:com.iorga.webappwatcher.analyzer.ws.session.ConfigurationsWS.java
@POST @Path("/save") public void save(final Configurations configurations) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { PropertyUtils.copyProperties(getConfigurations(), configurations); }
From source file:jp.co.opentone.bsol.linkbinder.dto.CorresponTest.java
@Test public void testProperties() throws Exception { Correspon expected = new Correspon(); initProperties(expected);/*from w ww .j a va 2 s. c o m*/ PropertyUtils.copyProperties(correspon, expected); assertEquals(expected.toString(), correspon.toString()); }
From source file:com.appspot.socialinquirer.server.service.mapper.AbstractMapper.java
public void copyProperties(SOURCE source, TARGET target) { try {/*w w w. j av a 2 s. c o m*/ PropertyUtils.copyProperties(target, source); } catch (Exception e) { logger.log(Level.SEVERE, "An error occurred while copying properties from '" + source.getClass().getName() + "' to '" + target.getClass().getName(), e); } }
From source file:jp.co.opentone.bsol.linkbinder.scrapbook.CopyPropertiesTest.java
@Test public void testPropertyUtilsCopyProperties() throws Exception { Map<String, Object> values = new HashMap<String, Object>(); values.put("id", Long.valueOf(10)); values.put("name", "test"); List<CorresponGroup> groups = new ArrayList<CorresponGroup>(); CorresponGroup g = new CorresponGroup(); g.setId(1L);//from w w w . j a v a 2 s .c o m g.setName("g1"); groups.add(g); g = new CorresponGroup(); g.setId(2L); g.setName("g2"); groups.add(g); values.put("groups", groups); Dto dto = new Dto(); PropertyUtils.copyProperties(dto, values); assertEquals(Long.valueOf(10L), dto.getId()); assertEquals("test", dto.getName()); List<CorresponGroup> actual = dto.getGroups(); assertNotNull(actual); assertEquals(groups.size(), actual.size()); assertEquals(groups.get(0).getId(), actual.get(0).getId()); assertEquals(groups.get(0).getName(), actual.get(0).getName()); }
From source file:com.ms.commons.lang.BeanUtils.java
@SuppressWarnings({ "rawtypes" }) public static <T extends Object> void copyProperties(T target, Object raw, ValueEditable... defaultValues) { try {//from w w w . j ava 2s . c o m Map values = raw == null ? new HashMap() : PropertyUtils.describe(raw); if (Argument.isNotEmptyArray(defaultValues)) { for (ValueEditable edit : defaultValues) { edit.edit(raw, values); } } PropertyUtils.copyProperties(target, values); // ? // TODO } catch (Exception e) { logger.error(e.getMessage(), e); } }
From source file:com.appspot.socialinquirer.server.service.mapper.AbstractMapper.java
public void copyProperties(TARGET source, SOURCE target) { try {//from www . j ava 2 s .co m PropertyUtils.copyProperties(target, source); } catch (Exception e) { logger.log(Level.SEVERE, "An error occurred while copying properties from '" + target.getClass().getName() + "' to '" + source.getClass().getName(), e); } }
From source file:com.aurel.track.report.execute.ReportBeanWithHistory.java
public ReportBeanWithHistory(ReportBean reportBean) { super();/*from w w w . j a v a 2 s . c om*/ try { PropertyUtils.copyProperties(this, reportBean); } catch (Exception e) { LOGGER.error("Constructing a ReportBeanWithHistory from ReportBean failed with " + e.getMessage()); } }
From source file:jp.co.opentone.bsol.framework.web.view.PagePropertyUtil.java
/** * page???values??./* w ww. j a v a2 s . co m*/ * <p> * ???????????????. * </p> * @param page * page * @param values * ? */ public static void copyProperties(Page page, Map<String, Object> values) { if (values != null && !values.isEmpty()) { try { PropertyUtils.copyProperties(page, values); } catch (IllegalAccessException e) { throw new ReflectionRuntimeException(e); } catch (InvocationTargetException e) { throw new ReflectionRuntimeException(e); } catch (NoSuchMethodException e) { throw new ReflectionRuntimeException(e); } } }
From source file:com.norconex.jefmon.settings.update.SettingsPage.java
private void initializeComponents() { try {/*from ww w.j av a 2s . c o m*/ PropertyUtils.copyProperties(dirtyConfig, getJEFMonConfig()); } catch (Exception e) { throw new WicketRuntimeException(e); } AjaxLink<String> nameBack = new AjaxLink<String>("nameBack") { private static final long serialVersionUID = -7790485617549321158L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(InstancePage.class); } }; nameBack.add(new Label("name", getJEFMonConfig().getInstanceName())); add(nameBack); Form<Void> form = new Form<Void>("form"); form.setOutputMarkupId(true); add(form); final FeedbackPanel feedback = new FeedbackPanel("feedback"); feedback.setOutputMarkupId(true); form.add(feedback); form.add(createConfigPanel("configPanel", dirtyConfig)); final AjaxButton saveButton = new AjaxButton("save") { private static final long serialVersionUID = 8835758195954072646L; @Override protected void onAfterSubmit(AjaxRequestTarget target, Form<?> theform) { try { ConfigurationDAO.saveConfig(dirtyConfig); PropertyUtils.copyProperties(getJEFMonConfig(), dirtyConfig); } catch (IOException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new WicketRuntimeException("Cannot save configuration.", e); } success(getString("success")); setResponsePage(InstancePage.class); } @Override protected void onError(AjaxRequestTarget target, Form<?> theForm) { target.add(feedback); } }; form.add(saveButton); form.setDefaultButton(saveButton); AjaxLink<String> closeButton = new AjaxLink<String>("close") { private static final long serialVersionUID = 6062171472516887030L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(InstancePage.class); } }; form.add(closeButton); }
From source file:net.sourceforge.fenixedu.presentationTier.config.FenixNotAuthorizedExceptionHandler.java
/** * Handle the exception. Return the <code>ActionForward</code> instance (if * any) returned by the called <code>ExceptionHandler</code>. * // w w w . ja va 2s . c o m * @param ex * The exception to handle * @param ae * The ExceptionConfig corresponding to the exception * @param mapping * The ActionMapping we are processing * @param formInstance * The ActionForm we are processing * @param request * The servlet request we are processing * @param response * The servlet response we are creating * * @exception ServletException * if a servlet exception occurs * * @since Struts 1.1 */ @Override public ActionForward execute(Exception ex, ExceptionConfig exceptionConfig, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws ServletException { try { ActionForward forward = mapping.getInputForward(); ActionForward newForward = new ActionForward(); PropertyUtils.copyProperties(newForward, forward); StringBuilder path = new StringBuilder(); path.append("/teacherAdministrationViewer.do?method=instructions").append("&objectCode=") .append(request.getParameter("executionCourseId")); newForward.setPath(path.toString()); // Store the exception ActionError actionError = new ActionError(exceptionConfig.getKey()); super.storeException(request, exceptionConfig.getKey(), actionError, newForward, exceptionConfig.getScope()); return newForward; } catch (Exception e) { throw new ServletException(e.getMessage()); } }