List of usage examples for com.vaadin.data Binder writeBean
public void writeBean(BEAN bean) throws ValidationException
From source file:org.jpos.qi.eeuser.ConsumersHelper.java
License:Open Source License
@Override public boolean updateEntity(Binder binder) throws BLException { try {/* w w w. j av a2s .com*/ return (boolean) DB.execWithTransaction((db) -> { Consumer oldConsumer = (Consumer) ((Consumer) getOriginalEntity()).clone(); binder.writeBean(getOriginalEntity()); Consumer newConsumer = (Consumer) getOriginalEntity(); db.session().merge(newConsumer); return addRevisionUpdated(db, getEntityName(), String.valueOf(newConsumer.getId()), oldConsumer, newConsumer, new String[] { "active", "roles", "startDate", "endDate" }); }); } catch (Exception e) { getApp().getLog().error(e); return false; } }
From source file:org.jpos.qi.eeuser.RolesHelper.java
License:Open Source License
@Override public boolean updateEntity(Binder binder) throws BLException { try {/* w w w .j av a 2s .c o m*/ return (boolean) DB.execWithTransaction((db) -> { Role oldRole = (Role) ((Role) getOriginalEntity()).clone(); binder.writeBean(getOriginalEntity()); Role r = (Role) getOriginalEntity(); db.session().merge(r); return addRevisionUpdated(db, getEntityName(), String.valueOf(r.getId()), oldRole, r, new String[] { "name", "permissions" }); }); } catch (Exception e) { throw new BLException(e.getMessage()); } }
From source file:org.jpos.qi.minigl.AccountsHelper.java
License:Open Source License
@Override public boolean updateEntity(Binder binder) throws BLException { try {//from www . j a v a2 s . c o m return (boolean) DB.execWithTransaction((db) -> { Account oldAcct = (Account) ((Account) getOriginalEntity()).clone(); binder.writeBean(getOriginalEntity()); Account a = (Account) getOriginalEntity(); db.session().merge(a); return addRevisionUpdated(db, getEntityName(), String.valueOf(a.getId()), oldAcct, a, new String[] { "code", "description", "created", "expired" }); }); } catch (Exception e) { getApp().getLog().error(e); return false; } }
From source file:org.jpos.qi.minigl.TransactionsHelper.java
License:Open Source License
protected boolean updateEntity(Binder binder, EntryGrid entryGrid, boolean shouldReverse) throws BLException { boolean wasUpdated; try {/* ww w. j a v a2 s . co m*/ wasUpdated = (boolean) DB.execWithTransaction((db) -> { GLTransaction oldTxn = ((GLTransaction) getOriginalEntity()).clone(); binder.writeBean(getOriginalEntity()); GLTransaction txn = (GLTransaction) getOriginalEntity(); db.session().merge(txn); boolean addedRevision = addRevisionUpdated(db, getEntityName(), String.valueOf(txn.getId()), oldTxn, txn, new String[] { "id", "detail", "tags", "postDate" }); if (shouldReverse) { //Create reverse GLTransaction reverse = txn.createReverse(); //Add the entries to the ones reversed. GLTransaction entryGridTxn = entryGrid.getValue(); List<GLEntry> entries = entryGridTxn.getEntries(); //Reset ids to 0 for (GLEntry e : entries) e.setId(0); reverse.getEntries().addAll(entryGridTxn.getEntries()); GLSession glSession = new GLSession(db); glSession.post(txn.getJournal(), reverse); addRevisionCreated(db, getEntityName(), String.valueOf(reverse.getId())); addedRevision = true; } return addedRevision; }); } catch (Exception e) { throw new BLException(e.getMessage()); } return wasUpdated; }
From source file:org.jpos.qi.sysconfig.SysConfigHelper.java
License:Open Source License
@Override public boolean updateEntity(Binder binder) throws BLException { try {/* w ww .ja v a 2s.c om*/ return (boolean) DB.execWithTransaction((db) -> { SysConfig oldSysConfig = (SysConfig) ((SysConfig) getOriginalEntity()).clone(); binder.writeBean(getOriginalEntity()); SysConfig s = (SysConfig) getOriginalEntity(); //need to re-set prefix to id as it gets deleted on write s.setId(addPrefix(s.getId())); db.session().merge(s); return addRevisionUpdated(db, getEntityName(), String.valueOf(s.getId()), oldSysConfig, s, new String[] { "value" }); }); } catch (Exception e) { QI.getQI().getLog().error(e); return false; } }