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.kuali.rice.kim.impl.responsibility.ResponsibilityInquirableImpl.java
private UberResponsibilityBo getResponsibilitiesSearchResultsCopy(ResponsibilityBo responsibilitySearchResult) { UberResponsibilityBo responsibilitySearchResultCopy = new UberResponsibilityBo(); try {//from w w w .ja v a2s . c o m PropertyUtils.copyProperties(responsibilitySearchResultCopy, responsibilitySearchResult); } catch (Exception ex) { throw new RuntimeException(ex); } List<RoleResponsibilityBo> roleResponsibilitys = getDataObjectService() .findMatching(RoleResponsibilityBo.class, QueryByCriteria.Builder .forAttribute("responsibilityId", responsibilitySearchResultCopy.getId()).build()) .getResults(); List<RoleBo> assignedToRoles = new ArrayList<RoleBo>(); for (RoleResponsibilityBo roleResponsibilityImpl : roleResponsibilitys) { assignedToRoles.add(getDataObjectService().find(RoleBo.class, roleResponsibilityImpl.getRoleId())); } responsibilitySearchResultCopy.setAssignedToRoles(assignedToRoles); return responsibilitySearchResultCopy; }
From source file:org.kuali.rice.kim.impl.responsibility.ResponsibilityLookupableHelperServiceImpl.java
private List<UberResponsibilityBo> getResponsibilitiesSearchResultsCopy( List<ResponsibilityBo> responsibilitySearchResults) { List<UberResponsibilityBo> responsibilitySearchResultsCopy = new CollectionIncomplete<UberResponsibilityBo>( new ArrayList<UberResponsibilityBo>(), getActualSizeIfTruncated(responsibilitySearchResults)); for (ResponsibilityBo responsibilityImpl : responsibilitySearchResults) { UberResponsibilityBo responsibilityCopy = new UberResponsibilityBo(); try {//from w w w . j av a2 s .c o m PropertyUtils.copyProperties(responsibilityCopy, responsibilityImpl); //Hack for tomcat 7 KULRICE:5927 responsibilityCopy.setTemplate(responsibilityImpl.getTemplate()); } catch (IllegalAccessException e) { throw new RuntimeException("unable to copy properties"); } catch (InvocationTargetException e) { throw new RuntimeException("unable to copy properties"); } catch (NoSuchMethodException e) { throw new RuntimeException("unable to copy properties"); } responsibilitySearchResultsCopy.add(responsibilityCopy); } return responsibilitySearchResultsCopy; }
From source file:org.kuali.rice.kim.inquiry.PermissionInquirableImpl.java
private PermissionBo getPermissionsSearchResultsCopy(PermissionBo permissionSearchResult) { UberPermissionBo permissionSearchResultCopy = new UberPermissionBo(); try {/*from w ww . j av a 2 s . c o m*/ PropertyUtils.copyProperties(permissionSearchResultCopy, permissionSearchResult); } catch (Exception ex) { throw new RuntimeException(ex); } List<RolePermissionBo> rolePermissions = getDataObjectService().findMatching(RolePermissionBo.class, QueryByCriteria.Builder.forAttribute("permissionId", permissionSearchResultCopy.getId()).build()) .getResults(); List<RoleBo> assignedToRoles = new ArrayList<RoleBo>(); for (RolePermissionBo rolePermissionImpl : rolePermissions) { assignedToRoles.add(getDataObjectService().find(RoleBo.class, rolePermissionImpl.getRoleId())); } permissionSearchResultCopy.setAssignedToRoles(assignedToRoles); return permissionSearchResultCopy; }
From source file:org.kuali.rice.kim.lookup.PermissionLookupableHelperServiceImpl.java
private List<UberPermissionBo> getPermissionsSearchResultsCopy(List<PermissionBo> permissionSearchResults) { List<UberPermissionBo> permissionSearchResultsCopy = new CollectionIncomplete<UberPermissionBo>( new ArrayList<UberPermissionBo>(), getActualSizeIfTruncated(permissionSearchResults)); for (PermissionBo permissionBo : permissionSearchResults) { UberPermissionBo permissionCopy = new UberPermissionBo(); try {// w w w . j a va 2 s . c o m PropertyUtils.copyProperties(permissionCopy, permissionBo); //Hack for tomcat 7 KULRICE-5927 permissionCopy.setTemplate(permissionBo.getTemplate()); } catch (IllegalAccessException e) { throw new RuntimeException("unable to copy properties"); } catch (InvocationTargetException e) { throw new RuntimeException("unable to copy properties"); } catch (NoSuchMethodException e) { throw new RuntimeException("unable to copy properties"); } permissionSearchResultsCopy.add(permissionCopy); } return permissionSearchResultsCopy; }
From source file:org.kuali.rice.kim.util.KimCommonUtils.java
public static void copyProperties(Object targetToCopyTo, Object sourceToCopyFrom) { if (targetToCopyTo != null && sourceToCopyFrom != null) { try {/*from ww w .j a v a2s . c om*/ PropertyUtils.copyProperties(targetToCopyTo, sourceToCopyFrom); } catch (Exception ex) { throw new RuntimeException("Failed to copy from source object: " + sourceToCopyFrom.getClass() + " to target object: " + targetToCopyTo, ex); } } }
From source file:org.kuali.rice.kim.util.KimCommonUtilsInternal.java
public static void copyProperties(Object targetToCopyTo, Object sourceToCopyFrom) { if (targetToCopyTo != null && sourceToCopyFrom != null) try {/*from w w w . j a v a2 s .c o m*/ PropertyUtils.copyProperties(targetToCopyTo, sourceToCopyFrom); } catch (Exception ex) { throw new RuntimeException("Failed to copy from source object: " + sourceToCopyFrom.getClass() + " to target object: " + targetToCopyTo, ex); } }
From source file:org.lnicholls.galleon.togo.ToGoThread.java
public void run() { while (true) { try {/*from w w w . j a v a2 s. co m*/ ServerConfiguration serverConfiguration = Server.getServer().getServerConfiguration(); List tivos = (List) serverConfiguration.getTiVos(); log.debug("tivos=" + tivos.size()); ArrayList downloaded = null; synchronized (mToGo) { downloaded = mToGo.getRecordings(tivos, this); } if (downloaded != null && downloaded.size() > 0) { log.debug("downloaded.size()=" + downloaded.size()); List recordings = null; synchronized (mToGo) { recordings = VideoManager.listAll(); } // Remove recordings that dont exist on TiVo anymore Iterator iterator = recordings.listIterator(); while (iterator.hasNext()) { Video next = (Video) iterator.next(); if (next.getStatus() == Video.STATUS_DOWNLOADED || next.getStatus() == Video.STATUS_DELETED) { boolean found = false; Iterator downloadedIterator = downloaded.iterator(); while (downloadedIterator.hasNext()) { Video video = (Video) downloadedIterator.next(); if (video.equals(next)) { found = true; break; } } if (found) { try { next.setAvailability(new Integer(Video.RECORDING_AVAILABLE)); VideoManager.updateVideo(next); } catch (HibernateException ex) { log.error("Video create failed", ex); } } else { try { next.setAvailability(new Integer(Video.RECORDING_DELETED)); VideoManager.updateVideo(next); } catch (HibernateException ex) { log.error("Video create failed", ex); } } } else if (next.getStatus() != Video.STATUS_DOWNLOADED && next.getStatus() != Video.STATUS_DELETED) { boolean found = false; Iterator downloadedIterator = downloaded.iterator(); while (downloadedIterator.hasNext()) { Video video = (Video) downloadedIterator.next(); if (video.equals(next)) { found = true; break; } } if (!found && next.getOrigen() == null) { synchronized (mToGo) { try { VideoManager.deleteVideo(next); } catch (HibernateException ex) { log.error("Video delete failed", ex); } } } } } recordings.clear(); synchronized (mToGo) { recordings = VideoManager.listAll(); } // Update status of recordings iterator = downloaded.iterator(); while (iterator.hasNext()) { Video next = (Video) iterator.next(); boolean found = false; Iterator recordingsIterator = recordings.iterator(); while (recordingsIterator.hasNext()) { Video video = (Video) recordingsIterator.next(); if (video.equals(next)) { synchronized (mToGo) { try { if (video.getStatus() == Video.STATUS_DOWNLOADED || video.getStatus() == Video.STATUS_DOWNLOADING || video.getStatus() == Video.STATUS_USER_SELECTED || video.getStatus() == Video.STATUS_USER_CANCELLED || video.getStatus() == Video.STATUS_INCOMPLETE || video.getStatus() == Video.STATUS_DELETED) next.setStatus(video.getStatus()); next.setAvailability(new Integer(Video.RECORDING_AVAILABLE)); if (video.getStatus() == Video.STATUS_DOWNLOADED) { next.setPath(video.getPath()); next.setDownloadSize(video.getDownloadSize()); next.setDownloadTime(video.getDownloadTime()); next.setDateDownloaded(video.getDateDownloaded()); next.setDateUploaded(video.getDateUploaded()); next.setUploaded(video.getUploaded()); } PropertyUtils.copyProperties(video, next); VideoManager.updateVideo(video); } catch (HibernateException ex) { log.error("Video update failed", ex); } catch (Exception ex) { log.error("Video properties update failed", ex); } } found = true; break; } } if (!found) { synchronized (mToGo) { try { next.setAvailability(new Integer(Video.RECORDING_AVAILABLE)); VideoManager.createVideo(next); } catch (HibernateException ex) { log.error("Video create failed", ex); } } } } synchronized (mToGo) { mToGo.applyRules(); } recordings.clear(); downloaded.clear(); sleep(1000 * 60 * serverConfiguration.getReload()); } else sleep(1000 * 60 * serverConfiguration.getReload()); } catch (InterruptedException ex) { Tools.logException(ToGoThread.class, ex); } // handle silently for waking up catch (Exception ex2) { Tools.logException(ToGoThread.class, ex2); } } }
From source file:org.metamorfosis.model.AbstractJMetaClass.java
protected void copySourceProperties() { if (className != null) { source = instantiateClass(className); }// w ww . j a v a 2 s. com try { // copia todas las propiedades del objeto original // y las pone al servicio con get('originalPropertyName') PropertyUtils.copyProperties(this, source); } catch (Exception ex) { throw new MetaClassException("Error al crear el metapojo", ex); } }
From source file:org.metamorfosis.model.AbstractJMetaClass.java
@Override public void injectFieldProperty(String fieldName, String propertyName, Object propertyValue) { try {//from ww w .j a va2 s . c o m // 1.validar que exista el field y obtenerlo Object fieldObj = PropertyUtils.getNestedProperty(this, fieldName); // 2. MetaClass // datos del objeto original (copySource) JMetaClass metaField = new JMetaClass(fieldObj); Map<String, Object> metaFieldClassProperties = new HashMap(); // datos inyectados (propertyName:propertyValue) metaFieldClassProperties.put(propertyName, propertyValue); metaField.setInjectedClassProperties(metaFieldClassProperties); // datos del metaClassProperty (name, type) HashMap propertiesHash = getMetaClass().getPropertiesHash(); MetaClassProperty metaClassProperty = new MetaClassProperty(); metaClassProperty.setName(fieldName); metaClassProperty.setType(this.getClass()); PropertyUtils.copyProperties(metaField, metaClassProperty); metaField.initialize(); // 3. reemplazar propiedad original con el metaField replaceProperty(fieldName, metaField); // accesible por medio de get propertiesHash.put(fieldName, metaField); // accesible por medio de metaclass.properties } catch (Exception ex) { throw new MetaClassException( "No existe el field '" + fieldName + "' " + "dentro de la clase '" + source + "'", ex); } }
From source file:org.mule.module.fws.api.FwsPaginatedIterable.java
@Override @SuppressWarnings("unchecked") protected final Page nextPage(Page currentPage) { try {//from www .j a va2 s . c o m Page nextPage = (Page) currentPage.getClass().newInstance(); PropertyUtils.copyProperties(nextPage, nextFwsPage(currentPage)); return nextPage; } catch (RemoteException e) { throw new UnhandledException(e); } catch (Exception e) { throw new AssertionError(e); } }