dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #01746
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 547: Updated dhis-service-vn to new Hibernate setup.
------------------------------------------------------------
revno: 547
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Tue 2009-09-01 14:22:47 +0200
message:
Updated dhis-service-vn to new Hibernate setup.
modified:
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/status/DefaultDataStatusService.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/status/hibernate/HibernateDataStatusStore.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/vn/report/DefaultReportExcelService.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/vn/report/hibernate/HibernateReportExcelStore.java
local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/status/DefaultDataStatusService.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/status/DefaultDataStatusService.java 2009-09-01 11:25:50 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/status/DefaultDataStatusService.java 2009-09-01 12:22:47 +0000
@@ -3,6 +3,7 @@
import java.util.Collection;
import org.hisp.dhis.dataset.DataSet;
+import org.springframework.transaction.annotation.Transactional;
/*
* Copyright (c) 2004-2007, University of Oslo
@@ -35,6 +36,7 @@
* @author Tran Thanh Tri
* @version $Id$
*/
+@Transactional
public class DefaultDataStatusService
implements DataStatusService
{
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/status/hibernate/HibernateDataStatusStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/status/hibernate/HibernateDataStatusStore.java 2009-09-01 11:25:50 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/status/hibernate/HibernateDataStatusStore.java 2009-09-01 12:22:47 +0000
@@ -1,15 +1,13 @@
package org.hisp.dhis.status.hibernate;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import org.hibernate.Criteria;
import org.hibernate.Session;
-import org.hibernate.criterion.Disjunction;
+import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.hibernate.HibernateSessionManager;
import org.hisp.dhis.status.DataStatus;
import org.hisp.dhis.status.DataStatusStore;
@@ -51,11 +49,11 @@
// Dependency
// -------------------------------------------------
- private HibernateSessionManager hibernateSessionManager;
+ private SessionFactory sessionFactory;
- public void setHibernateSessionManager( HibernateSessionManager hibernateSessionManager )
+ public void setSessionFactory( SessionFactory sessionFactory )
{
- this.hibernateSessionManager = hibernateSessionManager;
+ this.sessionFactory = sessionFactory;
}
// -------------------------------------------------
@@ -64,7 +62,7 @@
public void delete( int id )
{
- Session session = hibernateSessionManager.getCurrentSession();
+ Session session = sessionFactory.getCurrentSession();
session.delete( session.get( DataStatus.class, id ) );
@@ -72,14 +70,14 @@
public DataStatus get( int id )
{
- Session session = hibernateSessionManager.getCurrentSession();
+ Session session = sessionFactory.getCurrentSession();
return (DataStatus) session.get( DataStatus.class, id );
}
public void save( DataStatus dataStatus )
{
- Session session = hibernateSessionManager.getCurrentSession();
+ Session session = sessionFactory.getCurrentSession();
session.save( dataStatus );
@@ -87,7 +85,7 @@
public void update( DataStatus dataStatus )
{
- Session session = hibernateSessionManager.getCurrentSession();
+ Session session = sessionFactory.getCurrentSession();
session.update( dataStatus );
}
@@ -95,7 +93,7 @@
@SuppressWarnings( "unchecked" )
public Collection<DataStatus> getALL()
{
- Session session = hibernateSessionManager.getCurrentSession();
+ Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria( DataStatus.class );
@@ -105,7 +103,7 @@
@SuppressWarnings( "unchecked" )
public Collection<DataStatus> getDataStatusDefault()
{
- Session session = hibernateSessionManager.getCurrentSession();
+ Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria( DataStatus.class );
criteria.add( Restrictions.eq( "frontPage", true ) );
@@ -118,7 +116,7 @@
Collection<DataStatus> result = new HashSet<DataStatus>();
if ( !dataSets.isEmpty() )
{
- Session session = hibernateSessionManager.getCurrentSession();
+ Session session = sessionFactory.getCurrentSession();
for ( DataSet dataSet : dataSets )
{
@@ -136,7 +134,7 @@
Collection<DataStatus> result = new HashSet<DataStatus>();
if ( !dataSets.isEmpty() )
{
- Session session = hibernateSessionManager.getCurrentSession();
+ Session session = sessionFactory.getCurrentSession();
for ( DataSet dataSet : dataSets )
{
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/vn/report/DefaultReportExcelService.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/vn/report/DefaultReportExcelService.java 2009-07-13 00:23:50 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/vn/report/DefaultReportExcelService.java 2009-09-01 12:22:47 +0000
@@ -29,15 +29,16 @@
import java.util.Collection;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.springframework.transaction.annotation.Transactional;
/**
* @author Tran Thanh Tri
* @version $Id$
*/
+@Transactional
public class DefaultReportExcelService
implements ReportExcelService
{
-
// -------------------------------------------------
// Dependency
// -------------------------------------------------
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/vn/report/hibernate/HibernateReportExcelStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/vn/report/hibernate/HibernateReportExcelStore.java 2009-09-01 10:22:24 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/vn/report/hibernate/HibernateReportExcelStore.java 2009-09-01 12:22:47 +0000
@@ -31,10 +31,8 @@
import org.hibernate.Criteria;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
-import org.hibernate.criterion.Projection;
-import org.hibernate.criterion.Projections;
+import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
-import org.hisp.dhis.hibernate.HibernateSessionManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.vn.report.ReportExcel;
import org.hisp.dhis.vn.report.ReportExcelInterface;
@@ -46,164 +44,169 @@
* @author Tran Thanh Tri
* @version $Id$
*/
-public class HibernateReportExcelStore implements ReportExcelStore {
-
- // -------------------------------------------------
- // Dependency
- // -------------------------------------------------
-
- private HibernateSessionManager hibernateSessionManager;
-
- public void setHibernateSessionManager(
- HibernateSessionManager hibernateSessionManager) {
- this.hibernateSessionManager = hibernateSessionManager;
- }
-
- // --------------------------------------
- // Service of Report
- // --------------------------------------
-
- public void addReport(ReportExcelInterface report) {
-
- Session session = hibernateSessionManager.getCurrentSession();
-
- session.save(report);
-
- }
-
- public void updateReport(ReportExcelInterface report) {
-
- Session session = hibernateSessionManager.getCurrentSession();
-
- session.update(report);
-
- }
-
- public void deleteReport(int id) {
-
- Session session = hibernateSessionManager.getCurrentSession();
-
- session.delete(getReport(id));
-
- }
-
- public ReportExcelInterface getReport(int id) {
-
- Session session = hibernateSessionManager.getCurrentSession();
-
- return (ReportExcelInterface) session.get(ReportExcel.class, id);
-
- }
-
- public ReportExcelInterface getReport(String name) {
- Session session = hibernateSessionManager.getCurrentSession();
-
- Criteria criteria = session.createCriteria(ReportExcel.class);
-
- criteria.add(Restrictions.eq("name", name));
-
- return (ReportExcelInterface) criteria.uniqueResult();
- }
-
- public Collection<ReportExcelInterface> getReportsByOrganisationUnit(
- OrganisationUnit organisationUnit) {
-
- Session session = hibernateSessionManager.getCurrentSession();
-
- Criteria criteria = session.createCriteria(ReportExcel.class);
-
- criteria.createAlias("organisationAssocitions", "o");
-
- criteria.add(Restrictions.eq("o.id", organisationUnit.getId()));
-
- return criteria.list();
- }
-
- public Collection<ReportExcelInterface> getALLReport() {
-
- Session session = hibernateSessionManager.getCurrentSession();
-
- Criteria criteria = session.createCriteria(ReportExcel.class);
-
- return criteria.list();
-
- }
-
- // --------------------------------------
- // Service of Report Item
- // --------------------------------------
-
- public void addReportItem(ReportItem reportItem) {
- Session session = hibernateSessionManager.getCurrentSession();
-
- session.save(reportItem);
-
- }
-
- public void updateReportItem(ReportItem reportItem) {
- Session session = hibernateSessionManager.getCurrentSession();
-
- session.update(reportItem);
-
- }
-
- public void deleteReportItem(int id) {
- Session session = hibernateSessionManager.getCurrentSession();
-
- session.delete(getReportItem(id));
-
- }
-
- public ReportItem getReportItem(int id) {
- Session session = hibernateSessionManager.getCurrentSession();
-
- return (ReportItem) session.get(ReportItem.class, id);
- }
-
- public Collection<ReportItem> getALLReportItem() {
- Session session = hibernateSessionManager.getCurrentSession();
-
- Criteria criteria = session.createCriteria(ReportItem.class);
-
- return criteria.list();
-
- }
-
- public ReportItem getReportItem(String name) {
- Session session = hibernateSessionManager.getCurrentSession();
-
- Criteria criteria = session.createCriteria(ReportItem.class);
-
- criteria.add(Restrictions.eq("name", name));
-
- return (ReportItem) criteria.uniqueResult();
- }
-
- public Collection<ReportItem> getReportItem(String arg0,
- ReportExcelNormal arg1) {
-
- return null;
- }
-
- public Collection<ReportItem> getReportItem(int sheetNo, Integer reportId) {
-
- Session session = hibernateSessionManager.getCurrentSession();
- SQLQuery sqlQuery = session
- .createSQLQuery("SELECT * from reportitem where reportitem.sheetno="
- + sheetNo
- + " and reportitem.reportid="
- + reportId.intValue());
- sqlQuery.addEntity(ReportItem.class);
- return sqlQuery.list();
- }
-
- @SuppressWarnings("unchecked")
- public Collection<Integer> getSheets(Integer reportId) {
- Session session = hibernateSessionManager.getCurrentSession();
- SQLQuery sqlQuery = session
- .createSQLQuery("select DISTINCT(sheetno) from reportitem where reportitem.reportid=" + reportId.intValue());
-
- return sqlQuery.list();
- }
-
+public class HibernateReportExcelStore
+ implements ReportExcelStore
+{
+ // -------------------------------------------------
+ // Dependency
+ // -------------------------------------------------
+
+ private SessionFactory sessionFactory;
+
+ public void setSessionFactory( SessionFactory sessionFactory )
+ {
+ this.sessionFactory = sessionFactory;
+ }
+
+ // --------------------------------------
+ // Service of Report
+ // --------------------------------------
+
+ public void addReport( ReportExcelInterface report )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.save( report );
+ }
+
+ public void updateReport( ReportExcelInterface report )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.update( report );
+ }
+
+ public void deleteReport( int id )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.delete( getReport( id ) );
+ }
+
+ public ReportExcelInterface getReport( int id )
+ {
+
+ Session session = sessionFactory.getCurrentSession();
+
+ return (ReportExcelInterface) session.get( ReportExcel.class, id );
+
+ }
+
+ public ReportExcelInterface getReport( String name )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( ReportExcel.class );
+
+ criteria.add( Restrictions.eq( "name", name ) );
+
+ return (ReportExcelInterface) criteria.uniqueResult();
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Collection<ReportExcelInterface> getReportsByOrganisationUnit( OrganisationUnit organisationUnit )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( ReportExcel.class );
+
+ criteria.createAlias( "organisationAssocitions", "o" );
+
+ criteria.add( Restrictions.eq( "o.id", organisationUnit.getId() ) );
+
+ return criteria.list();
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Collection<ReportExcelInterface> getALLReport()
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( ReportExcel.class );
+
+ return criteria.list();
+
+ }
+
+ // --------------------------------------
+ // Service of Report Item
+ // --------------------------------------
+
+ public void addReportItem( ReportItem reportItem )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.save( reportItem );
+
+ }
+
+ public void updateReportItem( ReportItem reportItem )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.update( reportItem );
+
+ }
+
+ public void deleteReportItem( int id )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.delete( getReportItem( id ) );
+
+ }
+
+ public ReportItem getReportItem( int id )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ return (ReportItem) session.get( ReportItem.class, id );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Collection<ReportItem> getALLReportItem()
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( ReportItem.class );
+
+ return criteria.list();
+ }
+
+ public ReportItem getReportItem( String name )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( ReportItem.class );
+
+ criteria.add( Restrictions.eq( "name", name ) );
+
+ return (ReportItem) criteria.uniqueResult();
+ }
+
+ public Collection<ReportItem> getReportItem( String arg0, ReportExcelNormal arg1 )
+ {
+ return null;
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Collection<ReportItem> getReportItem( int sheetNo, Integer reportId )
+ {
+ Session session = sessionFactory.getCurrentSession();
+ SQLQuery sqlQuery = session.createSQLQuery( "SELECT * from reportitem where reportitem.sheetno=" + sheetNo
+ + " and reportitem.reportid=" + reportId.intValue() );
+ sqlQuery.addEntity( ReportItem.class );
+ return sqlQuery.list();
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Collection<Integer> getSheets( Integer reportId )
+ {
+ Session session = sessionFactory.getCurrentSession();
+ SQLQuery sqlQuery = session
+ .createSQLQuery( "select DISTINCT(sheetno) from reportitem where reportitem.reportid="
+ + reportId.intValue() );
+
+ return sqlQuery.list();
+ }
}
=== modified file 'local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml'
--- local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml 2009-09-01 10:22:24 +0000
+++ local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml 2009-09-01 12:22:47 +0000
@@ -6,8 +6,7 @@
<bean id="org.hisp.dhis.vn.report.ReportExcelStore"
class="org.hisp.dhis.vn.report.hibernate.HibernateReportExcelStore">
- <property name="hibernateSessionManager"
- ref="org.hisp.dhis.hibernate.HibernateSessionManager"/>
+ <property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="org.hisp.dhis.vn.report.ReportExcelService"
@@ -18,8 +17,7 @@
<bean id="org.hisp.dhis.status.DataStatusStore"
class="org.hisp.dhis.status.hibernate.HibernateDataStatusStore">
- <property name="hibernateSessionManager"
- ref="org.hisp.dhis.hibernate.HibernateSessionManager"/>
+ <property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="org.hisp.dhis.status.DataStatusService"
@@ -27,22 +25,5 @@
<property name="dataStatusStore"
ref="org.hisp.dhis.status.DataStatusStore"/>
</bean>
-
-
- <bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
- <property name="advice" ref="readWriteTransactionInterceptor"/>
- <property name="patterns">
- <list>
- <value>.*\.ReportExcelStore\.add.*</value>
- <value>.*\.ReportExcelStore\.update.*</value>
- <value>.*\.ReportExcelStore\.save.*</value>
- <value>.*\.ReportExcelStore\.delete.*</value>
- <value>.*\.DataStatusStore\.add.*</value>
- <value>.*\.DataStatusStore\.update.*</value>
- <value>.*\.DataStatusStore\.save.*</value>
- <value>.*\.DataStatusStore\.delete.*</value>
- </list>
- </property>
- </bean>
-
+
</beans>