dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13864
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4559: Extended data statistics with no of datavalues captured today, yesterday, last 7 and last 30 days
------------------------------------------------------------
revno: 4559
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-09-11 12:39:49 +0200
message:
Extended data statistics with no of datavalues captured today, yesterday, last 7 and last 30 days
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/statistics/GetStatisticsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewStatistics.vm
--
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/datavalue/DataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java 2011-06-04 13:52:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java 2011-09-11 10:39:49 +0000
@@ -261,5 +261,13 @@
* @param operands the data element operands to filter.
* @return the data element operands with registered data values.
*/
- Set<DataElementOperand> getOperandsWithDataValues( Set<DataElementOperand> operands );
+ Set<DataElementOperand> getOperandsWithDataValues( Set<DataElementOperand> operands );
+
+ /**
+ * Gets the number of DataValues persisted since the given number of days.
+ *
+ * @param days the number of days since now to include in the count.
+ * @return the number of DataValues.
+ */
+ int getDataValueCount( int days );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java 2011-06-04 13:52:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java 2011-09-11 10:39:49 +0000
@@ -28,6 +28,7 @@
*/
import java.util.Collection;
+import java.util.Date;
import java.util.Set;
import org.hisp.dhis.dataelement.DataElement;
@@ -254,4 +255,12 @@
* @return the data element operands with registered data values.
*/
Set<DataElementOperand> getOperandsWithDataValues( Set<DataElementOperand> operands );
+
+ /**
+ * Gets the number of DataValues persisted since the given data.
+ *
+ * @param date the date.
+ * @return the number of DataValues.
+ */
+ int getDataValueCount( Date date );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2011-06-04 13:52:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2011-09-11 10:39:49 +0000
@@ -29,6 +29,7 @@
import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE;
+import java.util.Calendar;
import java.util.Collection;
import java.util.Set;
@@ -203,4 +204,12 @@
{
return dataValueStore.getOperandsWithDataValues( operands );
}
+
+ public int getDataValueCount( int days )
+ {
+ Calendar cal = PeriodType.createCalendarInstance();
+ cal.add( Calendar.DAY_OF_YEAR, (days * -1) );
+
+ return dataValueStore.getDataValueCount( cal.getTime() );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java 2011-06-04 13:52:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java 2011-09-11 10:39:49 +0000
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.HashSet;
import java.util.Set;
@@ -39,6 +40,7 @@
import org.hibernate.Query;
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.dataelement.DataElementCategoryOptionCombo;
@@ -400,5 +402,17 @@
}
return operandsWithData;
- }
+ }
+
+ public int getDataValueCount( Date date )
+ {
+ Criteria criteria = sessionFactory.getCurrentSession().createCriteria( DataValue.class );
+
+ criteria.add( Restrictions.ge( "timestamp", date ) );
+ criteria.setProjection( Projections.rowCount() );
+
+ Number rs = (Number) criteria.uniqueResult();
+
+ return rs != null ? rs.intValue() : 0;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/statistics/GetStatisticsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/statistics/GetStatisticsAction.java 2011-09-04 10:21:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/statistics/GetStatisticsAction.java 2011-09-11 10:39:49 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.statistics.StatisticsProvider;
import org.hisp.dhis.common.Objects;
+import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.system.util.EnumMapWrapper;
import org.hisp.dhis.user.UserService;
@@ -61,6 +62,13 @@
{
this.userService = userService;
}
+
+ private DataValueService dataValueService;
+
+ public void setDataValueService( DataValueService dataValueService )
+ {
+ this.dataValueService = dataValueService;
+ }
// -------------------------------------------------------------------------
// Output
@@ -79,6 +87,13 @@
{
return activeUsers;
}
+
+ private Map<Integer, Integer> dataValueCount = new HashMap<Integer, Integer>();
+
+ public Map<Integer, Integer> getDataValueCount()
+ {
+ return dataValueCount;
+ }
// -------------------------------------------------------------------------
// Action implementation
@@ -96,6 +111,11 @@
activeUsers.put( 7, userService.getActiveUsersCount( 7 ) );
activeUsers.put( 30, userService.getActiveUsersCount( 30 ) );
+ dataValueCount.put( 0, dataValueService.getDataValueCount( 0 ) );
+ dataValueCount.put( 1, dataValueService.getDataValueCount( 1 ) );
+ dataValueCount.put( 7, dataValueService.getDataValueCount( 7 ) );
+ dataValueCount.put( 30, dataValueService.getDataValueCount( 30 ) );
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2011-09-11 10:39:49 +0000
@@ -79,6 +79,7 @@
scope="prototype">
<property name="statisticsProvider" ref="org.hisp.dhis.statistics.StatisticsProvider" />
<property name="userService" ref="org.hisp.dhis.user.UserService" />
+ <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService"/>
</bean>
<bean id="org.hisp.dhis.dataadmin.action.statistics.GetStatisticsChartAction" class="org.hisp.dhis.dataadmin.action.statistics.GetStatisticsChartAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewStatistics.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewStatistics.vm 2011-09-04 10:21:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewStatistics.vm 2011-09-11 10:39:49 +0000
@@ -93,4 +93,30 @@
</tr>
</table>
+<table>
+ <tr>
+ <th style="width:200px">$i18n.getString( "data_values" )</th>
+ <th style="width:200px">$i18n.getString( "number" )</th>
+ </tr>
+ <tr>
+ <td>$i18n.getString( "today" )</td>
+ <td>$dataValueCount.get( 0 )</td>
+ </tr>
+ <tr>
+ <td>$i18n.getString( "yesterday" )</td>
+ <td>$dataValueCount.get( 1 )</td>
+ </tr>
+ <tr>
+ <td>$i18n.getString( "last_7_days" )</td>
+ <td>$dataValueCount.get( 7 )</td>
+ </tr>
+ <tr>
+ <td>$i18n.getString( "last_30_days" )</td>
+ <td>$dataValueCount.get( 30 )</td>
+ </tr>
+ <tr>
+ <td colspan="2" style="height:15px"></td>
+ </tr>
+</table>
+
<p><img src="viewStatisticsChart.action" alt="$i18n.getString( 'number_of_objects' )" style="border: 1px solid #d0d0d0; margin-left: 2px"/></p>