List of usage examples for org.springframework.beans BeanUtils copyProperties
public static void copyProperties(Object source, Object target) throws BeansException
From source file:it.geosolutions.geobatch.ftp.client.configuration.FTPActionConfiguration.java
@Override public FTPActionConfiguration clone() { // throws CloneNotSupportedException // {/*from w w w .ja v a 2 s. com*/ final FTPActionConfiguration configuration = new FTPActionConfiguration(getId(), getName(), getDescription()); BeanUtils.copyProperties(this, configuration); return configuration; }
From source file:com.googlecode.starflow.engine.handle.BaseHandlerAdapter.java
/** * ?//from ww w . j a v a 2 s . c o m * * @param e * @param event * @param activityXml */ protected void handleException(Exception e, ActivityStartEvent event, ActivityElement activityXml) { String exceptionStrategy = activityXml.getExceptionStrategy(); if (Constants.ACT_EXCEPTIONSTRATEGY_ROLLBACK.equals(exceptionStrategy)) throw new ToolAppRollBackException("Action", e); else if (Constants.ACT_EXCEPTIONSTRATEGY_INTERRUPT.equals(exceptionStrategy)) { long activityInstId = event.getActivityInst().getActivityInstId(); event.getActInstRep().updateActivityStateAndFinalTime(activityInstId, StarFlowState.ACT_APP_EXCEPTION, new Date()); throw new InterruptStrategyException(); } else if (Constants.ACT_EXCEPTIONSTRATEGY_APPLICATION.equals(exceptionStrategy)) { String beanName = activityXml.getExceptionAction(); ProcessInstance cloneProcessInstance = new ProcessInstance(); BeanUtils.copyProperties(event.getProcessInstance(), cloneProcessInstance); ActivityInst cloneActivityInst = new ActivityInst(); BeanUtils.copyProperties(event.getActivityInst(), cloneActivityInst); executeExceptionAction(beanName, e, cloneProcessInstance, cloneActivityInst); } else if (Constants.ACT_EXCEPTIONSTRATEGY_STEPROLLBACK.equals(exceptionStrategy)) { throw new UnsupportedOperationException("?"); } else { logger.error("Action", e); } }
From source file:org.sventon.web.command.ConfigCommand.java
/** * Create and populate a RepositoryConfiguration based on the contents of this config command instance. * * @return New, populated RepositoryConfiguration */// w ww . j a v a 2s . c o m public RepositoryConfiguration createRepositoryConfiguration() { final RepositoryConfiguration configuration = new RepositoryConfiguration(getName()); BeanUtils.copyProperties(this, configuration); if (AccessMethod.USER == accessMethod) { configuration.setEnableAccessControl(true); configuration.setUserCredentials(Credentials.EMPTY); } else { configuration.setUserCredentials(new Credentials(userName, userPassword)); } if (isCacheUsed()) { configuration.setCacheCredentials(new Credentials(cacheUserName, cacheUserPassword)); } else { configuration.setCacheCredentials(Credentials.EMPTY); } return configuration; }
From source file:com.greenline.guahao.biz.manager.statistics.impl.StatisticsManagerImpl.java
@Override public MainItemDataDO getStatisticByMainType(String mainType, String mainId) { if (StringUtils.isBlank(mainId)) { return null; }//from w w w . j av a 2 s . c o m try { ResponseDTO<List<MainItemDataDTO>> resp = statisticService .listStatisticByMainType(Integer.valueOf(mainType), new String[] { mainId }); if (ResponseCode.isSuccess(resp.getCode())) { List<MainItemDataDTO> list = resp.getDataResult(); if (list != null && list.size() > 0) { MainItemDataDTO dto = list.get(0); MainItemDataDO mainItemDataDO = new MainItemDataDO(); BeanUtils.copyProperties(dto, mainItemDataDO); return mainItemDataDO; } } else { logs.error("statisticService.listStatisticByMainType(mainType, mainId) error. " + " message:" + resp.getMessage() + " code:" + resp.getCode() + " mainType:" + mainType + " mainId:" + mainId); } } catch (Exception e) { logs.error("statisticService.listStatisticByMainType(mainType, mainId) error. " + " message:" + e.getMessage() + " mainType:" + mainType + " mainId:" + mainId); } return null; }
From source file:com.github.moscaville.contactsdb.controller.BaseController.java
public List<T> loadItems(int count, int itemsLoaded, T t) { List<T> result = new ArrayList<>(); if (!OFFLINE_TEST) { StringBuilder uri = new StringBuilder(); uri.append(AIRTABLE_ENDPOINT_URL).append(getAirTableName()); count = count <= 0 || count > 100 ? 100 : count; uri.append("?limit=").append(count); if (sortColumn != null) { uri.append("&sortField=").append(Utility.toHumanName(sortColumn)); }// w w w. ja v a 2 s. co m RecordCollection recordCollection = restTemplate.getForObject(uri.toString(), getRecordCollection().getClass()); for (Object o : recordCollection.getRecords()) { RecordWrapper recordWrapper = (RecordWrapper) o; Object r = BeanUtils.instantiate(t.getClass()); //BeanUtils.copyProperties(recordWrapper, r); BeanUtils.copyProperties(recordWrapper.getFields(), r); ((AtBaseRecord) r).setId(recordWrapper.getId()); result.add((T) r); } } return result; }
From source file:com.gisgraphy.domain.repository.AbstractTransactionalTestCase.java
/** * Utility method to populate a javabean-style object with values from a * Properties file//from w ww . j a v a 2 s . c om * * @param obj * the model object to populate * @return Object populated object * @throws Exception * if BeanUtils fails to copy properly */ @SuppressWarnings("unchecked") protected Object populate(Object obj) throws Exception { // loop through all the beans methods and set its properties from // its .properties file Map map = PropertiesHelper.convertBundleToMap(rb); BeanUtils.copyProperties(obj, map); return obj; }
From source file:com.greenline.hrs.admin.user.service.UserInfoService.java
/** * ??normalInfo?//from ww w . j av a 2 s .c o m * * @param uid ??id * @return , , ?null. */ public UserNormalInfo getUserNomalInfo(long uid) { UserNickName userNickName = userNickNameBiz.get(uid); UserBasicInfo userBasicInfo = userBasicInfoBiz.getUserBasicInfo(uid); UserNormalInfo userNormalInfo = null; //??null, if (userNickName != null && userBasicInfo != null) { userNormalInfo = new UserNormalInfo(); BeanUtils.copyProperties(userNickName, userNormalInfo); BeanUtils.copyProperties(userBasicInfo, userNormalInfo); } return userNormalInfo; }
From source file:com.bose.aem.spring.config.ConfigClientProperties.java
public ConfigClientProperties override(Environment environment) { ConfigClientProperties override = new ConfigClientProperties(); BeanUtils.copyProperties(this, override); override.setName(environment.resolvePlaceholders( "${" + ConfigClientProperties.PREFIX + ".name:${spring.application.name:application}}")); if (environment.containsProperty(ConfigClientProperties.PREFIX + ".profile")) { override.setProfile(environment.getProperty(ConfigClientProperties.PREFIX + ".profile")); }//www .j a va 2s. co m if (environment.containsProperty(ConfigClientProperties.PREFIX + ".label")) { override.setLabel(environment.getProperty(ConfigClientProperties.PREFIX + ".label")); } return override; }
From source file:com.wandrell.example.swss.client.DefaultEntityClient.java
/** * Sends an id to the endpoint and receives back the data for the entity * with that same id./*from ww w. jav a 2s . c o m*/ * <p> * If for some reason, which may be caused by the id being invalid, an empty * response, or not response at all, is received then an entity with a * negative id will be returned. * <p> * The SOAP request will include, in the HTTP header, the SOAP action. This * way the unreachable endpoint error caused by some authentication methods, * such as encryption, can be avoided. * * @param uri * URI to the endpoint * @param identifier * id of the queried entity * @return the entity with the received id */ @Override public final ExampleEntity getEntity(final String uri, final Integer identifier) { final GetEntityRequest request; // Request for acquiring the entity final GetEntityResponse response; // Response with the result final ExampleEntity entity; // Entity with the response data final WebServiceMessageCallback callback; // SOAP action callback checkNotNull(uri, "Received a null pointer as URI"); checkNotNull(identifier, "Received a null pointer as entity id"); LOGGER.debug(String.format("Querying URI %1$s for id %2$d", uri, identifier)); // Generates request request = new GetEntityRequest(); request.setId(identifier); // Prepares callback callback = new SoapActionCallback(ExampleEntityEndpointConstants.ACTION); // Sends request and receives response response = (GetEntityResponse) getWebServiceTemplate().marshalSendAndReceive(uri, request, callback); if ((response == null) || (response.getEntity() == null)) { // No response was received entity = new DefaultExampleEntity(); entity.setName(""); entity.setId(-1); LOGGER.debug("No response received"); } else { entity = new DefaultExampleEntity(); if (response.getEntity().getName() == null) { // The response was empty entity.setName(""); entity.setId(-1); LOGGER.debug("Received an empty response"); } else { // The response was not empty BeanUtils.copyProperties(response.getEntity(), entity); LOGGER.debug(String.format("Received response with id %1$d and name %2$s", entity.getId(), entity.getName())); } } return entity; }
From source file:net.kamhon.ieagle.util.ReflectionUtil.java
public static void copyProperties(Object source, Object target, String... ignoreProperties) { if (ignoreProperties == null) BeanUtils.copyProperties(source, target); else//from w w w .jav a2 s . co m BeanUtils.copyProperties(source, target, ignoreProperties); }