← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5345: Replaced boilerplate code in store layer with HibernateGenericStore

 

------------------------------------------------------------
revno: 5345
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-12-09 20:30:02 +0100
message:
  Replaced boilerplate code in store layer with HibernateGenericStore
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/hibernate/HibernateIndicatorStore.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetStoreTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorStoreTest.java


--
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/dataelement/DataElementStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java	2011-11-22 15:48:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java	2011-12-09 19:30:02 +0000
@@ -171,16 +171,6 @@
     
     Collection<DataElement> getDataElementsByDataSets( Collection<DataSet> dataSets );
 
-    Collection<DataElement> getDataElementsLikeName( String name );
-    
-    Collection<DataElement> getDataElementsBetween( int first, int max );
-    
-    Collection<DataElement> getDataElementsBetweenByName( String name, int first, int max );
-    
-    int getDataElementCount();
-    
-    int getDataElementCountByName( String name );
-    
     Map<Integer, Set<Integer>> getDataElementCategoryOptionCombos();
     
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java	2011-12-02 15:18:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java	2011-12-09 19:30:02 +0000
@@ -47,75 +47,6 @@
     // -------------------------------------------------------------------------
 
     /**
-     * Adds a DataSet.
-     * 
-     * @param dataSet The DataSet to add.
-     * @return The generated unique identifier for this DataSet.
-     */
-    int addDataSet( DataSet dataSet );
-
-    /**
-     * Updates a DataSet.
-     * 
-     * @param dataSet The DataSet to update.
-     */
-    void updateDataSet( DataSet dataSet );
-
-    /**
-     * Deletes a DataSet.
-     * 
-     * @param dataSet The DataSet to delete.
-     */
-    void deleteDataSet( DataSet dataSet );
-
-    /**
-     * Get a DataSet
-     * 
-     * @param id The unique identifier for the DataSet to get.
-     * @return The DataSet with the given id or null if it does not exist.
-     */
-    DataSet getDataSet( int id );
-
-    /**
-     * Returns the DataSet with the given UID.
-     * 
-     * @param uid the UID.
-     * @return the DataSet with the given UID, or null if no match.
-     */
-    DataSet getDataSet( String uid );
-
-    /**
-     * Returns the DataSet with the given name.
-     * 
-     * @param name The name.
-     * @return The DataSet with the given name.
-     */
-    DataSet getDataSetByName( String name );
-
-    /**
-     * Returns the DataSet with the given short name.
-     * 
-     * @param shortName The short name.
-     * @return The DataSet with the given short name.
-     */
-    DataSet getDataSetByShortName( String shortName );
-
-    /**
-     * Returns the DataSet with the given code.
-     * 
-     * @param code The code.
-     * @return The DataSet with the given code.
-     */
-    DataSet getDataSetByCode( String code );
-
-    /**
-     * Gets all DataSets.
-     * 
-     * @return A collection containing all DataSets.
-     */
-    Collection<DataSet> getAllDataSets();
-
-    /**
      * Gets all DataSets associated with the given PeriodType.
      * 
      * @param periodType the PeriodType.
@@ -131,13 +62,4 @@
     Collection<DataSet> getDataSetsForMobile();
 
     Collection<DataSet> getDataSetsBySources( Collection<OrganisationUnit> sources );
-
-    int getDataSetCountByName( String name );
-
-    Collection<DataSet> getDataSetsBetweenByName( String name, int first, int max );
-
-    int getDataSetCount();
-
-    Collection<DataSet> getDataSetsBetween( int first, int max );
-
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java	2011-11-22 15:48:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java	2011-12-09 19:30:02 +0000
@@ -29,47 +29,20 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.common.GenericNameableObjectStore;
+
 /**
  * @author Lars Helge Overland
  * @version $Id: IndicatorStore.java 3305 2007-05-14 18:55:52Z larshelg $
  */
 public interface IndicatorStore
+    extends GenericNameableObjectStore<Indicator>
 {
     String ID = IndicatorStore.class.getName();
 
-    int addIndicator( Indicator indicator );
-
-    void updateIndicator( Indicator indicator );
-
-    void deleteIndicator( Indicator indicator );
-
-    Indicator getIndicator( int id );
-    
-    Indicator getIndicator( String uid );
-    
-    Collection<Indicator> getAllIndicators();
-    
-    Indicator getIndicatorByName( String name );
-
-    Indicator getIndicatorByShortName( String shortName );
-
-    Indicator getIndicatorByAlternativeName( String alternativeName );
-    
-    Indicator getIndicatorByCode( String code );
-
     Collection<Indicator> getIndicatorsWithGroupSets();
     
     Collection<Indicator> getIndicatorsWithoutGroups();
     
     Collection<Indicator> getIndicatorsWithDataSets();
-
-    int getIndicatorCountByName( String name );
-    
-    Collection<Indicator> getIndicatorsLikeName( String name );
-    
-    Collection<Indicator> getIndicatorsBetweenByName( String name, int first, int max );
-    
-    int getIndicatorCount();
-    
-    Collection<Indicator> getIndicatorsBetween(int first, int max );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java	2011-12-09 13:40:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java	2011-12-09 19:30:02 +0000
@@ -39,21 +39,21 @@
     implements GenericIdentifiableObjectStore<T>
 {
     @Override
-    public final int save( T object )
+    public int save( T object )
     {
         object.setAutoFields();
         return super.save( object );
     }
 
     @Override
-    public final void update( T object )
+    public void update( T object )
     {
         object.setAutoFields();
         super.update( object );
     }
 
     @Override
-    public final void saveOrUpdate( T object )
+    public void saveOrUpdate( T object )
     {
         object.setAutoFields();
         super.saveOrUpdate( object );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2011-12-09 18:30:43 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2011-12-09 19:30:02 +0000
@@ -314,27 +314,27 @@
 
     public Collection<DataElement> getDataElementsLikeName( String name )
     {
-        return i18n( i18nService, dataElementStore.getDataElementsLikeName( name ) );
+        return i18n( i18nService, dataElementStore.getLikeName( name ) );
     }
 
     public Collection<DataElement> getDataElementsBetween( int first, int max )
     {
-        return i18n( i18nService, dataElementStore.getDataElementsBetween( first, max ) );
+        return i18n( i18nService, dataElementStore.getBetween( first, max ) );
     }
 
     public Collection<DataElement> getDataElementsBetweenByName( String name, int first, int max )
     {
-        return i18n( i18nService, dataElementStore.getDataElementsBetweenByName( name, first, max ) );
+        return i18n( i18nService, dataElementStore.getBetweenByName( name, first, max ) );
     }
 
     public int getDataElementCount()
     {
-        return dataElementStore.getDataElementCount();
+        return dataElementStore.getCount();
     }
 
     public int getDataElementCountByName( String name )
     {
-        return dataElementStore.getDataElementCountByName( name );
+        return dataElementStore.getCountByName( name );
     }
 
     public Collection<DataElement> getDataElementsByDataSets( Collection<DataSet> dataSets )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java	2011-12-09 18:42:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java	2011-12-09 19:30:02 +0000
@@ -246,31 +246,6 @@
             ConversionUtils.getIdentifiers( DataSet.class, dataSets ) ).list();
     }
 
-    public Collection<DataElement> getDataElementsLikeName( String name )
-    {
-        return getLikeName( name );
-    }
-
-    public Collection<DataElement> getDataElementsBetween( int first, int max )
-    {
-        return getBetween( first, max );
-    }
-
-    public Collection<DataElement> getDataElementsBetweenByName( String name, int first, int max )
-    {
-        return getBetweenByName( name, first, max );
-    }
-
-    public int getDataElementCount()
-    {
-        return getCount();
-    }
-
-    public int getDataElementCountByName( String name )
-    {
-        return getCountByName( name );
-    }
-    
     public Map<Integer, Set<Integer>> getDataElementCategoryOptionCombos()
     {
         final String sql = "select de.dataelementid, coc.categoryoptioncomboid from dataelement de " +

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2011-12-02 14:53:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2011-12-09 19:30:02 +0000
@@ -90,7 +90,7 @@
 
     public int addDataSet( DataSet dataSet )
     {
-        int id = dataSetStore.addDataSet( dataSet );
+        int id = dataSetStore.save( dataSet );
 
         i18nService.addObject( dataSet );
 
@@ -102,7 +102,7 @@
 
     public void updateDataSet( DataSet dataSet )
     {
-        dataSetStore.updateDataSet( dataSet );
+        dataSetStore.update( dataSet );
 
         log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
             AuditLogUtil.ACTION_EDIT, DataSet.class.getSimpleName(), dataSet.getName() ) );
@@ -114,7 +114,7 @@
     {
         i18nService.removeObject( dataSet );
 
-        dataSetStore.deleteDataSet( dataSet );
+        dataSetStore.delete( dataSet );
 
         log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
             AuditLogUtil.ACTION_DELETE, DataSet.class.getSimpleName(), dataSet.getName() ) );
@@ -122,7 +122,7 @@
 
     public DataSet getDataSet( int id )
     {
-        return i18n( i18nService, dataSetStore.getDataSet( id ) );
+        return i18n( i18nService, dataSetStore.get( id ) );
     }
     
     @Override
@@ -133,17 +133,17 @@
 
     public DataSet getDataSetByName( String name )
     {
-        return i18n( i18nService, dataSetStore.getDataSetByName( name ) );
+        return i18n( i18nService, dataSetStore.getByName( name ) );
     }
 
     public DataSet getDataSetByShortName( String shortName )
     {
-        return i18n( i18nService, dataSetStore.getDataSetByShortName( shortName ) );
+        return i18n( i18nService, dataSetStore.getByShortName( shortName ) );
     }
 
     public DataSet getDataSetByCode( String code )
     {
-        return i18n( i18nService, dataSetStore.getDataSetByCode( code ) );
+        return i18n( i18nService, dataSetStore.getByCode( code ) );
     }
 
     public Collection<DataSet> getDataSetsBySources( Collection<OrganisationUnit> sources )
@@ -168,7 +168,7 @@
 
     public Collection<DataSet> getAllDataSets()
     {
-        return i18n( i18nService, dataSetStore.getAllDataSets() );
+        return i18n( i18nService, dataSetStore.getAll() );
     }
 
     public Collection<DataSet> getDataSetsByPeriodType( PeriodType periodType )
@@ -289,24 +289,24 @@
     @Override
     public int getDataSetCount()
     {
-        return dataSetStore.getDataSetCount();
+        return dataSetStore.getCount();
     }
 
     @Override
     public int getDataSetCountByName( String name )
     {
-        return dataSetStore.getDataSetCountByName( name );
+        return dataSetStore.getCountByName( name );
     }
 
     @Override
     public Collection<DataSet> getDataSetsBetween( int first, int max )
     {
-        return i18n( i18nService, dataSetStore.getDataSetsBetween( first, max ) );
+        return i18n( i18nService, dataSetStore.getBetween( first, max ) );
     }
 
     @Override
     public Collection<DataSet> getDataSetsBetweenByName( String name, int first, int max )
     {
-        return i18n( i18nService, dataSetStore.getDataSetsBetweenByName( name, first, max ) );
+        return i18n( i18nService, dataSetStore.getBetweenByName( name, first, max ) );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java	2011-11-25 14:03:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java	2011-12-09 19:30:02 +0000
@@ -64,86 +64,24 @@
     // DataSet
     // -------------------------------------------------------------------------
 
-    public int addDataSet( DataSet dataSet )
-    {
-        PeriodType periodType = periodStore.getPeriodType( dataSet.getPeriodType().getClass() );
-
-        dataSet.setPeriodType( periodType );
-
-        Session session = sessionFactory.getCurrentSession();
-
-        return (Integer) session.save( dataSet );
-    }
-
-    public void updateDataSet( DataSet dataSet )
-    {
-        PeriodType periodType = periodStore.getPeriodType( dataSet.getPeriodType().getClass() );
-
-        dataSet.setPeriodType( periodType );
-
-        Session session = sessionFactory.getCurrentSession();
-
-        session.update( dataSet );
-    }
-
-    public void deleteDataSet( DataSet dataSet )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.delete( dataSet );
-    }
-
-    public DataSet getDataSet( int id )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        return (DataSet) session.get( DataSet.class, id );
-    }
-
-    public DataSet getDataSet( String uid )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataSet.class );
-        criteria.add( Restrictions.eq( "uid", uid ) );
-
-        return (DataSet) criteria.uniqueResult();
-    }
-
-    
-    public DataSet getDataSetByName( String name )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataSet.class );
-        criteria.add( Restrictions.eq( "name", name ) );
-
-        return (DataSet) criteria.uniqueResult();
-    }
-
-    public DataSet getDataSetByShortName( String shortName )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataSet.class );
-        criteria.add( Restrictions.eq( "shortName", shortName ) );
-
-        return (DataSet) criteria.uniqueResult();
-    }
-
-    public DataSet getDataSetByCode( String code )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataSet.class );
-        criteria.add( Restrictions.eq( "code", code ) );
-
-        return (DataSet) criteria.uniqueResult();
-    }
-
-    public Collection<DataSet> getAllDataSets()
-    {
-        return getAll();
+    @Override
+    public int save( DataSet dataSet )
+    {
+        PeriodType periodType = periodStore.getPeriodType( dataSet.getPeriodType().getClass() );
+
+        dataSet.setPeriodType( periodType );
+
+        return super.save( dataSet );
+    }
+
+    @Override
+    public void update( DataSet dataSet )
+    {
+        PeriodType periodType = periodStore.getPeriodType( dataSet.getPeriodType().getClass() );
+
+        dataSet.setPeriodType( periodType );
+
+        super.update( dataSet );
     }
 
     @SuppressWarnings( "unchecked" )
@@ -185,29 +123,5 @@
         Query query = sessionFactory.getCurrentSession().createQuery( hql );
 
         return query.list();
-    }    
-
-    @Override
-    public int getDataSetCount()
-    {
-        return getCount();
-    }
-
-    @Override
-    public int getDataSetCountByName( String name )
-    {
-        return getCountByName( name );
-    }
-
-    @Override
-    public Collection<DataSet> getDataSetsBetween( int first, int max )
-    {
-        return getBetween( first, max );
-    }
-
-    @Override
-    public Collection<DataSet> getDataSetsBetweenByName( String name, int first, int max )
-    {
-        return getBetweenByName( name, first, max );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.java	2011-04-23 18:52:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.java	2011-12-09 19:30:02 +0000
@@ -24,7 +24,6 @@
  */
 
 import org.hibernate.Criteria;
-import org.hibernate.Session;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.Section;
@@ -40,11 +39,9 @@
 {
     public Section getSectionByName( String name, DataSet dataSet )
     {
-        Session session = sessionFactory.getCurrentSession();
-        Criteria criteria = session.createCriteria( Section.class );
+        Criteria criteria = getCriteria();
         criteria.add( Restrictions.eq( "name", name ) );
         criteria.add( Restrictions.eq( "dataSet", dataSet ) );
-        criteria.setCacheable( true );
         return (Section) criteria.uniqueResult();
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java	2011-12-09 18:30:43 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java	2011-12-09 19:30:02 +0000
@@ -92,7 +92,7 @@
 
     public int addIndicator( Indicator indicator )
     {
-        int id = indicatorStore.addIndicator( indicator );
+        int id = indicatorStore.save( indicator );
 
         i18nService.addObject( indicator );
 
@@ -101,7 +101,7 @@
 
     public void updateIndicator( Indicator indicator )
     {
-        indicatorStore.updateIndicator( indicator );
+        indicatorStore.update( indicator );
 
         i18nService.verify( indicator );
     }
@@ -110,22 +110,22 @@
     {
         i18nService.removeObject( indicator );
 
-        indicatorStore.deleteIndicator( indicator );
+        indicatorStore.delete( indicator );
     }
 
     public Indicator getIndicator( int id )
     {
-        return i18n( i18nService, indicatorStore.getIndicator( id ) );
+        return i18n( i18nService, indicatorStore.get( id ) );
     }
 
     public Indicator getIndicator( String uid )
     {
-        return i18n( i18nService, indicatorStore.getIndicator( uid ) );
+        return i18n( i18nService, indicatorStore.getByUid( uid ) );
     }
 
     public Collection<Indicator> getAllIndicators()
     {
-        return i18n( i18nService, indicatorStore.getAllIndicators() );
+        return i18n( i18nService, indicatorStore.getAll() );
     }
 
     public Collection<Indicator> getIndicators( final Collection<Integer> identifiers )
@@ -143,22 +143,22 @@
 
     public Indicator getIndicatorByName( String name )
     {
-        return i18n( i18nService, indicatorStore.getIndicatorByName( name ) );
+        return i18n( i18nService, indicatorStore.getByName( name ) );
     }
 
     public Indicator getIndicatorByShortName( String shortName )
     {
-        return i18n( i18nService, indicatorStore.getIndicatorByShortName( shortName ) );
+        return i18n( i18nService, indicatorStore.getByShortName( shortName ) );
     }
 
     public Indicator getIndicatorByAlternativeName( String alternativeName )
     {
-        return i18n( i18nService, indicatorStore.getIndicatorByAlternativeName( alternativeName ) );
+        return i18n( i18nService, indicatorStore.getByAlternativeName( alternativeName ) );
     }
 
     public Indicator getIndicatorByCode( String code )
     {
-        return i18n( i18nService, indicatorStore.getIndicatorByCode( code ) );
+        return i18n( i18nService, indicatorStore.getByCode( code ) );
     }
 
     public Collection<Indicator> getIndicatorsWithGroupSets()
@@ -178,27 +178,27 @@
 
     public int getIndicatorCount()
     {
-        return indicatorStore.getIndicatorCount();
+        return indicatorStore.getCount();
     }
 
     public int getIndicatorCountByName( String name )
     {
-        return indicatorStore.getIndicatorCountByName( name );
+        return indicatorStore.getCountByName( name );
     }
 
     public Collection<Indicator> getIndicatorsLikeName( String name )
     {
-        return i18n( i18nService, indicatorStore.getIndicatorsLikeName( name ) );
+        return i18n( i18nService, indicatorStore.getLikeName( name ) );
     }
 
     public Collection<Indicator> getIndicatorsBetween( int first, int max )
     {
-        return i18n( i18nService, indicatorStore.getIndicatorsBetween( first, max ) );
+        return i18n( i18nService, indicatorStore.getBetween( first, max ) );
     }
 
     public Collection<Indicator> getIndicatorsBetweenByName( String name, int first, int max )
     {
-        return i18n( i18nService, indicatorStore.getIndicatorsBetweenByName( name, first, max ) );
+        return i18n( i18nService, indicatorStore.getBetweenByName( name, first, max ) );
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/hibernate/HibernateIndicatorStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/hibernate/HibernateIndicatorStore.java	2011-11-25 14:03:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/hibernate/HibernateIndicatorStore.java	2011-12-09 19:30:02 +0000
@@ -29,10 +29,6 @@
 
 import java.util.Collection;
 
-import org.hibernate.Criteria;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorStore;
@@ -49,97 +45,6 @@
     // Indicator
     // -------------------------------------------------------------------------
 
-    @Override
-    public int addIndicator( Indicator indicator )
-    {
-        return this.save(indicator);
-    }
-
-    @Override
-    public void updateIndicator( Indicator indicator )
-    {
-        this.update( indicator );
-    }
-
-    public void deleteIndicator( Indicator indicator )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.delete( indicator );
-    }
-
-    public Indicator getIndicator( int id )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        return (Indicator) session.get( Indicator.class, id );
-    }
-
-    public Indicator getIndicator( String uid )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( Indicator.class );
-        criteria.add( Restrictions.eq( "uid", uid ) );
-
-        return (Indicator) criteria.uniqueResult();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<Indicator> getAllIndicators()
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( Indicator.class );
-        criteria.setCacheable( true );
-
-        return criteria.list();
-    }
-
-    public Indicator getIndicatorByName( String name )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Query query = session.createQuery( "from Indicator i where i.name = :name" );
-
-        query.setString( "name", name );
-
-        return (Indicator) query.uniqueResult();
-    }
-
-    public Indicator getIndicatorByShortName( String shortName )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Query query = session.createQuery( "from Indicator i where i.shortName = :shortName" );
-
-        query.setString( "shortName", shortName );
-
-        return (Indicator) query.uniqueResult();
-    }
-
-    public Indicator getIndicatorByAlternativeName( String alternativeName )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Query query = session.createQuery( "from Indicator i where i.alternativeName = :alternativeName" );
-
-        query.setString( "alternativeName", alternativeName );
-
-        return (Indicator) query.uniqueResult();
-    }
-
-    public Indicator getIndicatorByCode( String code )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Query query = session.createQuery( "from Indicator i where i.code = :code" );
-
-        query.setString( "code", code );
-
-        return (Indicator) query.uniqueResult();
-    }
-
     @SuppressWarnings( "unchecked" )
     public Collection<Indicator> getIndicatorsWithGroupSets()
     {
@@ -163,29 +68,4 @@
 
         return getQuery( hql ).setCacheable( true ).list();
     }
-
-    public int getIndicatorCount()
-    {
-        return getCount();
-    }
-
-    public int getIndicatorCountByName( String name )
-    {
-        return getCountByName( name );
-    }
-
-    public Collection<Indicator> getIndicatorsLikeName( String name )
-    {
-        return getLikeName( name );
-    }
-
-    public Collection<Indicator> getIndicatorsBetween( int first, int max )
-    {
-        return getBetween( first, max );
-    }
-
-    public Collection<Indicator> getIndicatorsBetweenByName( String name, int first, int max )
-    {
-        return getBetweenByName( name, first, max );
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetStoreTest.java	2011-04-22 17:02:27 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetStoreTest.java	2011-12-09 19:30:02 +0000
@@ -97,10 +97,10 @@
         dataSetB.getSources().add( unitA );
         dataSetC.getSources().add( unitB );
         
-        dataSetStore.addDataSet( dataSetA );
-        dataSetStore.addDataSet( dataSetB );
-        dataSetStore.addDataSet( dataSetC );
-        dataSetStore.addDataSet( dataSetD );
+        dataSetStore.save( dataSetA );
+        dataSetStore.save( dataSetB );
+        dataSetStore.save( dataSetC );
+        dataSetStore.save( dataSetD );
         
         Collection<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
         sources.add( unitA );
@@ -129,11 +129,11 @@
         DataSet dataSetA = createDataSet( 'A', periodType );
         DataSet dataSetB = createDataSet( 'B', periodType );
 
-        int idA = dataSetStore.addDataSet( dataSetA );
-        int idB = dataSetStore.addDataSet( dataSetB );
+        int idA = dataSetStore.save( dataSetA );
+        int idB = dataSetStore.save( dataSetB );
 
-        dataSetA = dataSetStore.getDataSet( idA );
-        dataSetB = dataSetStore.getDataSet( idB );
+        dataSetA = dataSetStore.get( idA );
+        dataSetB = dataSetStore.get( idB );
 
         assertEquals( idA, dataSetA.getId() );
         assertEq( 'A', dataSetA );
@@ -147,17 +147,17 @@
     {
         DataSet dataSet = createDataSet( 'A', periodType );
 
-        int id = dataSetStore.addDataSet( dataSet );
+        int id = dataSetStore.save( dataSet );
 
-        dataSet = dataSetStore.getDataSet( id );
+        dataSet = dataSetStore.get( id );
 
         assertEq( 'A', dataSet );
 
         dataSet.setName( "DataSetB" );
 
-        dataSetStore.updateDataSet( dataSet );
+        dataSetStore.update( dataSet );
 
-        dataSet = dataSetStore.getDataSet( id );
+        dataSet = dataSetStore.get( id );
 
         assertEquals( dataSet.getName(), "DataSetB" );
     }
@@ -168,21 +168,21 @@
         DataSet dataSetA = createDataSet( 'A', periodType );
         DataSet dataSetB = createDataSet( 'B', periodType );
 
-        int idA = dataSetStore.addDataSet( dataSetA );
-        int idB = dataSetStore.addDataSet( dataSetB );
-
-        assertNotNull( dataSetStore.getDataSet( idA ) );
-        assertNotNull( dataSetStore.getDataSet( idB ) );
-
-        dataSetStore.deleteDataSet( dataSetStore.getDataSet( idA ) );
-
-        assertNull( dataSetStore.getDataSet( idA ) );
-        assertNotNull( dataSetStore.getDataSet( idB ) );
-
-        dataSetStore.deleteDataSet( dataSetStore.getDataSet( idB ) );
-
-        assertNull( dataSetStore.getDataSet( idA ) );
-        assertNull( dataSetStore.getDataSet( idB ) );
+        int idA = dataSetStore.save( dataSetA );
+        int idB = dataSetStore.save( dataSetB );
+
+        assertNotNull( dataSetStore.get( idA ) );
+        assertNotNull( dataSetStore.get( idB ) );
+
+        dataSetStore.delete( dataSetStore.get( idA ) );
+
+        assertNull( dataSetStore.get( idA ) );
+        assertNotNull( dataSetStore.get( idB ) );
+
+        dataSetStore.delete( dataSetStore.get( idB ) );
+
+        assertNull( dataSetStore.get( idA ) );
+        assertNull( dataSetStore.get( idB ) );
     }
 
     @Test
@@ -192,12 +192,12 @@
         DataSet dataSetA = createDataSet( 'A', periodType );
         DataSet dataSetB = createDataSet( 'B', periodType );
 
-        int idA = dataSetStore.addDataSet( dataSetA );
-        int idB = dataSetStore.addDataSet( dataSetB );
+        int idA = dataSetStore.save( dataSetA );
+        int idB = dataSetStore.save( dataSetB );
 
-        assertEquals( dataSetStore.getDataSetByName( "DataSetA" ).getId(), idA );
-        assertEquals( dataSetStore.getDataSetByName( "DataSetB" ).getId(), idB );
-        assertNull( dataSetStore.getDataSetByName( "DataSetC" ) );
+        assertEquals( dataSetStore.getByName( "DataSetA" ).getId(), idA );
+        assertEquals( dataSetStore.getByName( "DataSetB" ).getId(), idB );
+        assertNull( dataSetStore.getByName( "DataSetC" ) );
     }
 
     @Test
@@ -207,12 +207,12 @@
         DataSet dataSetA = createDataSet( 'A', periodType );
         DataSet dataSetB = createDataSet( 'B', periodType );
 
-        int idA = dataSetStore.addDataSet( dataSetA );
-        int idB = dataSetStore.addDataSet( dataSetB );
+        int idA = dataSetStore.save( dataSetA );
+        int idB = dataSetStore.save( dataSetB );
 
-        assertEquals( dataSetStore.getDataSetByShortName( "DataSetShortA" ).getId(), idA );
-        assertEquals( dataSetStore.getDataSetByShortName( "DataSetShortB" ).getId(), idB );
-        assertNull( dataSetStore.getDataSetByShortName( "DataSetShortC" ) );
+        assertEquals( dataSetStore.getByShortName( "DataSetShortA" ).getId(), idA );
+        assertEquals( dataSetStore.getByShortName( "DataSetShortB" ).getId(), idB );
+        assertNull( dataSetStore.getByShortName( "DataSetShortC" ) );
     }
 
     @Test
@@ -221,10 +221,10 @@
         DataSet dataSetA = createDataSet( 'A', periodType );
         DataSet dataSetB = createDataSet( 'B', periodType );
 
-        dataSetStore.addDataSet( dataSetA );
-        dataSetStore.addDataSet( dataSetB );
+        dataSetStore.save( dataSetA );
+        dataSetStore.save( dataSetB );
 
-        Collection<DataSet> dataSets = dataSetStore.getAllDataSets();
+        Collection<DataSet> dataSets = dataSetStore.getAll();
 
         assertEquals( dataSets.size(), 2 );
         assertTrue( dataSets.contains( dataSetA ) );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorStoreTest.java	2011-11-22 15:48:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorStoreTest.java	2011-12-09 19:30:02 +0000
@@ -207,23 +207,23 @@
         Indicator indicatorB = createIndicator( 'B', type );
         Indicator indicatorC = createIndicator( 'A', type );
         
-        int idA = indicatorStore.addIndicator( indicatorA );
-        int idB = indicatorStore.addIndicator( indicatorB );
+        int idA = indicatorStore.save( indicatorA );
+        int idB = indicatorStore.save( indicatorB );
         
         try
         {
-            indicatorStore.addIndicator( indicatorC );
+            indicatorStore.save( indicatorC );
             fail( "Expected unique constraint exception" );
         }
         catch ( Exception ex )
         {
         }
 
-        indicatorA = indicatorStore.getIndicator( idA );
+        indicatorA = indicatorStore.get( idA );
         assertNotNull( indicatorA );
         assertEq( 'A', indicatorA );
         
-        indicatorB = indicatorStore.getIndicator( idB );
+        indicatorB = indicatorStore.get( idB );
         assertNotNull( indicatorB );
         assertEq( 'B', indicatorB );
     }
@@ -237,13 +237,13 @@
         indicatorTypeStore.save( type );
         
         Indicator indicatorA = createIndicator( 'A', type );
-        int idA = indicatorStore.addIndicator( indicatorA );
-        indicatorA = indicatorStore.getIndicator( idA );
+        int idA = indicatorStore.save( indicatorA );
+        indicatorA = indicatorStore.get( idA );
         assertEq( 'A', indicatorA );
         
         indicatorA.setName( "IndicatorB" );
-        indicatorStore.updateIndicator( indicatorA );
-        indicatorA = indicatorStore.getIndicator( idA );
+        indicatorStore.update( indicatorA );
+        indicatorA = indicatorStore.get( idA );
         assertNotNull( indicatorA );
         assertEquals( indicatorA.getName(), "IndicatorB" );
     }
@@ -259,21 +259,21 @@
         Indicator indicatorA = createIndicator( 'A', type );
         Indicator indicatorB = createIndicator( 'B', type );
 
-        int idA = indicatorStore.addIndicator( indicatorA );
-        int idB = indicatorStore.addIndicator( indicatorB );
-        
-        assertNotNull( indicatorStore.getIndicator( idA ) );
-        assertNotNull( indicatorStore.getIndicator( idB ) );
-        
-        indicatorStore.deleteIndicator( indicatorA );
-
-        assertNull( indicatorStore.getIndicator( idA ) );
-        assertNotNull( indicatorStore.getIndicator( idB ) );
-
-        indicatorStore.deleteIndicator( indicatorB );
-
-        assertNull( indicatorStore.getIndicator( idA ) );
-        assertNull( indicatorStore.getIndicator( idB ) );        
+        int idA = indicatorStore.save( indicatorA );
+        int idB = indicatorStore.save( indicatorB );
+        
+        assertNotNull( indicatorStore.get( idA ) );
+        assertNotNull( indicatorStore.get( idB ) );
+        
+        indicatorStore.delete( indicatorA );
+
+        assertNull( indicatorStore.get( idA ) );
+        assertNotNull( indicatorStore.get( idB ) );
+
+        indicatorStore.delete( indicatorB );
+
+        assertNull( indicatorStore.get( idA ) );
+        assertNull( indicatorStore.get( idB ) );        
     }
 
     @Test
@@ -287,10 +287,10 @@
         Indicator indicatorA = createIndicator( 'A', type );
         Indicator indicatorB = createIndicator( 'B', type );
 
-        indicatorStore.addIndicator( indicatorA );
-        indicatorStore.addIndicator( indicatorB );
+        indicatorStore.save( indicatorA );
+        indicatorStore.save( indicatorB );
         
-        Collection<Indicator> indicators = indicatorStore.getAllIndicators();
+        Collection<Indicator> indicators = indicatorStore.getAll();
         
         assertEquals( indicators.size(), 2 );
         assertTrue( indicators.contains( indicatorA ) );
@@ -308,17 +308,17 @@
         Indicator indicatorA = createIndicator( 'A', type );
         Indicator indicatorB = createIndicator( 'B', type );
 
-        int idA = indicatorStore.addIndicator( indicatorA );
-        int idB = indicatorStore.addIndicator( indicatorB );
-        
-        assertNotNull( indicatorStore.getIndicator( idA ) );
-        assertNotNull( indicatorStore.getIndicator( idB ) );
-        
-        indicatorA = indicatorStore.getIndicatorByName( "IndicatorA" );
+        int idA = indicatorStore.save( indicatorA );
+        int idB = indicatorStore.save( indicatorB );
+        
+        assertNotNull( indicatorStore.get( idA ) );
+        assertNotNull( indicatorStore.get( idB ) );
+        
+        indicatorA = indicatorStore.getByName( "IndicatorA" );
         assertNotNull( indicatorA );
         assertEq( 'A', indicatorA );
         
-        Indicator indicatorC = indicatorStore.getIndicatorByName( "IndicatorC" );
+        Indicator indicatorC = indicatorStore.getByName( "IndicatorC" );
         assertNull( indicatorC );
     }    
 
@@ -333,17 +333,17 @@
         Indicator indicatorA = createIndicator( 'A', type );
         Indicator indicatorB = createIndicator( 'B', type );
 
-        int idA = indicatorStore.addIndicator( indicatorA );
-        int idB = indicatorStore.addIndicator( indicatorB );
-        
-        assertNotNull( indicatorStore.getIndicator( idA ) );
-        assertNotNull( indicatorStore.getIndicator( idB ) );
-        
-        indicatorA = indicatorStore.getIndicatorByAlternativeName( "IndicatorAlternativeA" );
+        int idA = indicatorStore.save( indicatorA );
+        int idB = indicatorStore.save( indicatorB );
+        
+        assertNotNull( indicatorStore.get( idA ) );
+        assertNotNull( indicatorStore.get( idB ) );
+        
+        indicatorA = indicatorStore.getByAlternativeName( "IndicatorAlternativeA" );
         assertNotNull( indicatorA );
         assertEq( 'A', indicatorA );
         
-        Indicator indicatorC = indicatorStore.getIndicatorByAlternativeName( "IndicatorAlternativeC" );
+        Indicator indicatorC = indicatorStore.getByAlternativeName( "IndicatorAlternativeC" );
         assertNull( indicatorC );
     }
 
@@ -358,17 +358,17 @@
         Indicator indicatorA = createIndicator( 'A', type );
         Indicator indicatorB = createIndicator( 'B', type );
     
-        int idA = indicatorStore.addIndicator( indicatorA );
-        int idB = indicatorStore.addIndicator( indicatorB );
-        
-        assertNotNull( indicatorStore.getIndicator( idA ) );
-        assertNotNull( indicatorStore.getIndicator( idB ) );
-        
-        indicatorA = indicatorStore.getIndicatorByShortName( "IndicatorShortA" );
+        int idA = indicatorStore.save( indicatorA );
+        int idB = indicatorStore.save( indicatorB );
+        
+        assertNotNull( indicatorStore.get( idA ) );
+        assertNotNull( indicatorStore.get( idB ) );
+        
+        indicatorA = indicatorStore.getByShortName( "IndicatorShortA" );
         assertNotNull( indicatorA );
         assertEq( 'A', indicatorA );
         
-        Indicator indicatorC = indicatorStore.getIndicatorByShortName( "IndicatorShortC" );
+        Indicator indicatorC = indicatorStore.getByShortName( "IndicatorShortC" );
         assertNull( indicatorC );
     }
 }