dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #01460
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 459: Updated dhis-service-vn to new hibernate management.
------------------------------------------------------------
revno: 459
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Mon 2009-07-13 16:29:11 +0200
message:
Updated dhis-service-vn to new hibernate management.
modified:
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
=== 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-07-13 00:23:50 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/vn/report/hibernate/HibernateReportExcelStore.java 2009-07-13 14:29:11 +0000
@@ -31,179 +31,175 @@
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;
import org.hisp.dhis.vn.report.ReportExcelNormal;
import org.hisp.dhis.vn.report.ReportExcelStore;
import org.hisp.dhis.vn.report.ReportItem;
+import org.springframework.transaction.annotation.Transactional;
/**
* @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();
- }
-
+@Transactional
+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();
+ }
+
+ 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();
+ }
+
+ 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 );
+ }
+
+ 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;
+ }
+
+ 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-07-13 00:23:50 +0000
+++ local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml 2009-07-13 14:29:11 +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"
@@ -15,18 +14,5 @@
<property name="reportStore"
ref="org.hisp.dhis.vn.report.ReportExcelStore"/>
</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>
- </list>
- </property>
- </bean>
</beans>
--
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.