dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #00177
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 50: Improved data integrity checks.
------------------------------------------------------------
revno: 50
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Fri 2009-03-13 07:24:17 +0100
message:
Improved data integrity checks.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/AggregatedDataValueConverter.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java 2009-03-11 12:42:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java 2009-03-13 06:24:17 +0000
@@ -28,6 +28,7 @@
*/
import java.util.Collection;
+import java.util.Map;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
@@ -65,7 +66,7 @@
* Returns all data elements which are members of data sets with different
* period types.
*/
- Collection<DataElement> getDataElementsAssignedToDataSetsWithDifferentPeriodTypes();
+ Map<DataElement, Collection<DataSet>> getDataElementsAssignedToDataSetsWithDifferentPeriodTypes();
// -------------------------------------------------------------------------
// DataSet
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2009-03-11 12:42:37 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2009-03-13 06:24:17 +0000
@@ -29,9 +29,11 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.hisp.dhis.dataelement.DataElement;
@@ -158,32 +160,32 @@
return dataElements;
}
- public Collection<DataElement> getDataElementsAssignedToDataSetsWithDifferentPeriodTypes()
+ public Map<DataElement, Collection<DataSet>> getDataElementsAssignedToDataSetsWithDifferentPeriodTypes()
{
Collection<DataElement> dataElements = dataElementService.getAllDataElements();
Collection<DataSet> dataSets = dataSetService.getAllDataSets();
- Collection<DataElement> targets = new ArrayList<DataElement>();
-
- Set<PeriodType> periodTypes = new HashSet<PeriodType>();
-
+ Map<DataElement, Collection<DataSet>> targets = new HashMap<DataElement, Collection<DataSet>>();
+
for ( DataElement element : dataElements )
{
+ final Set<PeriodType> targetPeriodTypes = new HashSet<PeriodType>();
+ final Collection<DataSet> targetDataSets = new HashSet<DataSet>();
+
for ( DataSet dataSet : dataSets )
{
if ( dataSet.getDataElements().contains( element ) )
{
- periodTypes.add( dataSet.getPeriodType() );
+ targetPeriodTypes.add( dataSet.getPeriodType() );
+ targetDataSets.add( dataSet );
}
}
- if ( periodTypes.size() > 1 )
+ if ( targetPeriodTypes.size() > 1 )
{
- targets.add( element );
- }
-
- periodTypes.clear();
+ targets.put( element, targetDataSets );
+ }
}
return targets;
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java 2009-03-11 12:42:37 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java 2009-03-13 06:24:17 +0000
@@ -28,6 +28,7 @@
*/
import java.util.Collection;
+import java.util.Map;
import org.hisp.dhis.DhisConvenienceTest;
import org.hisp.dhis.dataelement.DataElement;
@@ -230,9 +231,11 @@
public void testGetDataElementsAssignedToDataSetsWithDifferentPeriodType()
{
- Collection<DataElement> expected = dataIntegrityService.getDataElementsAssignedToDataSetsWithDifferentPeriodTypes();
+ Map<DataElement, Collection<DataSet>> expected = dataIntegrityService.getDataElementsAssignedToDataSetsWithDifferentPeriodTypes();
- assertTrue( equals( expected, elementA ) );
+ assertEquals( 1, expected.size() );
+ assertEquals( elementA, expected.keySet().iterator().next() );
+ assertTrue( equals( expected.get( elementA ), dataSetA, dataSetB ) );
}
public void testGetDataSetsNotAssignedToOrganisationUnits()
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/AggregatedDataValueConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/AggregatedDataValueConverter.java 2009-03-11 15:16:35 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/AggregatedDataValueConverter.java 2009-03-13 06:24:17 +0000
@@ -33,6 +33,8 @@
import org.amplecode.staxwax.reader.XMLReader;
import org.amplecode.staxwax.writer.XMLWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.aggregation.AggregatedDataValue;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.datamart.DataMartStore;
@@ -51,6 +53,8 @@
public class AggregatedDataValueConverter
implements XMLConverter
{
+ private static final Log log = LogFactory.getLog( AggregatedDataValueConverter.class );
+
public static final String COLLECTION_NAME = "dataValues";
public static final String ELEMENT_NAME = "dataValue";
@@ -113,6 +117,8 @@
periods = periodService.getIntersectingPeriodsByPeriodType( periodType, params.getStartDate(), params.getEndDate() );
+ log.debug( "Using period type: " + periodType.getName() + " for data element: " + dataElement.getName() );
+
values = dataMartStore.getAggregatedDataValues( dataElement.getId(),
getIdentifiers( Period.class, periods ), params.getOrganisationUnits() );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java 2009-03-11 12:42:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java 2009-03-13 06:24:17 +0000
@@ -28,6 +28,7 @@
*/
import java.util.Collection;
+import java.util.Map;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataintegrity.DataIntegrityService;
@@ -81,9 +82,9 @@
return dataSetsNotAssignedToOrganisationUnits;
}
- private Collection<DataElement> dataElementsAssignedToDataSetsWithDifferentPeriodTypes;
+ private Map<DataElement, Collection<DataSet>> dataElementsAssignedToDataSetsWithDifferentPeriodTypes;
- public Collection<DataElement> getDataElementsAssignedToDataSetsWithDifferentPeriodTypes()
+ public Map<DataElement, Collection<DataSet>> getDataElementsAssignedToDataSetsWithDifferentPeriodTypes()
{
return dataElementsAssignedToDataSetsWithDifferentPeriodTypes;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm 2009-03-11 12:42:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm 2009-03-13 06:24:17 +0000
@@ -35,7 +35,21 @@
#violationList( "dataElementsWithoutGroups" $dataElementsWithoutGroups )
#integrityHeader( $i18n.getString( "data_elements_assigned_to_period_types_with_different_period_types" ) $dataElementsAssignedToDataSetsWithDifferentPeriodTypes.size() "dataElementsAssignedToDataSetsWithDifferentPeriodTypes" )
-#violationList( "dataElementsAssignedToDataSetsWithDifferentPeriodTypes" $dataElementsAssignedToDataSetsWithDifferentPeriodTypes )
+<div style="display:none" id="dataElementsAssignedToDataSetsWithDifferentPeriodTypes">
+ <table>
+ #foreach ( $dataElement in $dataElementsAssignedToDataSetsWithDifferentPeriodTypes.keySet() )
+ <tr>
+ <td>
+ #set( $size = $dataElementsAssignedToDataSetsWithDifferentPeriodTypes.get( $dataElement ).size() )
+ ${dataElement.name} (
+ #foreach ( $dataSet in $dataElementsAssignedToDataSetsWithDifferentPeriodTypes.get( $dataElement ) )
+ ${dataSet.name}#if( $velocityCount < $size ), #end
+ #end)
+ </td>
+ </tr>
+ #end
+ </table>
+</div>
#integrityHeader( $i18n.getString( "data_sets_not_assigned_to_organisation_units" ) $dataSetsNotAssignedToOrganisationUnits.size() "dataSetsNotAssignedToOrganisationUnits" )
#violationList( "dataSetsNotAssignedToOrganisationUnits" $dataSetsNotAssignedToOrganisationUnits )
--
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.