dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30067
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15257: Reverted r 15254
------------------------------------------------------------
revno: 15257
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-05-13 14:54:58 +0200
message:
Reverted r 15254
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java
dhis-2/dhis-services/dhis-service-tracker/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 2014-05-13 10:43:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElementStore.java 2014-05-13 12:54:58 +0000
@@ -30,7 +30,6 @@
import java.util.Collection;
-import org.hisp.dhis.common.GenericStore;
import org.hisp.dhis.dataelement.DataElement;
/**
@@ -39,11 +38,34 @@
* @version $Id$
*/
public interface ProgramStageDataElementStore
- extends GenericStore<ProgramStageDataElement>
{
String ID = ProgramStageInstanceStore.class.getName();
/**
+ * Adds an {@link ProgramStageDataElement}
+ *
+ * @param programStageDataElement The to ProgramStageDataElement add.
+ *
+ * @return A generated unique id of the added
+ * {@link ProgramStageDataElement}.
+ */
+ void save( ProgramStageDataElement programStageDataElement );
+
+ /**
+ * Updates an {@link ProgramStageDataElement}.
+ *
+ * @param programStageDataElement the ProgramStageDataElement to update.
+ */
+ void update( ProgramStageDataElement programStageDataElement );
+
+ /**
+ * Deletes a {@link ProgramStageDataElement}.
+ *
+ * @param programStageDataElement the ProgramStageDataElement to delete.
+ */
+ void delete( ProgramStageDataElement programStageDataElement );
+
+ /**
* Retrieve ProgramStageDataElement list on a program stage and a data
* element
*
@@ -55,6 +77,14 @@
ProgramStageDataElement get( ProgramStage programStage, DataElement dataElement );
/**
+ * Returns all {@link ProgramStageDataElement}
+ *
+ * @return a collection of all ProgramStageDataElement, or an empty
+ * collection if there are no ProgramStageDataElements.
+ */
+ Collection<ProgramStageDataElement> getAll();
+
+ /**
* Retrieve ProgramStageDataElement list on a program stage
*
* @param programStage ProgramStage
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java 2014-05-13 10:43:52 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java 2014-05-13 12:54:58 +0000
@@ -28,51 +28,109 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-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;
+import java.util.Collection;
+
/**
* @author Viet Nguyen
*/
public class HibernateProgramStageDataElementStore
- extends HibernateGenericStore<ProgramStageDataElement>
implements ProgramStageDataElementStore
{
// -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private SessionFactory sessionFactory;
+
+ public void setSessionFactory( SessionFactory sessionFactory )
+ {
+ this.sessionFactory = sessionFactory;
+ }
+
+ // -------------------------------------------------------------------------
// Implemented methods
// -------------------------------------------------------------------------
+ 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 = getCriteria( Restrictions.eq( "programStage", programStage ) );
+ 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-tracker/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml 2014-05-13 10:43:52 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml 2014-05-13 12:54:58 +0000
@@ -113,8 +113,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>