details: https://code.openbravo.com/erp/devel/pi/rev/72e0f315fe57 changeset: 17720:72e0f315fe57 user: Martin Taal <martin.taal <at> openbravo.com> date: Mon Aug 20 18:26:36 2012 +0200 summary: Fixes issue 21360: DalConnectionProvider getTransactionConnection() should be equal than ConnectionProviderImpl Use a statelesssession to create a new connection
details: https://code.openbravo.com/erp/devel/pi/rev/d7b435781ed2 changeset: 17721:d7b435781ed2 user: Martin Taal <martin.taal <at> openbravo.com> date: Mon Aug 20 22:05:02 2012 +0200 summary: Fixes issue 21332: openDirectTab doesn't show process buttons if the opened tab is a child one Call updatebuttonstate also for child windows if the parent record gets selected in case of open direct on tab Prevent excessive calls to updatebuttonstate diffstat: modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js | 3 ++ modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js | 15 ++------- src-test/org/openbravo/test/dal/IssuesTest.java | 15 ++++++++++ src/org/openbravo/service/db/DalConnectionProvider.java | 7 ++++- 4 files changed, 28 insertions(+), 12 deletions(-) diffs (102 lines): diff -r 95edb2421ea8 -r d7b435781ed2 modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js Mon Aug 20 12:59:56 2012 -0500 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js Mon Aug 20 22:05:02 2012 +0200 @@ -1191,6 +1191,9 @@ if (!selectedRecordId || !this.isOpenDirectModeParent || selectedRecordId !== tabViewPane.parentRecordId) { tabViewPane.doRefreshContents(true); } + if (this.isOpenDirectModeParent) { + tabViewPane.toolBar.updateButtonState(true); + } } } delete this.isOpenDirectModeParent; diff -r 95edb2421ea8 -r d7b435781ed2 modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js Mon Aug 20 12:59:56 2012 -0500 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js Mon Aug 20 22:05:02 2012 +0200 @@ -623,18 +623,11 @@ updateButtonState: function (noSetSession, changeEvent) { var me = this, isActiveTab = false; - if (this.view && this.view.activeBar && this.view.activeBar.styleName === 'OBViewActive') { - isActiveTab = true; + if (this.view && this.view.isActiveView && this.view.isActiveView()) { + this.fireOnPause('updateButtonState', function () { + me.pausedUpdateButtonState(noSetSession, changeEvent); + }); } - this.fireOnPause('updateButtonState', function () { - //Temporary hack to fix issue https://issues.openbravo.com/view.php?id=20825 - if ((me.view.tabId === '160' || me.view.tabId === 'FF8080812F213146012F2135BC25000E') && isActiveTab) { //corner case: 160 --> G/L Journal and FF8080812F213146012F2135BC25000E --> Transaction (Financial Account child) - setTimeout(function () { - me.pausedUpdateButtonState(noSetSession, changeEvent); - }, 1000); - } - me.pausedUpdateButtonState(noSetSession, changeEvent); - }); }, pausedUpdateButtonState: function (noSetSession, changeEvent) { diff -r 95edb2421ea8 -r d7b435781ed2 src-test/org/openbravo/test/dal/IssuesTest.java --- a/src-test/org/openbravo/test/dal/IssuesTest.java Mon Aug 20 12:59:56 2012 -0500 +++ b/src-test/org/openbravo/test/dal/IssuesTest.java Mon Aug 20 22:05:02 2012 +0200 @@ -79,6 +79,7 @@ import org.openbravo.model.common.plm.Product; import org.openbravo.service.db.CallProcess; import org.openbravo.service.db.CallStoredProcedure; +import org.openbravo.service.db.DalConnectionProvider; import org.openbravo.service.json.DataEntityQueryService; import org.openbravo.service.json.DataToJsonConverter; import org.openbravo.test.base.BaseTest; @@ -145,6 +146,9 @@ * https://issues.openbravo.com/view.php?id=20733: Json serialization: always the identifier * properties of associated entities are serialized also, resulting in extra queries * + * https://issues.openbravo.com/view.php?id=21360 DalConnectionProvider: getTransactionConnection() + * should be equal than ConnectionProviderImpl getTransactionConnection() + * * @author mtaal * @author iperdomo */ @@ -765,4 +769,15 @@ } } + public void test21360() throws Exception { + final DalConnectionProvider connectionProvider = new DalConnectionProvider(); + // test that a new connection is returned + final Connection connection = connectionProvider.getConnection(); + final Connection otherConnection = connectionProvider.getTransactionConnection(); + final Connection yetAnotherConnection = connectionProvider.getTransactionConnection(); + Assert.assertNotSame(connection, yetAnotherConnection); + Assert.assertNotSame(connection, otherConnection); + Assert.assertNotSame(otherConnection, yetAnotherConnection); + } + } \ No newline at end of file diff -r 95edb2421ea8 -r d7b435781ed2 src/org/openbravo/service/db/DalConnectionProvider.java --- a/src/org/openbravo/service/db/DalConnectionProvider.java Mon Aug 20 12:59:56 2012 -0500 +++ b/src/org/openbravo/service/db/DalConnectionProvider.java Mon Aug 20 22:05:02 2012 +0200 @@ -27,7 +27,9 @@ import java.sql.Statement; import java.util.Properties; +import org.hibernate.StatelessSession; import org.openbravo.base.session.OBPropertiesProvider; +import org.openbravo.base.session.SessionFactoryController; import org.openbravo.dal.service.OBDal; import org.openbravo.database.ConnectionProvider; import org.openbravo.exception.NoConnectionAvailableException; @@ -94,7 +96,10 @@ } public Connection getTransactionConnection() throws NoConnectionAvailableException, SQLException { - Connection conn = getConnection(); + final StatelessSession session = SessionFactoryController.getInstance().getSessionFactory() + .openStatelessSession(); + Connection conn = session.connection(); + if (conn == null) { throw new NoConnectionAvailableException("CouldnĀ“t get an available connection"); } ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits