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:org.nqcx.ncs.commons.app.GlobalApp.java
public <T> GlobalApp(T app) { try {//from w w w .ja va 2 s. co m if (app != null) PropertyUtils.copyProperties(this, app); } catch (Exception e) { // nothing to do } }
From source file:org.oscm.ui.services.MockService.java
public void copyProperties(Object dest, Object orig) { try {/* w w w . j a v a2s .co m*/ PropertyUtils.copyProperties(dest, orig); } catch (Exception e) { throw new SaaSSystemException(e); } }
From source file:org.ovirt.engine.sdk.mapping.Mapper.java
/** * Maps model object to defined decorator * //from w w w . j a va 2s .c o m * @param from * model object * @param to * decorator object * @param proxy * HttpProxyDecorator to inject * * @return Decorator instance */ @SuppressWarnings("unchecked") public static synchronized <F, T> T map(F from, Class<T> to, HttpProxyBroker proxy) { T dstobj = null; try { if (proxy != null) { dstobj = (T) getConstracor(to).newInstance(proxy); } else { dstobj = to.newInstance(); } if (dstobj != null) { PropertyUtils.copyProperties(dstobj, from); excludeExceptions(dstobj); } } catch (InstantiationException e) { // TODO: log error e.printStackTrace(); } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { // do nothing (PropertyUtils exceptions treatment #1007266) } catch (IllegalArgumentException e) { // TODO: log error e.printStackTrace(); } return dstobj; }
From source file:org.seasar.struts.pojo.processor.ProcessSetInputPathValidateInterceptor.java
public Object invoke(MethodInvocation invocation) throws Throwable { ActionMapping mapping = (ActionMapping) invocation.getArguments()[3]; String input = mapping.getInput(); if (input == null && S2StrutsContextUtil.getPreviousInputPath() != null) { ActionMapping newMapping = new ActionMapping(); try {/* w ww . j a v a2 s. co m*/ PropertyUtils.copyProperties(newMapping, mapping); } catch (IllegalAccessException e) { throw new IllegalAccessRuntimeException(newMapping.getClass(), e); } catch (InvocationTargetException e) { throw new InvocationTargetRuntimeException(newMapping.getClass(), e); } catch (NoSuchMethodException e) { throw new NoSuchMethodRuntimeException(newMapping.getClass(), null, null, e); } input = S2StrutsContextUtil.getPreviousInputPath(); newMapping.setInput(input); invocation.getArguments()[3] = newMapping; } return invocation.proceed(); }
From source file:org.specrunner.plugins.core.AbstractPlugin.java
@Override public IPlugin copy(IContext context) throws PluginException { try {/*from w w w .jav a 2 s. co m*/ IPlugin p = getClass().newInstance(); IParameterDecorator decorator = p.getParameters(); PropertyUtils.copyProperties(p, this); p.setParameters(decorator); return p; } catch (Exception e) { if (UtilLog.LOG.isDebugEnabled()) { UtilLog.LOG.debug(e.getMessage(), e); } throw new PluginException(e); } }
From source file:org.squale.welcom.taglib.field.util.LayoutUtils.java
/** * copie les properties d'un objet vers un autre * /*from w w w . j a va 2 s.co m*/ * @param dest l'objet destination * @param orig l'objet origine * @throws JspException exception pouvant etre levee */ public static void copyProperties(final Object dest, final Object orig) throws JspException { try { PropertyUtils.copyProperties(dest, orig); } catch (final InvocationTargetException e) { Throwable t = e.getTargetException(); if (t == null) { t = e; } System.err.println("LayoutUtils.copyProperties: "); System.err.println(t); throw new JspException("LayoutUtils.copyProperties: " + t.getMessage()); } catch (final Throwable t) { System.err.println("LayoutUtils.copyProperties: "); System.err.println(t); throw new JspException("LayoutUtils.copyProperties: " + t.getMessage()); } }
From source file:org.talend.dq.helper.UDIHelper.java
/** * /*from w w w.ja v a 2s . com*/ * DOC mzhao feature 11128, If the execute engine and by the same time Java User Defined Indicator is also defined, * then compute via Java UDI, here convert common udi to a Java UDI. * * @param udi * @return * @throws Exception */ public static Indicator adaptToJavaUDI(Indicator indicator) throws Throwable { Indicator returnIndicator = getUDIFromMap(indicator); if (returnIndicator != null) { return returnIndicator; } UserDefIndicator adaptedUDI = null; if (userDefIndSwitch.doSwitch(indicator) != null) { EList<TaggedValue> taggedValues = indicator.getIndicatorDefinition().getTaggedValue(); String userJavaClassName = null; String jarPath = null; for (TaggedValue tv : taggedValues) { if (tv.getTag().equals(TaggedValueHelper.CLASS_NAME_TEXT)) { userJavaClassName = tv.getValue(); continue; } if (tv.getTag().equals(TaggedValueHelper.JAR_FILE_PATH)) { jarPath = tv.getValue(); } } // MOD by zshen for feature 18724 if (validateJavaUDI(userJavaClassName, jarPath)) { List<URL> jarUrls = new ArrayList<URL>(); for (File file : getContainJarFile(jarPath)) { jarUrls.add(file.toURI().toURL()); } TalendURLClassLoader cl; // Note that the 2nd parameter (classloader) is needed to load class UserDefinitionIndicator from // org.talend.dataquality plugin. cl = new TalendURLClassLoader(jarUrls.toArray(new URL[jarUrls.size()]), UDIHelper.class.getClassLoader()); Class<?> clazz = null; clazz = cl.findClass(userJavaClassName); if (clazz != null) { // MOD yyin 20121012 TDQ-6259 UserDefIndicator judi = (UserDefIndicator) clazz.newInstance(); // judi.setIndicatorDefinition(indicator.getIndicatorDefinition()); PropertyUtils.copyProperties(judi, indicator); // judi.setAnalyzedElement(indicator.getAnalyzedElement()); adaptedUDI = judi; JAVAUDIMAP.put(indicator, adaptedUDI); } } } return adaptedUDI; }
From source file:org.tequila.model.JMetaPojo.java
/** * Crea una JMetaPojo en base a un objeto * @param object// w ww . j av a 2 s. c o m * @throws MetaPojoException */ protected JMetaPojo(Object instance) throws MetaPojoException { this.sourceObject = instance; try { // copia todas las propiedades y las pone al servicio con get('propertyName') PropertyUtils.copyProperties(this, instance); } catch (Exception ex) { throw new MetaPojoException("Error al crear el metapojo", ex); } }
From source file:sk.opendata.odn.repository.jackrabbit.JackrabbitItem.java
/** * Create SOLR item from given record./*from w w w . jav a2s . c o m*/ * * @param source * record - source of data * @param type * type of the record * @param id * ID of the record * * @return SOLR item created from given data * * @throws OdnSerializationException * when conversion into SOLR beans fails */ public static JackrabbitItem createJackrabbitItem(AbstractRecord source) throws OdnSerializationException { JackrabbitItem solrItem = null; try { solrItem = new JackrabbitItem(); PropertyUtils.copyProperties(solrItem, source); solrItem.type = JackrabbitItemType.getType(source.getClass()).toString(); solrItem.id = source.getId(); } catch (IllegalAccessException e) { logger.error("illegal access exception", e); throw new OdnSerializationException(e.getMessage(), e); } catch (InvocationTargetException e) { logger.error("invocation target exception", e); throw new OdnSerializationException(e.getMessage(), e); } catch (NoSuchMethodException e) { logger.error("no such method exception", e); throw new OdnSerializationException(e.getMessage(), e); } return solrItem; }
From source file:sk.opendata.odn.repository.solr.SolrItem.java
/** * Create SOLR item from given record./* w w w .j a v a2 s. c om*/ * * @param source * record - source of data * @param type * type of the record * @param id * ID of the record * * @return SOLR item created from given data * * @throws OdnSerializationException * when conversion into SOLR beans fails */ public static SolrItem createSolrItem(AbstractRecord source) throws OdnSerializationException { SolrItem solrItem = null; try { solrItem = new SolrItem(); PropertyUtils.copyProperties(solrItem, source); solrItem.type = SolrItemType.getType(source.getClass()).toString(); solrItem.id = source.getId(); } catch (IllegalAccessException e) { logger.error("illegal access exception", e); throw new OdnSerializationException(e.getMessage(), e); } catch (InvocationTargetException e) { logger.error("invocation target exception", e); throw new OdnSerializationException(e.getMessage(), e); } catch (NoSuchMethodException e) { logger.error("no such method exception", e); throw new OdnSerializationException(e.getMessage(), e); } return solrItem; }