Java Code Examples for org.apache.commons.beanutils.BeanUtils#copyProperties()
The following examples show how to use
org.apache.commons.beanutils.BeanUtils#copyProperties() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpringWebHttpFramework.java From xDoc with MIT License | 6 votes |
/** * 构建基于spring web的接口 * * @param apiAction 请求的Action信息 * @param isjson 是否json * @return 封装后的机遇SpringWeb的Action信息 */ private HttpApiAction buildSpringApiAction(ApiModule apiModule, ApiAction apiAction, boolean isjson) { HttpApiAction saa = new HttpApiAction(); try { BeanUtils.copyProperties(saa, apiAction); } catch (Exception e) { logger.error("copy ApiAction to HttpApiAction properties error", e); return null; } if (isjson || apiAction.getMethod().getAnnotation(ResponseBody.class) != null) { saa.setJson(true); } boolean isMappingMethod = this.setUrisAndMethods(apiModule, apiAction, saa); if (!isMappingMethod) { return null; } return saa; }
Example 2
Source File: GetIssuerOperation.java From oxd with Apache License 2.0 | 6 votes |
public IOpResponse execute(GetIssuerParams params) { try { OpenIdConnectDiscoveryClient client = new OpenIdConnectDiscoveryClient(params.getResource()); OpenIdConnectDiscoveryResponse response = client.exec(); if (response == null) { LOG.error("Error in fetching op discovery configuration response "); throw new HttpException(ErrorResponseCode.FAILED_TO_GET_ISSUER); } GetIssuerResponse webfingerResponse = new GetIssuerResponse(); BeanUtils.copyProperties(webfingerResponse, response); return webfingerResponse; } catch (Exception e) { LOG.error("Error in creating op discovery configuration response ", e); } throw new HttpException(ErrorResponseCode.FAILED_TO_GET_ISSUER); }
Example 3
Source File: ProcessController.java From easyweb with Apache License 2.0 | 6 votes |
@ResponseBody @PostMapping("/index") @ApiOperation(value = "工作流管理") public Object index(HttpServletRequest request, HttpServletResponse response) throws Exception { // ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); // RepositoryService repositoryService = processEngine.getRepositoryService(); Page<Process> pg = new Page<Process>(request, response); List<ProcessDefinition> definitions = repositoryService.createProcessDefinitionQuery().listPage(pg.getPage() - 1, pg.getPageSize()); long count = repositoryService.createProcessDefinitionQuery().count(); List<Process> list = new ArrayList<Process>(); if (definitions != null) { for (ProcessDefinition item : definitions) { Process p = new Process(); BeanUtils.copyProperties(p, item); list.add(p); } } pg.setList(list); pg.setRecords(count); return pg; }
Example 4
Source File: BeanUtil.java From MaxKey with Apache License 2.0 | 5 votes |
public static Object cloneSupper(Object origin) { Object target = null; if(origin == null) return target; try { target = origin.getClass().getSuperclass().newInstance(); BeanUtils.copyProperties(target,origin); } catch (Exception e) { e.printStackTrace(); } return target; }
Example 5
Source File: AbstractHttpFramework.java From xDoc with MIT License | 5 votes |
@Override public List<ApiModule> extend(List<ApiModule> apiModules) { for (ApiModule apiModule : apiModules) { for (int i = 0; i < apiModule.getApiActions().size(); i++) { ApiAction oldApiAction = apiModule.getApiActions().get(i); HttpApiAction newApiAction = new HttpApiAction(); try { BeanUtils.copyProperties(newApiAction, oldApiAction); } catch (Exception e) { logger.error("copy ApiAction to HttpApiAction properties error", e); return new ArrayList<>(0); } newApiAction.setTitle(this.getTitile(newApiAction)); newApiAction.setRespbody(this.getRespbody(newApiAction)); newApiAction.setParams(this.getParams(newApiAction)); newApiAction.setRespParam(this.getResp(newApiAction)); newApiAction.setReturnObj(this.getSeeObj(newApiAction)); newApiAction.setReturnDesc(this.getReturnDesc(newApiAction)); newApiAction.setParamObjs(this.getParamObjs(newApiAction)); apiModule.getApiActions().set(i, newApiAction); } } return apiModules; }
Example 6
Source File: WorkItemStateModel.java From telekom-workflow-engine with MIT License | 5 votes |
public static WorkItemStateModel create( WorkItemState woit ){ WorkItemStateModel model = new WorkItemStateModel(); try{ BeanUtils.copyProperties( model, woit ); } catch( IllegalAccessException | InvocationTargetException e ){ throw new RuntimeException( "Error creating model", e ); } return model; }
Example 7
Source File: NetSuiteClientServiceImpl.java From components with Apache License 2.0 | 5 votes |
@Override protected SearchPreferences createNativeSearchPreferences(NsSearchPreferences nsSearchPreferences) { SearchPreferences searchPreferences = new SearchPreferences(); try { BeanUtils.copyProperties(searchPreferences, nsSearchPreferences); } catch (IllegalAccessException | InvocationTargetException e) { throw new NetSuiteException(e.getMessage(), e); } return searchPreferences; }
Example 8
Source File: GetDiscoveryOperation.java From oxd with Apache License 2.0 | 5 votes |
public IOpResponse execute(GetDiscoveryParams params) { OpenIdConfigurationResponse discoveryResponse = getDiscoveryService().getConnectDiscoveryResponse(params.getOpConfigurationEndpoint(), params.getOpHost(), params.getOpDiscoveryPath()); GetDiscoveryResponse response = new GetDiscoveryResponse(); try { BeanUtils.copyProperties(response, discoveryResponse); return response; } catch (IllegalAccessException | InvocationTargetException e) { LOG.error("Error in creating op discovery configuration response ", e); } throw new HttpException(ErrorResponseCode.FAILED_TO_GET_DISCOVERY); }
Example 9
Source File: Semester.java From sakai with Educational Community License v2.0 | 5 votes |
public static Semester createCopy(Semester otherSemester){ Semester s = new Semester(); try { BeanUtils.copyProperties(s, otherSemester); } catch (IllegalAccessException | InvocationTargetException e) { log.warn("Could copy properties", e); } return s; }
Example 10
Source File: DbConsoleController.java From bdf3 with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @DataResolver public void saveTableColumn(Collection<ColumnInfo> coll, Map<String, Object> map) throws Exception { String dbInfoId = (String) map.get("dbInfoId"); String tableName = (String) map.get("tableName"); for (Iterator<ColumnInfo> iter = EntityUtils.getIterator(coll, FilterType.ALL); iter.hasNext();) { ColumnInfo columnInfo = iter.next(); columnInfo.setTableName(tableName); EntityState state = EntityUtils.getState(columnInfo); if (state.equals(EntityState.NEW)) { dbService.insertColumn(dbInfoId, columnInfo); } if (state.equals(EntityState.MODIFIED)) { EntityEnhancer entityEnhancer = EntityUtils.getEntityEnhancer(columnInfo); String oldDefaultValue = null; if (entityEnhancer != null) { Map<String, Object> oldValues = entityEnhancer.getOldValues(); if (oldValues.get("defaultValue") != null) { oldDefaultValue = (String) oldValues.get("defaultValue"); } } ColumnInfo oldColumnInfo = new ColumnInfo(); BeanUtils.copyProperties(oldColumnInfo, columnInfo); oldColumnInfo.setColumnName(EntityUtils.getOldString(columnInfo, "columnName")); oldColumnInfo.setIsnullAble(EntityUtils.getOldBoolean(columnInfo, "isnullAble")); oldColumnInfo.setIsprimaryKey(EntityUtils.getOldBoolean(columnInfo, "isprimaryKey")); oldColumnInfo.setDefaultValue(oldDefaultValue); dbService.updateColumn(dbInfoId, oldColumnInfo, columnInfo); } if (state.equals(EntityState.DELETED)) { dbService.deleteColumn(dbInfoId, tableName, columnInfo.getColumnName()); } } }
Example 11
Source File: LtiConsumerManagementController.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Edits specified LTI tool consumer */ @RequestMapping(path = "/edit") public String edit(@ModelAttribute LtiConsumerForm ltiConsumerForm, HttpServletRequest request) throws Exception { Integer sid = WebUtil.readIntParam(request, "sid", true); // editing a tool consumer if (sid != null) { ExtServer ltiConsumer = integrationService.getExtServer(sid); BeanUtils.copyProperties(ltiConsumerForm, ltiConsumer); } else { // do nothing in case of creating a tool consumer } return "integration/ltiConsumer"; }
Example 12
Source File: DataSourceConfig.java From tinyid with Apache License 2.0 | 5 votes |
private void buildDataSourceProperties(DataSource dataSource, Map<String, Object> dsMap) { try { // 此方法性能差,慎用 BeanUtils.copyProperties(dataSource, dsMap); } catch (Exception e) { logger.error("error copy properties", e); } }
Example 13
Source File: WebRuleUtils.java From rice with Educational Community License v2.0 | 5 votes |
public static void copyResponsibility(RuleResponsibilityBo source, RuleResponsibilityBo target) { try { BeanUtils.copyProperties(target, source); } catch (Exception e) { throw new RiceRuntimeException("Failed to copy properties from source to target responsibility", e); } }
Example 14
Source File: AtlasExtensionOutput.java From atlas with Apache License 2.0 | 5 votes |
private void copyProps(Object dest, Object orig) { if (orig == null) { return; } try { BeanUtils.copyProperties(dest, orig); } catch (Throwable e) { e.printStackTrace(); } }
Example 15
Source File: NetSuiteClientServiceImpl.java From components with Apache License 2.0 | 5 votes |
@Override protected Preferences createNativePreferences(NsPreferences nsPreferences) { Preferences preferences = new Preferences(); try { BeanUtils.copyProperties(preferences, nsPreferences); } catch (IllegalAccessException | InvocationTargetException e) { throw new NetSuiteException(e.getMessage(), e); } return preferences; }
Example 16
Source File: Version.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
/** * Factory method that creates a Version and replicate all given document's * properties.<br> * The new version and fileVersion will be set in both Document and * Version<br> * <br> * <b>Important:</b> The created Version is not persistent * * @param document The document to be versioned * @param user The user who made the changes * @param comment The version comment * @param event The event that caused the new release * @param release True if this is a new release(eg: 2.0) rather than a * subversion(eg: 1.1) * @return The newly created version */ public static Version create(Document document, User user, String comment, String event, boolean release) { Version version = new Version(); try { BeanUtils.copyProperties(version, document); } catch (Exception e) { } version.setVersion(document.getVersion()); version.setType(document.getType()); version.setTenantId(document.getTenantId()); version.setDeleted(0); version.setRecordVersion(0); version.setComment(comment); document.setComment(comment); version.setEvent(event); version.setUserId(user.getId()); version.setUsername(user.getFullName()); version.setOcrTemplateId(document.getOcrTemplateId()); version.setBarcodeTemplateId(document.getBarcodeTemplateId()); if (document.getTemplate() != null) { version.setTemplateId(document.getTemplate().getId()); version.setTemplateName(document.getTemplate().getName()); } version.setAttributes(new HashMap<String, Attribute>()); if (document.getAttributes() != null) { try { for (String name : document.getAttributeNames()) { version.getAttributes().put(name, document.getAttributes().get(name)); } } catch (Throwable t) { } } version.setFolderId(document.getFolder().getId()); version.setFolderName(document.getFolder().getName()); version.setTgs(document.getTagsString()); version.setDocId(document.getId()); version.setLinks(document.getLinks()); version.setPublished(document.getPublished()); version.setStartPublishing(document.getStartPublishing()); version.setStopPublishing(document.getStopPublishing()); String newVersionName = document.getVersion(); if (!event.equals(Version.EVENT_STORED)) { newVersionName = version.getNewVersionName(document.getVersion(), release); version.setVersion(newVersionName); document.setVersion(newVersionName); } // If the file changed, than the file version must be changed also if (Version.EVENT_CHECKIN.equals(event) || Version.EVENT_STORED.equals(event) || StringUtils.isEmpty(document.getFileVersion())) { version.setFileVersion(newVersionName); document.setFileVersion(newVersionName); } version.setExtResId(document.getExtResId()); version.setId(0); return version; }
Example 17
Source File: ProfileSaveController.java From lams with GNU General Public License v2.0 | 4 votes |
@RequestMapping(path = "/saveprofile", method = RequestMethod.POST) public String execute(@ModelAttribute("newForm") UserForm userForm, @RequestParam boolean editNameOnly, HttpServletRequest request) throws IllegalAccessException, InvocationTargetException { MultiValueMap<String, String> errorMap = new LinkedMultiValueMap<>(); if (!Configuration.getAsBoolean(ConfigurationKeys.PROFILE_EDIT_ENABLE)) { if (!Configuration.getAsBoolean(ConfigurationKeys.PROFILE_PARTIAL_EDIT_ENABLE)) { return "forward:/profile/edit.do"; } } request.setAttribute("submitted", true); // (dyna)form validation //first name validation String firstName = (userForm.getFirstName() == null) ? null : (String) userForm.getFirstName(); if (StringUtils.isBlank(firstName)) { errorMap.add("firstName", messageService.getMessage("error.firstname.required")); } else if (!ValidationUtil.isFirstLastNameValid(firstName)) { errorMap.add("firstName", messageService.getMessage("error.firstname.invalid.characters")); } //last name validation String lastName = (userForm.getLastName() == null) ? null : (String) userForm.getLastName(); if (StringUtils.isBlank(lastName)) { errorMap.add("lastName", messageService.getMessage("error.lastname.required")); } else if (!ValidationUtil.isFirstLastNameValid(lastName)) { errorMap.add("lastName", messageService.getMessage("error.lastname.invalid.characters")); } //user email validation if (!editNameOnly) { String userEmail = (userForm.getEmail() == null) ? null : (String) userForm.getEmail(); if (StringUtils.isBlank(userEmail)) { errorMap.add("email", messageService.getMessage("error.email.required")); } else if (!ValidationUtil.isEmailValid(userEmail)) { errorMap.add("email", messageService.getMessage("error.valid.email.required")); } //country validation String country = (userForm.getCountry() == null) ? null : (String) userForm.getCountry(); if (StringUtils.isBlank(country) || "0".equals(country)) { errorMap.add("email", messageService.getMessage("error.country.required")); } } if (!errorMap.isEmpty()) { request.setAttribute("errorMap", errorMap); return "forward:/profile/edit.do"; } User requestor = userManagementService.getUserByLogin(request.getRemoteUser()); if (!Configuration.getAsBoolean(ConfigurationKeys.PROFILE_EDIT_ENABLE) && Configuration.getAsBoolean(ConfigurationKeys.PROFILE_PARTIAL_EDIT_ENABLE)) { // update only contact fields requestor.setEmail(userForm.getEmail()); requestor.setDayPhone(userForm.getDayPhone()); requestor.setEveningPhone(userForm.getEveningPhone()); requestor.setMobilePhone(userForm.getMobilePhone()); requestor.setFax(userForm.getFax()); } else if (editNameOnly) { requestor.setFirstName(userForm.getFirstName()); requestor.setLastName(requestor.getLastName()); } else { // update all fields BeanUtils.copyProperties(requestor, userForm); SupportedLocale locale = (SupportedLocale) userManagementService.findById(SupportedLocale.class, userForm.getLocaleId()); requestor.setLocale(locale); Theme cssTheme = (Theme) userManagementService.findById(Theme.class, userForm.getUserTheme()); requestor.setTheme(cssTheme); } userManagementService.saveUser(requestor); // replace UserDTO in the shared session HttpSession ss = SessionManager.getSession(); ss.setAttribute(AttributeNames.USER, requestor.getUserDTO()); return "forward:/profile/view.do"; }
Example 18
Source File: AcademicSessionLogicImpl.java From sakai with Educational Community License v2.0 | 4 votes |
@Override public void updateSemester(String oldEID, Semester newValues) throws NoSuchKeyException { log.debug("update Semester!"); checkAccess(); AcademicSession session = cmService.getAcademicSession(oldEID); if (session != null) { String oldTitle = session.getTitle(); String newTitle = newValues.getTitle(); String newEID = newValues.getEid(); final boolean EID_CHANGED = !newEID.equals(oldEID); final boolean TITLE_CHANGED = !newTitle.equals(oldTitle); // update DB updateAcademicSessionPropertiesFromSemester(session, newValues); asSakaiProxy.updateAcademicSession(session); updateCurrentStatus(newValues); Semester oldData = getSemester(oldEID); // updates site table log.debug("oldEID={} | newEID={} | oldTitle={} | newTitle={}", oldEID, newEID, oldTitle, newTitle); if (EID_CHANGED || TITLE_CHANGED) { updateAllSites(oldEID, newEID, newTitle); } // update cache if (!oldData.equals(newValues)) { log.debug("updating the cached Semester instance with new values"); // it might be a bit safer to use the "newValues" object itself, but in theory // it should be enough to copy over the values to update the caches.. try { BeanUtils.copyProperties(oldData, newValues); } catch (IllegalAccessException | InvocationTargetException e) { // TODO Auto-generated catch block log.warn("Could not copy properties", e); } // ..unless, of course, it was the EID that has been updated. // because that is also used as the cache key for the single element cache. // Shouldn't affect the cached list, though. cache.remove(oldEID); cache.put(new Element(newValues.getEid(), oldData)); } else { log.debug("was given a reference to the cached Semester instance, i.e. the cache is already updated"); } asSakaiProxy.notifyEventServiceOfUpdate(oldEID); if (EID_CHANGED) { asSakaiProxy.notifyEventServiceOfUpdate(newEID); } } else { throw new NoSuchKeyException("E-ID \"" + oldEID + "\" of the AcademicSession I'm supposed to update doesn't exist in the database"); } }
Example 19
Source File: MailingImpl.java From openemm with GNU Affero General Public License v3.0 | 4 votes |
@Override public Object clone(ApplicationContext con) { Mailing tmpMailing = (Mailing) con.getBean("Mailing"); MailingComponent compNew = null; TrackableLink linkNew = null; DynamicTag tagNew = null; DynamicTagContent contentNew = null; try { ConvertUtils.register(new DateConverter(null), Date.class); // copy components for (MailingComponent compOrg : components.values()) { compNew = (MailingComponent) con.getBean("MailingComponent"); BeanUtils.copyProperties(compNew, compOrg); if (compOrg.getBinaryBlock() != null) { compNew.setBinaryBlock(compOrg.getBinaryBlock(), compOrg.getMimeType()); } else { compNew.setEmmBlock(compOrg.getEmmBlock(), compOrg.getMimeType()); } compNew.setId(0); compNew.setMailingID(0); tmpMailing.addComponent(compNew); } // copy dyntags for (DynamicTag tagOrg : dynTags.values()) { tagNew = (DynamicTag) con.getBean("DynamicTag"); for (DynamicTagContent contentOrg : tagOrg.getDynContent().values()) { contentNew = (DynamicTagContent) con.getBean("DynamicTagContent"); BeanUtils.copyProperties(contentNew, contentOrg); contentNew.setId(0); contentNew.setDynNameID(0); tagNew.addContent(contentNew); } tagNew.setCompanyID(tagOrg.getCompanyID()); tagNew.setDynName(tagOrg.getDynName()); tagNew.setDisableLinkExtension(tagOrg.isDisableLinkExtension()); tmpMailing.addDynamicTag(tagNew); } // copy urls for (TrackableLink linkOrg : trackableLinks.values()) { linkNew = (TrackableLink) con.getBean("TrackableLink"); BeanUtils.copyProperties(linkNew, linkOrg); linkNew.setId(0); linkNew.setMailingID(0); linkNew.setActionID(linkOrg.getActionID()); tmpMailing.getTrackableLinks().put(linkNew.getFullUrl(), linkNew); } // copy active media types for (Entry<Integer, Mediatype> entry : mediatypes.entrySet()) { Mediatype mediatype = entry.getValue(); if (mediatype.getStatus() == Mediatype.STATUS_ACTIVE) { Mediatype mediatypeCopy = mediatype.copy(); tmpMailing.getMediatypes().put(entry.getKey(), mediatypeCopy); } } tmpMailing.setOpenActionID(openActionID); tmpMailing.setClickActionID(clickActionID); return tmpMailing; } catch (Exception e) { logger.error("could not copy", e); return null; } }
Example 20
Source File: BaseBean.java From development with Apache License 2.0 | 3 votes |
/** * Invoke the BeanUtils.copyProperties() method and convert the possible * exceptions into SaaSSystemExceptions * * @param dest * the destination object * @param orig * the source object */ public void copyProperties(final Object dest, final Object orig) { try { BeanUtils.copyProperties(dest, orig); } catch (IllegalAccessException | InvocationTargetException e) { throw new SaaSSystemException(e); } }