dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03854
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1284: Work in progress on gap analysis.
------------------------------------------------------------
revno: 1284
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2009-12-24 09:55:53 +0100
message:
Work in progress on gap analysis.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/GapAnalysisService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/DeflatedDataValueNameMinMaxRowMapper.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/dataanalysis/DataAnalysisStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java 2009-12-23 18:55:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java 2009-12-24 08:55:53 +0000
@@ -47,6 +47,6 @@
Collection<DeflatedDataValue> getDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
Collection<Period> periods, OrganisationUnit organisationUnit, int lowerBound, int upperBound );
- Collection<DeflatedDataValue> getNonExistingDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
+ Collection<DeflatedDataValue> getDeflatedDataValueGaps( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
Collection<Period> periods, OrganisationUnit organisationUnit );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/GapAnalysisService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/GapAnalysisService.java 2009-12-23 18:55:58 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/GapAnalysisService.java 2009-12-24 08:55:53 +0000
@@ -69,9 +69,9 @@
Collection<DataElement> dataElements, Collection<Period> periods, Double stdDevFactor )
{
Collection<OrganisationUnit> units = organisationUnitService.getOrganisationUnitWithChildren( organisationUnit.getId() );
+
+ Collection<DeflatedDataValue> gapCollection = new ArrayList<DeflatedDataValue>();
- Collection<DeflatedDataValue> outlierCollection = new ArrayList<DeflatedDataValue>();
-
for ( DataElement dataElement : dataElements )
{
if ( dataElement.getType().equals( DataElement.VALUE_TYPE_INT ) )
@@ -82,13 +82,12 @@
{
for ( OrganisationUnit unit : units )
{
- outlierCollection.addAll( dataAnalysisStore.getNonExistingDeflatedDataValues(
- dataElement, categoryOptionCombo, periods, unit ) );
+ gapCollection.addAll( dataAnalysisStore.getDeflatedDataValueGaps( dataElement, categoryOptionCombo, periods, unit ) );
}
}
}
}
- return outlierCollection;
+ return gapCollection;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java 2009-12-23 18:43:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java 2009-12-24 08:55:53 +0000
@@ -74,7 +74,7 @@
Collection<OrganisationUnit> units = organisationUnitService.getOrganisationUnitWithChildren( organisationUnit.getId() );
Collection<DeflatedDataValue> outlierCollection = new ArrayList<DeflatedDataValue>();
-
+
for ( DataElement dataElement : dataElements )
{
if ( dataElement.getType().equals( DataElement.VALUE_TYPE_INT ) )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java 2009-12-24 07:36:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java 2009-12-24 08:55:53 +0000
@@ -109,7 +109,7 @@
final String sql =
"SELECT dv.dataelementid, dv.periodid, dv.sourceid, dv.categoryoptioncomboid, dv.value, dv.storedby, dv.lastupdated, " +
"dv.comment, dv.followup, '" + lowerBound + "' AS minvalue, '" + upperBound + "' AS maxvalue, " +
- "'" + dataElement.getName() + "' AS dataelementname, pe.startdate, pe.enddate, pt.name AS periodtypename, " +
+ "'" + dataElement.getName() + "' AS dataelementname, pt.name AS periodtypename, pe.startdate, pe.enddate, " +
"'" + organisationUnit.getName() + "' AS sourcename, cc.categoryoptioncomboname " +
"FROM datavalue AS dv " +
"JOIN period AS pe USING (periodid) " +
@@ -136,36 +136,35 @@
holder.close();
}
}
-
- public Collection<DeflatedDataValue> getNonExistingDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
+
+ public Collection<DeflatedDataValue> getDeflatedDataValueGaps( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
Collection<Period> periods, OrganisationUnit organisationUnit )
{
final StatementHolder holder = statementManager.getHolder();
-
+
final ObjectMapper<DeflatedDataValue> mapper = new ObjectMapper<DeflatedDataValue>();
final String periodIds = TextUtils.getCommaDelimitedString( ConversionUtils.getIdentifiers( Period.class, periods ) );
+ // TODO minmax
+
try
{
- //TODO minmax
-
final String sql =
- "SELECT dv.dataelementid, dv.periodid, dv.sourceid, dv.categoryoptioncomboid, dv.value, dv.storedby, dv.lastupdated, " +
- "dv.comment, dv.followup, '1' AS minvalue, '2' AS maxvalue, de.name AS dataelementname, " +
- "pe.startdate, pe.enddate, pt.name as periodtypename, ou.name AS sourcename, cc.categoryoptioncomboname " +
- "FROM datavalue AS dv " +
- "JOIN dataelement AS de USING (dataelementid) " +
- "RIGHT JOIN period AS pe USING (periodid) " +
- "JOIN periodtype AS pt USING (periodtypeid) " +
- "JOIN source AS sr USING (sourceid) " +
- "JOIN organisationunit AS ou ON ou.organisationunitid=sr.sourceid " +
- "LEFT JOIN categoryoptioncomboname AS cc USING (categoryoptioncomboid) " +
- "WHERE dv.dataelementid='" + dataElement.getId() + "' " +
- "AND dv.categoryoptioncomboid='" + categoryOptionCombo.getId() + "' " +
- "AND dv.periodid IN (" + periodIds + ") " +
- "AND pt.periodtypeid='" + dataElement.getPeriodType().getId() + "' " +
- "AND dv.sourceid='" + organisationUnit.getId() + "' )";
+ "SELECT '" + dataElement.getId() + "' AS dataelementid, pe.periodid " +
+ "'" + organisationUnit.getId() + "' AS sourceid, '" + categoryOptionCombo.getId() + "' AS categoryoptioncomboid, " +
+ "'' AS value, '' AS storedby, '1900-01-01' AS lastupdated, '' AS comment, false AS followup, 0 as minvalue, 0 as maxvalue, " +
+ "'" + dataElement.getName() + "' AS dataelementname, pt.name AS periodtypename, pe.startdate, pe.enddate, " +
+ "'" + organisationUnit.getName() + "' AS sourcename, '" + categoryOptionCombo.getName() + "' as categoryoptioncomboname " +
+ "FROM period as pe " +
+ "JOIN periodtype as pt USING (periodtypeid) " +
+ "WHERE periodid IN (" + periodIds + ") " +
+ "AND periodtypeid='" + dataElement.getPeriodType().getId() + "' " +
+ "AND periodid NOT IN ( " +
+ "SELECT periodid FROM datavalue " +
+ "WHERE dataelementid='" + dataElement.getId() + "' " +
+ "AND categoryoptioncomboid='" + categoryOptionCombo.getId() + "' " +
+ "AND sourceid='" + organisationUnit + "' )";
final ResultSet resultSet = holder.getStatement().executeQuery( sql );
@@ -179,5 +178,5 @@
{
holder.close();
}
- }
+ }
}
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/DeflatedDataValueNameMinMaxRowMapper.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/DeflatedDataValueNameMinMaxRowMapper.java 2009-12-23 12:09:02 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/DeflatedDataValueNameMinMaxRowMapper.java 2009-12-24 08:55:53 +0000
@@ -37,23 +37,23 @@
* RowMapper which expects a result set with the following columns:
*
* <ul>
- * <li>1: dataelementid</li>
- * <li>2: periodid</li>
- * <li>3: sourceid</li>
- * <li>4: categoryoptioncomboid</li>
- * <li>5: value</li>
- * <li>6: storedby</li>
- * <li>7: lastupdated</li>
- * <li>8: comment</li>
- * <li>9: followup</li>
- * <li>10: minvalue</li>
- * <li>11: maxvalue</li>
- * <li>12: dataelementname</li>
- * <li>13: periodtypename</li>
- * <li>14: startdate</li>
- * <li>15: enddate</li>
- * <li>16: sourcename</li>
- * <li>17: categoryoptioncomboname</li>
+ * <li>1: dataelementid - int</li>
+ * <li>2: periodid - int</li>
+ * <li>3: sourceid - int</li>
+ * <li>4: categoryoptioncomboid - int</li>
+ * <li>5: value - String</li>
+ * <li>6: storedby - String</li>
+ * <li>7: lastupdated - date</li>
+ * <li>8: comment - String</li>
+ * <li>9: followup - Boolean</li>
+ * <li>10: minvalue - int</li>
+ * <li>11: maxvalue - int</li>
+ * <li>12: dataelementname - String</li>
+ * <li>13: periodtypename - String</li>
+ * <li>14: startdate - String</li>
+ * <li>15: enddate - String</li>
+ * <li>16: sourcename - String</li>
+ * <li>17: categoryoptioncomboname - String</li>
* </ul>
*
* @author Lars Helge Overland