=== 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 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java 2016-03-02 16:55:48 +0000 @@ -205,4 +205,18 @@ * Gets all ValidationRules with invalid right side expressions. */ SortedMap getInvalidValidationRuleRightSideExpressions(); + + // ------------------------------------------------------------------------- + // DataIntegrityReport + // ------------------------------------------------------------------------- + + /** + * Returns a DataIntegrityReport. + */ + DataIntegrityReport getDataIntegrityReport(); + + /** + * Returns a FlattenedDataIntegrityReport. + */ + FlattenedDataIntegrityReport getFlattenedDataIntegrityReport(); } === 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 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2016-03-02 16:55:48 +0000 @@ -68,6 +68,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.Hashtable; import java.util.List; @@ -648,4 +649,69 @@ return invalids; } + + @Override + public DataIntegrityReport getDataIntegrityReport() + { + DataIntegrityReport report = new DataIntegrityReport(); + + report.setDataElementsWithoutDataSet( new ArrayList<>( getDataElementsWithoutDataSet() ) ); + report.setDataElementsWithoutGroups( new ArrayList<>( getDataElementsWithoutGroups() ) ); + report.setDataElementsAssignedToDataSetsWithDifferentPeriodTypes( getDataElementsAssignedToDataSetsWithDifferentPeriodTypes() ); + report.setDataElementsViolatingExclusiveGroupSets( getDataElementsViolatingExclusiveGroupSets() ); + report.setDataElementsInDataSetNotInForm( getDataElementsInDataSetNotInForm() ); + + log.info( "Checked data elements" ); + + report.setCategoryOptionCombosNotInDataElementCategoryCombo( getCategoryOptionCombosNotInDataElementCategoryCombo() ); + report.setDataSetsNotAssignedToOrganisationUnits( new ArrayList<>( getDataSetsNotAssignedToOrganisationUnits() ) ); + report.setSectionsWithInvalidCategoryCombinations( new ArrayList<>( getSectionsWithInvalidCategoryCombinations() ) ); + + log.info( "Checked data sets" ); + + report.setIndicatorsWithIdenticalFormulas( getIndicatorsWithIdenticalFormulas() ); + report.setIndicatorsWithoutGroups( new ArrayList<>( getIndicatorsWithoutGroups() ) ); + report.setInvalidIndicatorNumerators( getInvalidIndicatorNumerators() ); + report.setInvalidIndicatorDenominators( getInvalidIndicatorDenominators() ); + report.setIndicatorsViolatingExclusiveGroupSets( getIndicatorsViolatingExclusiveGroupSets() ); + + log.info( "Checked indicators" ); + + report.setDuplicatePeriods( getDuplicatePeriods() ); + + log.info( "Checked periods" ); + + report.setOrganisationUnitsWithCyclicReferences( new ArrayList<>( getOrganisationUnitsWithCyclicReferences() ) ); + report.setOrphanedOrganisationUnits( new ArrayList<>( getOrphanedOrganisationUnits() ) ); + report.setOrganisationUnitsWithoutGroups( new ArrayList<>( getOrganisationUnitsWithoutGroups() ) ); + report.setOrganisationUnitsViolatingExclusiveGroupSets( getOrganisationUnitsViolatingExclusiveGroupSets() ); + report.setOrganisationUnitGroupsWithoutGroupSets( new ArrayList<>( getOrganisationUnitGroupsWithoutGroupSets() ) ); + report.setValidationRulesWithoutGroups( new ArrayList<>( getValidationRulesWithoutGroups() ) ); + + log.info( "Checked organisation units" ); + + report.setInvalidValidationRuleLeftSideExpressions( getInvalidValidationRuleLeftSideExpressions() ); + report.setInvalidValidationRuleRightSideExpressions( getInvalidValidationRuleRightSideExpressions() ); + + log.info( "Checked validation rules" ); + + Collections.sort( report.getDataElementsWithoutDataSet(), IdentifiableObjectNameComparator.INSTANCE ); + Collections.sort( report.getDataElementsWithoutGroups(), IdentifiableObjectNameComparator.INSTANCE ); + Collections.sort( report.getDataSetsNotAssignedToOrganisationUnits(), IdentifiableObjectNameComparator.INSTANCE ); + Collections.sort( report.getSectionsWithInvalidCategoryCombinations(), IdentifiableObjectNameComparator.INSTANCE ); + Collections.sort( report.getIndicatorsWithoutGroups(), IdentifiableObjectNameComparator.INSTANCE ); + Collections.sort( report.getOrganisationUnitsWithCyclicReferences(), IdentifiableObjectNameComparator.INSTANCE ); + Collections.sort( report.getOrphanedOrganisationUnits(), IdentifiableObjectNameComparator.INSTANCE ); + Collections.sort( report.getOrganisationUnitsWithoutGroups(), IdentifiableObjectNameComparator.INSTANCE ); + Collections.sort( report.getOrganisationUnitGroupsWithoutGroupSets(), IdentifiableObjectNameComparator.INSTANCE ); + Collections.sort( report.getValidationRulesWithoutGroups(), IdentifiableObjectNameComparator.INSTANCE ); + + return report; + } + + @Override + public FlattenedDataIntegrityReport getFlattenedDataIntegrityReport() + { + return new FlattenedDataIntegrityReport( getDataIntegrityReport() ); + } } === modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/tasks/DataIntegrityTask.java' --- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/tasks/DataIntegrityTask.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/tasks/DataIntegrityTask.java 2016-03-02 16:55:48 +0000 @@ -28,11 +28,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; -import org.hisp.dhis.dataintegrity.DataIntegrityReport; import org.hisp.dhis.dataintegrity.DataIntegrityService; +import org.hisp.dhis.dataintegrity.FlattenedDataIntegrityReport; import org.hisp.dhis.scheduling.TaskId; import org.hisp.dhis.system.notification.NotificationLevel; import org.hisp.dhis.system.notification.Notifier; @@ -40,9 +37,6 @@ import org.hisp.dhis.commons.timer.Timer; import org.springframework.scheduling.annotation.Async; -import java.util.ArrayList; -import java.util.Collections; - /** * @author Halvdan Hoem Grelland */ @@ -50,12 +44,8 @@ public class DataIntegrityTask implements Runnable { - private static final Log log = LogFactory.getLog( DataIntegrityTask.class ); - private TaskId taskId; - private DataIntegrityReport dataIntegrityReport = new DataIntegrityReport(); - // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -84,69 +74,14 @@ { Timer timer = new SystemTimer().start(); - dataIntegrityReport.setDataElementsWithoutDataSet( new ArrayList<>( dataIntegrityService.getDataElementsWithoutDataSet() ) ); - - dataIntegrityReport.setDataElementsWithoutGroups( new ArrayList<>( dataIntegrityService.getDataElementsWithoutGroups() ) ); - dataIntegrityReport.setDataElementsAssignedToDataSetsWithDifferentPeriodTypes( dataIntegrityService.getDataElementsAssignedToDataSetsWithDifferentPeriodTypes() ); - dataIntegrityReport.setDataElementsViolatingExclusiveGroupSets( dataIntegrityService.getDataElementsViolatingExclusiveGroupSets() ); - dataIntegrityReport.setDataElementsInDataSetNotInForm( dataIntegrityService.getDataElementsInDataSetNotInForm() ); - - log.info( "Checked data elements" ); - - dataIntegrityReport.setCategoryOptionCombosNotInDataElementCategoryCombo( dataIntegrityService.getCategoryOptionCombosNotInDataElementCategoryCombo() ); - - log.info( "Checked operands" ); - - dataIntegrityReport.setDataSetsNotAssignedToOrganisationUnits( new ArrayList<>( dataIntegrityService.getDataSetsNotAssignedToOrganisationUnits() ) ); - dataIntegrityReport.setSectionsWithInvalidCategoryCombinations( new ArrayList<>( dataIntegrityService.getSectionsWithInvalidCategoryCombinations() ) ); - - log.info( "Checked data sets" ); - - dataIntegrityReport.setIndicatorsWithIdenticalFormulas( dataIntegrityService.getIndicatorsWithIdenticalFormulas() ); - dataIntegrityReport.setIndicatorsWithoutGroups( new ArrayList<>( dataIntegrityService.getIndicatorsWithoutGroups() ) ); - dataIntegrityReport.setInvalidIndicatorNumerators( dataIntegrityService.getInvalidIndicatorNumerators() ); - dataIntegrityReport.setInvalidIndicatorDenominators( dataIntegrityService.getInvalidIndicatorDenominators() ); - dataIntegrityReport.setIndicatorsViolatingExclusiveGroupSets( dataIntegrityService.getIndicatorsViolatingExclusiveGroupSets() ); - - log.info( "Checked indicators" ); - - dataIntegrityReport.setDuplicatePeriods( dataIntegrityService.getDuplicatePeriods() ); - - log.info( "Checked periods" ); - - dataIntegrityReport.setOrganisationUnitsWithCyclicReferences( new ArrayList<>( dataIntegrityService.getOrganisationUnitsWithCyclicReferences() ) ); - dataIntegrityReport.setOrphanedOrganisationUnits( new ArrayList<>( dataIntegrityService.getOrphanedOrganisationUnits() ) ); - dataIntegrityReport.setOrganisationUnitsWithoutGroups( new ArrayList<>( dataIntegrityService.getOrganisationUnitsWithoutGroups() ) ); - dataIntegrityReport.setOrganisationUnitsViolatingExclusiveGroupSets( dataIntegrityService.getOrganisationUnitsViolatingExclusiveGroupSets() ); - dataIntegrityReport.setOrganisationUnitGroupsWithoutGroupSets( new ArrayList<>( dataIntegrityService.getOrganisationUnitGroupsWithoutGroupSets() ) ); - dataIntegrityReport.setValidationRulesWithoutGroups( new ArrayList<>( dataIntegrityService.getValidationRulesWithoutGroups() ) ); - - log.info( "Checked organisation units" ); - - dataIntegrityReport.setInvalidValidationRuleLeftSideExpressions( dataIntegrityService.getInvalidValidationRuleLeftSideExpressions() ); - dataIntegrityReport.setInvalidValidationRuleRightSideExpressions( dataIntegrityService.getInvalidValidationRuleRightSideExpressions() ); - - log.info( "Checked validation rules" ); - - Collections.sort( dataIntegrityReport.getDataElementsWithoutDataSet(), IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( dataIntegrityReport.getDataElementsWithoutGroups(), IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( dataIntegrityReport.getDataSetsNotAssignedToOrganisationUnits(), IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( dataIntegrityReport.getSectionsWithInvalidCategoryCombinations(), IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( dataIntegrityReport.getIndicatorsWithoutGroups(), IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( dataIntegrityReport.getOrganisationUnitsWithCyclicReferences(), IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( dataIntegrityReport.getOrphanedOrganisationUnits(), IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( dataIntegrityReport.getOrganisationUnitsWithoutGroups(), IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( dataIntegrityReport.getOrganisationUnitGroupsWithoutGroupSets(), IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( dataIntegrityReport.getValidationRulesWithoutGroups(), IdentifiableObjectNameComparator.INSTANCE ); - - log.info( "Sorted results" ); - + FlattenedDataIntegrityReport report = dataIntegrityService.getFlattenedDataIntegrityReport(); + timer.stop(); if ( taskId != null ) { notifier.notify( taskId, NotificationLevel.INFO, "Data integrity checks completed in " + timer.toString() + ".", true ) - .addTaskSummary( taskId, dataIntegrityReport ); + .addTaskSummary( taskId, report ); } } } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java 2016-02-01 07:36:06 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java 2016-03-02 16:55:48 +0000 @@ -29,8 +29,6 @@ */ import org.hisp.dhis.common.CodeGenerator; -import org.hisp.dhis.dataintegrity.DataIntegrityReport; -import org.hisp.dhis.dataintegrity.FlattenedDataIntegrityReport; import org.hisp.dhis.dxf2.metadata.ImportSummary; import org.hisp.dhis.render.RenderService; import org.hisp.dhis.node.exception.InvalidTypeException; @@ -159,11 +157,9 @@ TaskId taskId = new TaskId( taskCategory, currentUserService.getCurrentUser() ); - // TODO Make task summary generic. (We use tasks for more than importing data). - if ( taskCategory.equals( TaskCategory.DATAINTEGRITY ) ) + if ( taskCategory.equals( TaskCategory.DATAINTEGRITY ) ) //TODO { - DataIntegrityReport dataIntegrityReport = (DataIntegrityReport) notifier.getTaskSummary( taskId ); - renderService.toJson( response.getOutputStream(), new FlattenedDataIntegrityReport( dataIntegrityReport ) ); + renderService.toJson( response.getOutputStream(), notifier.getTaskSummary( taskId ) ); return; } else