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.floreantpos.bo.ui.explorer.QuickMaintenanceExplorer.java
private static void quickMaintainMenuCategory(MenuCategory menuCategory) { try {/*from w w w .j a v a 2 s. c om*/ if (menuCategory.getId() != null) { if (btnCopy.isSelected()) { MenuCategory newMenuCategory = new MenuCategory(); PropertyUtils.copyProperties(newMenuCategory, menuCategory); newMenuCategory.setId(null); menuCategory = newMenuCategory; } else if (btnDelete.isSelected()) { if (POSMessageDialog.showYesNoQuestionDialog(POSUtil.getFocusedWindow(), POSConstants.CONFIRM_DELETE, POSConstants.DELETE) != JOptionPane.YES_OPTION) { return; } MenuGroupDAO menuGroupDao = new MenuGroupDAO(); List<MenuGroup> menuGroups = menuGroupDao.findByParent(menuCategory); if (menuGroups.size() > 0) { if (POSMessageDialog.showYesNoQuestionDialog(POSUtil.getFocusedWindow(), Messages.getString("MenuCategoryExplorer.0"), //$NON-NLS-1$ POSConstants.DELETE) != JOptionPane.YES_OPTION) { return; } menuGroupDao.releaseParent(menuGroups); } MenuCategoryDAO dao = new MenuCategoryDAO(); dao.delete(menuCategory); OrderView.getInstance().getCategoryView().updateView(menuCategory); return; } } MenuCategoryForm editor = new MenuCategoryForm(menuCategory); BeanEditorDialog dialog = new BeanEditorDialog(Application.getPosWindow(), editor); dialog.open(); if (dialog.isCanceled()) return; OrderView.getInstance().getCategoryView().updateView(menuCategory); return; } catch (Exception e) { return; } }
From source file:gov.nih.nci.rembrandt.web.struts2.action.EditClinicalDataAction.java
public String execute() { form = new ClinicalDataForm(); form.reset(this.servletRequest); String sessionId = this.servletRequest.getSession().getId(); SessionQueryBag queryBag = presentationTierCache.getSessionQueryBag(sessionId); String queryKey = (String) this.servletRequest.getAttribute("queryKey"); if (queryBag != null) { //get the Form from the sessionQB ClinicalDataForm origCdForm = (ClinicalDataForm) queryBag.getFormBeanMap().get(queryKey); try {// ww w. j a va2 s . c o m //try this, else call each setter PropertyUtils.copyProperties(form, origCdForm); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } // cdForm = origCdForm.cloneMe(); } String editForward = ""; if (this.copy.equalsIgnoreCase("true")) form.setQueryName(form.getQueryName() + "_copy"); editForward = "goEditClinical"; //saveToken(request); return editForward; }
From source file:com.jdon.jivejdon.service.imp.shortmessage.ShortMessageServiceImp.java
/** * ? ?PageIterator/*from ww w.j a v a 2s.c o m*/ */ public FromShortMessage getFromShortMessage(Long msgId) { logger.debug("ShortMessageServiceImp getFromShortMessage"); ShortMessage smsg = this.factory.findShortMessage(msgId); Account loginaccount = this.sessionContextUtil.getLoginAccount(sessionContext); // check auth if (!smsg.getMessageFrom().equals(loginaccount.getUsername())) { logger.error("msgId=" + msgId + " is not this user's =" + loginaccount.getUserId()); return null; } FromShortMessage fromsmsg = new FromShortMessage(); try { PropertyUtils.copyProperties(fromsmsg, smsg); } catch (Exception e) { e.printStackTrace(); } return fromsmsg; }
From source file:gov.nih.nci.rembrandt.web.struts2.action.EditCGHAction.java
public String execute() { // Shan: commented out. Why are they needed. // HttpSession session = request.getSession(); // if (form == null) { ////from w w w. ja va 2s .c om // form = new ComparativeGenomicForm(); // if ("request".equals(mapping.getScope())) // request.setAttribute(mapping.getAttribute(), form); // else // session.setAttribute(mapping.getAttribute(), form); // } //ComparativeGenomicForm cdForm = (ComparativeGenomicForm) form; form = new ComparativeGenomicForm(); form.reset(servletRequest); String sessionId = this.servletRequest.getSession().getId(); SessionQueryBag queryBag = presentationTierCache.getSessionQueryBag(sessionId); String queryKey = (String) this.servletRequest.getAttribute("queryKey"); if (queryBag != null) { // get the Form from the sessionQB ComparativeGenomicForm origCdForm = (ComparativeGenomicForm) queryBag.getFormBeanMap().get(queryKey); try { // try this, else call each setter PropertyUtils.copyProperties(form, origCdForm); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } } String editForward = ""; if (this.copy.equalsIgnoreCase("true")) form.setQueryName(form.getQueryName() + "_copy"); editForward = "goEditCGH"; // Show RegionView DIV if (form.getGeneList() == null || form.getGeneList().length() == 0) { this.servletRequest.setAttribute("selectedView", "regionView"); } return editForward; }
From source file:gov.nih.nci.rembrandt.web.struts2.action.EditGEAction.java
public String execute() { // HttpSession session = request.getSession(); // if (form == null) { // // form = new GeneExpressionForm(); // if ("request".equals(mapping.getScope())) // request.setAttribute(mapping.getAttribute(), form); // else // session.setAttribute(mapping.getAttribute(), form); // }//from ww w. j a v a 2 s . c o m this.form = new GeneExpressionForm(); this.form.reset(this.servletRequest); String sessionId = this.servletRequest.getSession().getId(); SessionQueryBag queryBag = presentationTierCache.getSessionQueryBag(sessionId); //String queryKey = (String) this.servletRequest.getAttribute("queryKey"); if (queryBag != null) { //get the Form from the sessionQB GeneExpressionForm origCdForm = (GeneExpressionForm) queryBag.getFormBeanMap().get(this.queryKey); try { //try this, else call each setter form.setUpGeneAndCloneList(this.servletRequest); PropertyUtils.copyProperties(form, origCdForm); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /* * resets the dropdowns that the saved form will need in order to render the page * and save the value. */ // GroupRetriever groupRetriever = new GroupRetriever(); // cdForm.setSavedSampleList(groupRetriever.getClinicalGroupsCollectionNoPath(request.getSession())); String editForward = ""; //if(this.servletRequest.getAttribute("copy")!=null && ((String) this.servletRequest.getAttribute("copy")).equals("true")) if (this.copy.equalsIgnoreCase("true")) form.setQueryName(form.getQueryName() + "_copy"); if (form.getChromosomes() == null || form.getChromosomes().isEmpty()) { //if (form.getChromosomeNumber().equals("-1")){ //set the chromsomes list in the form logger.debug("Setup the chromosome values for the form"); form.setChromosomes(ChromosomeHelper.getInstance().getChromosomes()); } editForward = "goEditGE"; //saveToken(request); //this.form = cdForm; return editForward; }
From source file:com.evanzeimet.queryinfo.it.feature.base.BaseSteps.java
protected List<PersonEntity> createPersonEntities(List<TestPerson> testPeople) { personToEmployerOrganizationIdMapper.setReferrerReferencePersistenceIdsForTestIds(testPeople); int personCount = testPeople.size(); List<PersonEntity> result = new ArrayList<>(personCount); for (TestPerson person : testPeople) { PersonEntity personEntity = new PersonEntity(); try {/* www. ja va2s.c om*/ PropertyUtils.copyProperties(personEntity, person); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new QueryInfoRuntimeException(e); } result.add(personEntity); } return result; }
From source file:gov.nih.nci.caarray.application.permissions.PermissionsManagementServiceBean.java
private User convertToLikeProperties(User u) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { final User newUser = new User(); if (u != null) { PropertyUtils.copyProperties(newUser, u); for (final PropertyDescriptor pd : PropertyUtils.getPropertyDescriptors(newUser)) { convertToLikeProperty(u, newUser, pd); }/* ww w. j a v a2 s . com*/ } return newUser; }
From source file:com.jdon.jivejdon.service.imp.shortmessage.ShortMessageServiceImp.java
public ToShortMessage getToShortMessage(Long msgId) { logger.debug("ShortMessageServiceImp getToShortMessage"); ShortMessage smsg = this.factory.findShortMessage(msgId); Account loginaccount = this.sessionContextUtil.getLoginAccount(sessionContext); // check auth if (!smsg.getMessageTo().equals(loginaccount.getUsername())) { logger.error("msgId=" + msgId + " is not this user's =" + loginaccount.getUserId()); return null; }/* w w w . j a v a2 s . c o m*/ ToShortMessage tosmsg = new ToShortMessage(); try { PropertyUtils.copyProperties(tosmsg, smsg); } catch (Exception e) { e.printStackTrace(); } return tosmsg; }
From source file:jp.co.opentone.bsol.linkbinder.view.common.LoginPage.java
private void storeLoginUser(User login) { // ??session????? // ???Spring?????????????????? try {/*from w ww . jav a2 s . c o m*/ User current = getCurrentUser(); if (current != null) { if (current.getUserId() != null && !current.getUserId().equals(login.getUserId())) { clearLoginInfo(); } PropertyUtils.copyProperties(current, login); } LoginUserInfoHolder holder = getLoginUserInfoHolder(); holder.setLoginUser(current); } catch (IllegalAccessException e) { throw new ApplicationFatalRuntimeException(e); } catch (InvocationTargetException e) { throw new ApplicationFatalRuntimeException(e); } catch (NoSuchMethodException e) { throw new ApplicationFatalRuntimeException(e); } }
From source file:jp.co.opentone.bsol.linkbinder.view.filter.LoginFilter.java
private void copyAttributes(HttpSession session, Map<String, Object> attributes) { try {//from w ww . j a va 2s . c om for (Map.Entry<String, Object> e : attributes.entrySet()) { if (session.getAttribute(e.getKey()) != null) { if (e.getValue() != null) { if (log.isDebugEnabled()) { log.debug("Value '{}' exists, so copy properties.", e.getKey()); } Object dest = session.getAttribute(e.getKey()); PropertyUtils.copyProperties(dest, e.getValue()); } } else { session.setAttribute(e.getKey(), e.getValue()); } } } catch (IllegalAccessException e) { throw new ApplicationFatalRuntimeException(e); } catch (InvocationTargetException e) { throw new ApplicationFatalRuntimeException(e); } catch (NoSuchMethodException e) { throw new ApplicationFatalRuntimeException(e); } }