dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20732
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9618: Added column daysno to analytics table
------------------------------------------------------------
revno: 9618
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-01-27 13:43:58 +0200
message:
Added column daysno to analytics table
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java
dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html
tools/dhis-adhoc/src/main/java/org/hisp/dhis/adhoc/RunMe.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-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-01-26 08:20:27 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-01-27 11:43:58 +0000
@@ -136,8 +136,6 @@
grid.addHeader( new GridHeader( DataQueryParams.VALUE_ID, VALUE_HEADER_NAME, Double.class.getName(), false, false ) );
- //TODO how to handle group sets?
-
// ---------------------------------------------------------------------
// Indicators
// ---------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java 2013-01-22 07:59:25 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java 2013-01-27 11:43:58 +0000
@@ -94,11 +94,11 @@
List<Dimension> queryDimensions = params.getQueryDimensions();
SqlHelper sqlHelper = new SqlHelper();
-
- String sql = "select " + getCommaDelimitedString( selectDimensions ) + ", "; //TODO
-
+
int days = PeriodType.getPeriodTypeByName( params.getPeriodType() ).getFrequencyOrder();
+ String sql = "select " + getCommaDelimitedString( selectDimensions ) + ", ";
+
if ( params.isAggregationType( AVERAGE_AGGREGATION ) )
{
sql += "sum(daysxvalue) / " + days;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java 2013-01-25 16:38:21 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java 2013-01-27 11:43:58 +0000
@@ -86,7 +86,7 @@
sqlCreate += col[0] + " " + col[1] + ",";
}
- sqlCreate += "daysxvalue double precision, value double precision)";
+ sqlCreate += "daysxvalue double precision, daysno integer not null, value double precision)";
log.info( "Create SQL: " + sqlCreate );
@@ -99,14 +99,16 @@
Date startDate = period.getStartDate();
Date endDate = period.getEndDate();
- populateTable( tableName, startDate, endDate, "cast(dv.value as double precision)", "int" );
+ populateTable( tableName, startDate, endDate, "cast(dv.value as double precision)", "int", "dv.value != ''" );
- populateTable( tableName, startDate, endDate, "1" , "bool" );
+ populateTable( tableName, startDate, endDate, "1" , "bool", "dv.value = 'true'" );
+
+ populateTable( tableName, startDate, endDate, "0" , "bool", "dv.value = 'false'" );
return null;
}
- private void populateTable( String tableName, Date startDate, Date endDate, String valueExpression, String valueType )
+ private void populateTable( String tableName, Date startDate, Date endDate, String valueExpression, String valueType, String clause )
{
final String start = DateUtils.getMediumDateString( startDate );
final String end = DateUtils.getMediumDateString( endDate );
@@ -118,7 +120,7 @@
insert += col[0] + ",";
}
- insert += "daysxvalue, value) ";
+ insert += "daysxvalue, daysno, value) ";
String select = "select ";
@@ -127,10 +129,9 @@
select += col[2] + ",";
}
- select = select.replace( "organisationunitid", "sourceid" ); // Legacy fix TODO remove
-
select +=
- valueExpression + " * ps.daysno as value, " +
+ valueExpression + " * ps.daysno as daysxvalue, " +
+ "ps.daysno as daysno, " +
valueExpression + " as value " +
"from datavalue dv " +
"left join _dataelementgroupsetstructure degs on dv.dataelementid=degs.dataelementid " +
@@ -143,8 +144,8 @@
"where de.valuetype='" + valueType + "' " +
"and pe.startdate >= '" + start + "' " +
"and pe.startdate <= '" + end + "'" +
- "and dv.value != ''" +
- "and dv.value is not null";
+ "and dv.value is not null " +
+ "and " + clause;
final String sql = insert + select;
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java 2012-12-30 10:52:46 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java 2013-01-27 11:43:58 +0000
@@ -115,9 +115,11 @@
final Date currentStartDate = period.getStartDate();
final Date currentEndDate = period.getEndDate();
+ final double duration = getDaysInclusive( currentStartDate, currentEndDate );
+
final int dataValueLevel = aggregationCache.getLevelOfOrganisationUnit( crossTabValue.getSourceId() );
- if ( getDaysInclusive( currentStartDate, currentEndDate ) > 0 )
+ if ( duration > 0 )
{
for ( final Entry<DataElementOperand, String> entry : crossTabValue.getValueMap().entrySet() ) // <Operand, value>
{
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html'
--- dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html 2013-01-25 20:45:07 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html 2013-01-27 11:43:58 +0000
@@ -48,6 +48,7 @@
<div style="font-family:courier,sans-serif; padding:20px; border: 1px solid #ddd;">
var orgUnit = dhis2.report.organisationUnit; // An object<br><br>
+var id = orgUnit.id;
var name = orgUnit.name;<br>
var shortName = orgUnit.shortName;<br>
var code = orgUnit.code;<br><br>
=== modified file 'tools/dhis-adhoc/src/main/java/org/hisp/dhis/adhoc/RunMe.java'
--- tools/dhis-adhoc/src/main/java/org/hisp/dhis/adhoc/RunMe.java 2013-01-24 08:39:47 +0000
+++ tools/dhis-adhoc/src/main/java/org/hisp/dhis/adhoc/RunMe.java 2013-01-27 11:43:58 +0000
@@ -9,6 +9,12 @@
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
+ * The purpose of this tool is to assist in performing ad-hoc tasks which
+ * benefits from having the DHIS 2 service layer accessible. Examples of
+ * such tasks are writing complex custom data entry forms to file, generating
+ * custom HTML or Jasper reports, and performing database operations which
+ * cannot be solved using SQL.
+ *
* This class should be executed. You can do this e.g. by choosing "Run as" -
* "Java application" in your IDE.
*