From de61dd55d3c8de159de4c779e32deb33b1026ea4 Mon Sep 17 00:00:00 2001 From: Bruno Sinou Date: Wed, 22 Sep 2010 17:41:34 +0000 Subject: [PATCH] tests for solving the hibernate transaction problem git-svn-id: https://svn.argeo.org/slc/trunk@3797 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../META-INF/MANIFEST.MF | 7 +++- .../client/core/ProcessListTableContent.java | 42 ++++++++++++++++++- .../argeo/slc/client/core/TableContent.java | 10 ++++- .../META-INF/MANIFEST.MF | 5 ++- .../META-INF/spring/core-osgi.xml | 7 +++- .../META-INF/spring/core.xml | 4 +- .../META-INF/spring/osgi.xml | 3 +- .../META-INF/spring/views.xml | 2 +- .../client/ui/commands/RefreshHandler.java | 9 ++-- .../slc/client/ui/views/ProcessListView.java | 32 ++++---------- 10 files changed, 84 insertions(+), 37 deletions(-) diff --git a/eclipse/plugins/org.argeo.slc.client.core/META-INF/MANIFEST.MF b/eclipse/plugins/org.argeo.slc.client.core/META-INF/MANIFEST.MF index 8088b5f1c..ad655215e 100644 --- a/eclipse/plugins/org.argeo.slc.client.core/META-INF/MANIFEST.MF +++ b/eclipse/plugins/org.argeo.slc.client.core/META-INF/MANIFEST.MF @@ -4,7 +4,12 @@ Bundle-Name: Core Bundle-SymbolicName: org.argeo.slc.client.core Bundle-Version: 1.0.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: com.springsource.org.hibernate;resolution:=optional Export-Package: org.argeo.slc.client.core -Import-Package: org.argeo.slc.dao.process, +Import-Package: org.apache.commons.io;version="1.4.0", + org.apache.commons.logging;version="1.1.1", + org.argeo.slc.dao.process, org.argeo.slc.process, + org.hibernate.hql.ast, + org.hibernate.jdbc, org.osgi.framework;version="1.3.0" diff --git a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/core/ProcessListTableContent.java b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/core/ProcessListTableContent.java index 78af963d4..68f6d7c85 100644 --- a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/core/ProcessListTableContent.java +++ b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/core/ProcessListTableContent.java @@ -1,12 +1,30 @@ package org.argeo.slc.client.core; +import java.util.Iterator; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.argeo.slc.dao.process.SlcExecutionDao; import org.argeo.slc.process.SlcExecution; public class ProcessListTableContent implements TableContent { + private static final Log log = LogFactory + .getLog(ProcessListTableContent.class); + + private List slcExecutions; + + // IoC + private SlcExecutionDao slcExecutionDao; @Override public SlcExecution getLine(int i) { - // TODO Auto-generated method stub + + // SlcExecution se = new SlcExecution(); + // se.setHost("Marshall"); + // se.setUuid("a very long uuid"); + // se.setStatus(SlcExecution.STATUS_RUNNING); + // return se; return null; } @@ -16,4 +34,26 @@ public class ProcessListTableContent implements TableContent { return "test"; } + public List getContent() { + return this.slcExecutions; + } + + public void setContent() { + List lst = slcExecutionDao.listSlcExecutions(); + if (lst.get(0) != null) { + log.debug(lst.get(0).getStartDate()); + log.debug(lst.get(0).getHost()); + log.debug(lst.get(0).getStatus()); + log.debug(lst.get(0).getUuid()); + } + Iterator it = slcExecutions.iterator(); + while (it.hasNext()) { + slcExecutions.add(it.next()); + } + } + + // IoC + public void setSlcExecutionDao(SlcExecutionDao slcExecutionDao) { + this.slcExecutionDao = slcExecutionDao; + } } diff --git a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/core/TableContent.java b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/core/TableContent.java index 02e750cd5..c08727593 100644 --- a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/core/TableContent.java +++ b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/core/TableContent.java @@ -1,8 +1,16 @@ package org.argeo.slc.client.core; +import java.util.List; + +import org.argeo.slc.process.SlcExecution; + public interface TableContent { public Object getLine(int i); - + public String getLabel(Object o, int i); + + public void setContent(); + + public List getContent(); } diff --git a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/MANIFEST.MF b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/MANIFEST.MF index f8cf3432a..5e3de1d76 100644 --- a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/MANIFEST.MF +++ b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/MANIFEST.MF @@ -3,5 +3,8 @@ Bundle-ManifestVersion: 2 Bundle-Name: Hibernate Interface for RCP Client Bundle-SymbolicName: org.argeo.slc.client.hibernate Bundle-Version: 1.0.0.qualifier -Import-Package: org.argeo.slc.client.core +Import-Package: org.argeo.slc.client.core, + org.argeo.slc.dao.process;version="0.13.0.SNAPSHOT-r3777", + org.hibernate.hql.ast, + org.hibernate.jdbc diff --git a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core-osgi.xml b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core-osgi.xml index b6a761fc8..fed1afced 100644 --- a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core-osgi.xml +++ b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core-osgi.xml @@ -6,7 +6,10 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - + + + + \ No newline at end of file diff --git a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml index 0545a4c14..29dfe3b2b 100644 --- a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml +++ b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml @@ -4,6 +4,8 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + + + diff --git a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml index e73da5a8e..0632203ba 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml +++ b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml @@ -9,8 +9,7 @@ - - + diff --git a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml index b262382b3..596a2a034 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml +++ b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml @@ -17,7 +17,7 @@ - + diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RefreshHandler.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RefreshHandler.java index 713f3a0bf..fb424a4dc 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RefreshHandler.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RefreshHandler.java @@ -1,5 +1,6 @@ package org.argeo.slc.client.ui.commands; +import org.argeo.slc.client.ui.views.ProcessListView; import org.argeo.slc.client.ui.views.ResultListView; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; @@ -13,10 +14,10 @@ public class RefreshHandler extends AbstractHandler { .getActiveWorkbenchWindow(event).getActivePage().findView( ResultListView.ID); view.retrieveResults(); - // ProcessListView pView = (ProcessListView) HandlerUtil - // .getActiveWorkbenchWindow(event).getActivePage().findView( - // ProcessListView.ID); - // pView.retrieveResults(); + ProcessListView pView = (ProcessListView) HandlerUtil + .getActiveWorkbenchWindow(event).getActivePage() + .findView(ProcessListView.ID); + pView.retrieveResults(); return null; } diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessListView.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessListView.java index 12a450057..b0b1d2067 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessListView.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessListView.java @@ -5,7 +5,6 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.slc.client.core.TableContent; -import org.argeo.slc.dao.process.SlcExecutionDao; import org.argeo.slc.process.SlcExecution; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; @@ -28,9 +27,11 @@ public class ProcessListView extends ViewPart { private TableViewer viewer; // IoC - private SlcExecutionDao slcExecutionDao; private TableContent tableContent; + // tests + private List slcExecutions; + public void createPartControl(Composite parent) { Table table = createTable(parent); viewer = new TableViewer(table); @@ -96,20 +97,7 @@ public class ProcessListView extends ViewPart { protected class ViewLabelProvider extends LabelProvider implements ITableLabelProvider { public String getColumnText(Object obj, int index) { - SlcExecution se = (SlcExecution) obj; - // switch (index) { - // - // case 0: - // return getText(se.getStartDate()); - // case 1: - // return se.getHost(); - // case 2: - // return se.getUuid(); - // case 3: - // return se.currentStep().getType(); - // } - // return getText(obj); - return tableContent.getLabel(null, 0); + return tableContent.getLabel(obj, index); } public Image getColumnImage(Object obj, int index) { @@ -124,11 +112,8 @@ public class ProcessListView extends ViewPart { public void retrieveResults() { try { - List lst = slcExecutionDao.listSlcExecutions(); - - if (log.isTraceEnabled()) - log.trace("Slc Execution count: " + lst.size()); - viewer.setInput(lst); + tableContent.setContent(); + viewer.setInput(tableContent.getContent()); // viewer.refresh(); } catch (Exception e) { // TODO Auto-generated catch block @@ -136,8 +121,9 @@ public class ProcessListView extends ViewPart { } } - public void setSlcExecutionDao(SlcExecutionDao slcExecutionDao) { - this.slcExecutionDao = slcExecutionDao; + // IoC + public void setTableContent(TableContent tableContent) { + this.tableContent = tableContent; } } -- 2.39.2