← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20785: remove unused methods in PSI Store

 

------------------------------------------------------------
revno: 20785
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-10-20 13:36:51 +0700
message:
  remove unused methods in PSI Store
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.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/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2015-10-20 06:26:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2015-10-20 06:36:51 +0000
@@ -29,9 +29,7 @@
  */
 
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
-import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.event.EventStatus;
-import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.trackedentity.TrackedEntityInstance;
 
 import java.util.Collection;
@@ -107,32 +105,6 @@
     int getOverDueCount( ProgramStage programStage, Collection<Integer> orgunitIds, Date startDate, Date endDate );
 
     /**
-     * Get the number of program instances completed
-     *
-     * @param program    Program
-     * @param orgunitIds The ids of orgunits where the events happened
-     * @param after      Optional date the instance should be on or after.
-     * @param before     Optional date the instance should be on or before.
-     * @param status     The status of event. There are four statuses for events,
-     *                   includes COMPLETED_STATUS, VISITED_STATUS, FUTURE_VISIT_STATUS,
-     *                   LATE_VISIT_STATUS
-     * @return A number
-     */
-    int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date after, Date before, ProgramStatus status );
-
-    /**
-     * Get/Export a report about the number of events of a program completed on
-     * a orgunit
-     *
-     * @param orgunitIds The ids of orgunits where the events happened
-     * @param program    The program needs for reporting
-     * @param startDate  Optional date the instance should be on or after.
-     * @param endDate    Optional date the instance should be on or before.
-     * @return Grid
-     */
-    Grid getCompleteness( Collection<Integer> orgunitIds, Program program, String startDate, String endDate, I18n i18n );
-
-    /**
      * Get the number of ProgramStageInstances updates since the given Date.
      *
      * @param time the time.
@@ -140,5 +112,11 @@
      */
     long getProgramStageInstanceCountLastUpdatedAfter( Date time );
 
+    /**
+     * Checks for the existence of a PSI by UID
+     *
+     * @param uid PSI UID to check for
+     * @return true/false depending on result
+     */
     boolean exists( String uid );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2015-10-20 06:26:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2015-10-20 06:36:51 +0000
@@ -32,24 +32,17 @@
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Restrictions;
-import org.hisp.dhis.common.Grid;
-import org.hisp.dhis.common.GridHeader;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.commons.util.TextUtils;
 import org.hisp.dhis.event.EventStatus;
-import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceStore;
-import org.hisp.dhis.program.ProgramStatus;
 import org.hisp.dhis.program.ProgramType;
 import org.hisp.dhis.program.SchedulingProgramObject;
-import org.hisp.dhis.system.grid.GridUtils;
-import org.hisp.dhis.system.grid.ListGrid;
 import org.hisp.dhis.trackedentity.TrackedEntityInstance;
 import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder;
 import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminderService;
@@ -221,41 +214,6 @@
     }
 
     @Override
-    public Grid getCompleteness( Collection<Integer> orgunitIds, Program program, String startDate, String endDate,
-        I18n i18n )
-    {
-        String sql = "select ou.name as orgunit, ps.name as events, psi.completeduser as user_name, count(psi.programstageinstanceid) as number_of_events "
-            + "from programstageinstance psi "
-            + "inner join programstage ps on psi.programstageid = ps.programstageid "
-            + "inner join organisationunit ou on ou.organisationunitid=psi.organisationunitid "
-            + "inner join program pg on pg.programid = ps.programid "
-            + "where ou.organisationunitid in ( " + TextUtils.getCommaDelimitedString( orgunitIds ) + " ) "
-            + "and pg.programid = " + program.getId() + " "
-            + "group by ou.name, ps.name, psi.completeduser, psi.completeddate, psi.status "
-            + "having psi.completeddate >= '" + startDate + "' AND psi.completeddate <= '" + endDate + "' "
-            + "and psi.status='" + EventStatus.COMPLETED.name() + "' "
-            + "order by ou.name, ps.name, psi.completeduser";
-
-        SqlRowSet rs = jdbcTemplate.queryForRowSet( sql );
-
-        Grid grid = new ListGrid();
-
-        grid.setTitle( program.getDisplayName() );
-        grid.setSubtitle( i18n.getString( "from" ) + " " + startDate + " " + i18n.getString( "to" ) + " " + endDate );
-
-        int cols = rs.getMetaData().getColumnCount();
-
-        for ( int i = 1; i <= cols; i++ )
-        {
-            grid.addHeader( new GridHeader( i18n.getString( rs.getMetaData().getColumnLabel( i ) ), false, false ) );
-        }
-
-        GridUtils.addRows( grid, rs );
-
-        return grid;
-    }
-
-    @Override
     public long getProgramStageInstanceCountLastUpdatedAfter( Date time )
     {
         Number rs = (Number) getCriteria()
@@ -267,31 +225,6 @@
     }
 
     @Override
-    public int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date after, Date before, ProgramStatus status )
-    {
-        Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstancesByStatus( status, program, orgunitIds, after, before );
-
-        Criteria criteria = getCriteria();
-        criteria.createAlias( "programInstance", "programInstance" );
-        criteria.createAlias( "programStage", "programStage" );
-        criteria.createAlias( "programInstance.entityInstance", "entityInstance" );
-        criteria.add( Restrictions.eq( "programInstance.program", program ) );
-        criteria.add( Restrictions.eq( "programInstance.status", status ) );
-        criteria.add( Restrictions.in( "organisationUnit.id", orgunitIds ) );
-        criteria.add( Restrictions.between( "programInstance.endDate", after, before ) );
-        criteria.add( Restrictions.eq( "status", EventStatus.COMPLETED ) );
-
-        if ( programInstances != null && programInstances.size() > 0 )
-        {
-            criteria.add( Restrictions.not( Restrictions.in( "programInstance", programInstances ) ) );
-        }
-
-        Number rs = (Number) criteria.setProjection( Projections.rowCount() ).uniqueResult();
-
-        return rs != null ? rs.intValue() : 0;
-    }
-
-    @Override
     public boolean exists( String uid )
     {
         Integer result = jdbcTemplate.queryForObject( "select count(*) from programstageinstance where uid=?", Integer.class, uid );