dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20693
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9592: Don't add/update program-stage-dataelements.
------------------------------------------------------------
revno: 9592
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-01-24 10:09:30 +0700
message:
Don't add/update program-stage-dataelements.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java
dhis-2/dhis-services/dhis-service-patient/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 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementStore.java 2010-02-22 09:19:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementStore.java 2013-01-24 03:09:30 +0000
@@ -28,21 +28,28 @@
import java.util.Collection;
-import org.hisp.dhis.common.GenericStore;
import org.hisp.dhis.dataelement.DataElement;
/**
* @author Viet Nguyen
- *
+ *
* @version $Id$
*/
-public interface ProgramStageDataElementStore extends GenericStore<ProgramStageDataElement>
+public interface ProgramStageDataElementStore
{
- String ID = ProgramStageInstanceStore.class.getName();
-
- ProgramStageDataElement get( ProgramStage programStage, DataElement dataElement );
-
- Collection<ProgramStageDataElement> get( ProgramStage programStage );
-
+ String ID = ProgramStageInstanceStore.class.getName();
+
+ void save( ProgramStageDataElement programStageDataElement );
+
+ void update( ProgramStageDataElement programStageDataElement );
+
+ void delete( ProgramStageDataElement programStageDataElement );
+
+ ProgramStageDataElement get( ProgramStage programStage, DataElement dataElement );
+
+ Collection<ProgramStageDataElement> getAll();
+
+ Collection<ProgramStageDataElement> get( ProgramStage programStage );
+
Collection<DataElement> getListDataElement( ProgramStage programStage );
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java 2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java 2013-01-24 03:09:30 +0000
@@ -29,10 +29,11 @@
import java.util.Collection;
import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.hibernate.HibernateGenericStore;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageDataElement;
import org.hisp.dhis.program.ProgramStageDataElementStore;
@@ -42,32 +43,92 @@
* @version $Id$
*/
public class HibernateProgramStageDataElementStore
- extends HibernateGenericStore<ProgramStageDataElement>
implements ProgramStageDataElementStore
{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private SessionFactory sessionFactory;
+
+ public void setSessionFactory( SessionFactory sessionFactory )
+ {
+ this.sessionFactory = sessionFactory;
+ }
+
+ // -------------------------------------------------------------------------
+ // Basic ProgramStageDataElement
+ // -------------------------------------------------------------------------
+
+ public void save( ProgramStageDataElement programStageDataElement )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.save( programStageDataElement );
+ }
+
+ public void update( ProgramStageDataElement programStageDataElement )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.update( programStageDataElement );
+ }
+
+ public void delete( ProgramStageDataElement programStageDataElement )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.delete( programStageDataElement );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Collection<ProgramStageDataElement> getAll()
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( ProgramStageDataElement.class );
+
+ return criteria.list();
+ }
+
@SuppressWarnings( "unchecked" )
public Collection<ProgramStageDataElement> get( ProgramStage programStage )
{
- return getCriteria( Restrictions.eq( "programStage", programStage ) ).list();
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( ProgramStageDataElement.class );
+
+ return criteria.add( Restrictions.eq( "programStage", programStage ) ).list();
}
@SuppressWarnings( "unchecked" )
public Collection<ProgramStageDataElement> get( ProgramStage programStage, boolean compulsory )
{
- return getCriteria( Restrictions.eq( "programStage", programStage ), Restrictions.eq( "compulsory", compulsory ) )
- .list();
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( ProgramStageDataElement.class );
+ criteria.add( Restrictions.eq( "programStage", programStage ) );
+ criteria.add( Restrictions.eq( "compulsory", compulsory ) );
+
+ return criteria.list();
}
public ProgramStageDataElement get( ProgramStage programStage, DataElement dataElement )
{
- return (ProgramStageDataElement) getCriteria( Restrictions.eq( "programStage", programStage ),
- Restrictions.eq( "dataElement", dataElement ) ).uniqueResult();
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( ProgramStageDataElement.class );
+ criteria.add( Restrictions.eq( "programStage", programStage ) );
+ criteria.add( Restrictions.eq( "dataElement", dataElement ) );
+
+ return (ProgramStageDataElement) criteria.uniqueResult();
}
@SuppressWarnings( "unchecked" )
public Collection<DataElement> getListDataElement( ProgramStage programStage )
{
- Criteria criteria = sessionFactory.getCurrentSession().createCriteria( getClazz() );
+ Session session = sessionFactory.getCurrentSession();
+ Criteria criteria = session.createCriteria( ProgramStageDataElement.class );
criteria.add( Restrictions.eq( "programStage", programStage ) );
criteria.setProjection( Projections.property( "dataElement" ) );
return criteria.list();
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-01-23 10:27:28 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-01-24 03:09:30 +0000
@@ -124,8 +124,6 @@
<bean id="org.hisp.dhis.program.ProgramStageDataElementStore"
class="org.hisp.dhis.program.hibernate.HibernateProgramStageDataElementStore">
- <property name="clazz"
- value="org.hisp.dhis.program.ProgramStageDataElement" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>