dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15212
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5405: Merge api and services in trunk
------------------------------------------------------------
revno: 5405
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-12-14 16:39:39 +0530
message:
Merge api and services in trunk
modified:
local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportType.java
local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java
local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetOrgUnitsAction.java
local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetReportsAction.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 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java 2011-11-02 09:54:19 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java 2011-12-14 11:09:39 +0000
@@ -160,5 +160,9 @@
List<Report_inDesign> getReportDesignWithMergeCells( String fileName );
//Map<String, String> getLLDeathDataFromLLDataValueTable( Integer orgunitId, String dataElmentIdsForLLDeathByComma, String periodIdsByComma , Integer recordNo );
- Map<String, String> getLLDeathDataFromLLDataValueTable( Integer orgunitId, String dataElmentIdsForLLDeathByComma, String periodIdsByComma , String recordNoByComma );
+ Map<String, String> getLLDeathDataFromLLDataValueTable( Integer orgunitId, String dataElmentIdsForLLDeathByComma, String periodIdsByComma , String recordNoByComma );
+
+ Map<String, String> getAggDataFromDataValueTableForOrgUnitWise( String orgUnitIdsByComma, String dataElmentIdsByComma, String periodIdsByComma );
+
+ Map<String, String> getAggDataFromAggDataValueTableForOrgUnitWise( String orgUnitIdsByComma, String dataElmentIdsByComma, String periodIdsByComma );
}
=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportType.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportType.java 2011-11-02 09:54:19 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportType.java 2011-12-14 11:09:39 +0000
@@ -61,6 +61,8 @@
public final static String RT_LINELIST_BULK_REPORT = "Linelisting Bulk Reports";
public final static String RT_COLDCHAIN_REPORT = "Cold Chain Reports";
+
+ public final static String RT_MD_REPORT = "MD Reports";
public static List<String> getReportTypes()
{
@@ -96,6 +98,8 @@
reportTypes.add( RT_COLDCHAIN_REPORT );
+ reportTypes.add( RT_MD_REPORT );
+
return reportTypes;
}
}
=== modified file 'local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java'
--- local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java 2011-11-02 09:54:19 +0000
+++ local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java 2011-12-14 11:09:39 +0000
@@ -1945,6 +1945,54 @@
}
}
+
+ public Map<String, String> getAggDataFromAggDataValueTableForOrgUnitWise( String orgUnitIdsByComma, String dataElmentIdsByComma, String periodIdsByComma )
+ {
+ Map<String, String> aggDataMap = new HashMap<String, String>();
+ DatabaseInfo dataBaseInfo = databaseInfoProvider.getDatabaseInfo();
+ try
+ {
+ String query = "";
+ if( dataBaseInfo.getType().equalsIgnoreCase( "postgresql" ) )
+ {
+ query = "SELECT organisationunitid, dataelementid,categoryoptioncomboid, SUM( cast( value as numeric) ) FROM aggregateddatavalue" +
+ " WHERE dataelementid IN (" + dataElmentIdsByComma + ") AND "+
+ " organisationunitid IN ("+ orgUnitIdsByComma +") AND "+
+ " periodid IN (" + periodIdsByComma +") " +
+ " GROUP BY organisationunitid,dataelementid,categoryoptioncomboid";
+ }
+ else if( dataBaseInfo.getType().equalsIgnoreCase( "mysql" ) )
+ {
+ query = "SELECT organisationunitid, dataelementid,categoryoptioncomboid, SUM(value) FROM aggregateddatavalue" +
+ " WHERE dataelementid IN (" + dataElmentIdsByComma + ") AND "+
+ " organisationunitid IN ("+ orgUnitIdsByComma +") AND "+
+ " periodid IN (" + periodIdsByComma +") " +
+ " GROUP BY organisationunitid,dataelementid,categoryoptioncomboid";
+ }
+
+ SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+
+ while ( rs.next() )
+ {
+ Integer ouId = rs.getInt( 1 );
+ Integer deId = rs.getInt( 2 );
+ Integer optionComId = rs.getInt( 3 );
+ Double aggregatedValue = rs.getDouble( 4 );
+ if( aggregatedValue != null )
+ {
+ aggDataMap.put( deId+"."+optionComId+":"+ouId, ""+aggregatedValue );
+ }
+ }
+
+ return aggDataMap;
+ }
+ catch( Exception e )
+ {
+ throw new RuntimeException( "Illegal DataElement id", e );
+ }
+ }
+
+
public Map<String, String> getResultDataValueFromAggregateTable( String orgUnitIdsByComma, String dataElmentIdsByComma, String periodIdsByComma )
{
@@ -2621,6 +2669,51 @@
throw new RuntimeException( "Illegal DataElement id", e );
}
}
-
-
+
+ public Map<String, String> getAggDataFromDataValueTableForOrgUnitWise( String orgUnitIdsByComma, String dataElmentIdsByComma, String periodIdsByComma )
+ {
+ Map<String, String> aggDataMap = new HashMap<String, String>();
+ DatabaseInfo dataBaseInfo = databaseInfoProvider.getDatabaseInfo();
+ try
+ {
+ String query = "";
+ if( dataBaseInfo.getType().equalsIgnoreCase( "postgresql" ) )
+ {
+ query = "SELECT sourceid, dataelementid,categoryoptioncomboid, SUM( cast( value as numeric) ) FROM datavalue" +
+ " WHERE dataelementid IN (" + dataElmentIdsByComma + ") AND "+
+ " sourceid IN ("+ orgUnitIdsByComma +") AND "+
+ " periodid IN (" + periodIdsByComma +") " +
+ " GROUP BY sourceid,dataelementid,categoryoptioncomboid";
+ }
+ else if( dataBaseInfo.getType().equalsIgnoreCase( "mysql" ) )
+ {
+ query = "SELECT sourceid, dataelementid,categoryoptioncomboid, SUM(value) FROM datavalue" +
+ " WHERE dataelementid IN (" + dataElmentIdsByComma + ") AND "+
+ " sourceid IN ("+ orgUnitIdsByComma +") AND "+
+ " periodid IN (" + periodIdsByComma +") " +
+ " GROUP BY sourceid,dataelementid,categoryoptioncomboid";
+ }
+
+ SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+ String tempValue = "";
+ while ( rs.next() )
+ {
+ Integer ouId = rs.getInt( 1 );
+ Integer deId = rs.getInt( 2 );
+ Integer optionComId = rs.getInt( 3 );
+ tempValue = rs.getString( 4 );
+ //Double aggregatedValue = rs.getDouble( 4 );
+ if( tempValue != null )
+ {
+ aggDataMap.put( deId+"."+optionComId+":"+ouId, ""+tempValue );
+ }
+ }
+
+ return aggDataMap;
+ }
+ catch( Exception e )
+ {
+ throw new RuntimeException( "Illegal DataElement id", e );
+ }
+ }
}
=== modified file 'local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetOrgUnitsAction.java'
--- local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetOrgUnitsAction.java 2011-01-18 12:01:24 +0000
+++ local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetOrgUnitsAction.java 2011-12-14 11:09:39 +0000
@@ -55,7 +55,8 @@
if ( orgUnitId != null )
{
orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
- ouLevel = "" + organisationUnitService.getLevelOfOrganisationUnit( orgUnit );
+ //ouLevel = "" + organisationUnitService.getLevelOfOrganisationUnit( orgUnit );
+ ouLevel = "" + organisationUnitService.getLevelOfOrganisationUnit( orgUnit.getId() );
System.out.println( orgUnit.getId() + " ---- " + orgUnit.getShortName() );
}
=== modified file 'local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetReportsAction.java'
--- local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetReportsAction.java 2011-01-18 12:01:24 +0000
+++ local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/GetReportsAction.java 2011-12-14 11:09:39 +0000
@@ -118,7 +118,8 @@
{
orgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( ouId ) );
- int ouLevel = organisationUnitService.getLevelOfOrganisationUnit( orgUnit );
+ //int ouLevel = organisationUnitService.getLevelOfOrganisationUnit( orgUnit );
+ int ouLevel = organisationUnitService.getLevelOfOrganisationUnit( orgUnit.getId() );
if ( autogenrep.equalsIgnoreCase( "1" ) )
ouLevel++;