=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityReport.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityReport.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityReport.java 2015-03-04 16:26:10 +0000 @@ -0,0 +1,330 @@ +package org.hisp.dhis.dataintegrity; + +/* + * Copyright (c) 2004-2015, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementGroup; +import org.hisp.dhis.dataelement.DataElementOperand; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.Section; +import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorGroup; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitGroup; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.validation.ValidationRule; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; + +/** + * @author Halvdan Hoem Grelland + */ +public class DataIntegrityReport +{ + private List dataElementsWithoutDataSet; + + private List dataElementsWithoutGroups; + + private Map> dataElementsAssignedToDataSetsWithDifferentPeriodTypes; + + private SortedMap> dataElementsViolatingExclusiveGroupSets; + + private SortedMap> dataElementsInDataSetNotInForm; + + private Map> categoryOptionCombosNotInDataElementCategoryCombo; + + private List dataSetsNotAssignedToOrganisationUnits; + + private List
sectionsWithInvalidCategoryCombinations; + + private Collection> indicatorsWithIdenticalFormulas; + + private List indicatorsWithoutGroups; + + private Map invalidIndicatorNumerators; + + private Map invalidIndicatorDenominators; + + private SortedMap> indicatorsViolatingExclusiveGroupSets; + + private List duplicatePeriods; + + private List organisationUnitsWithCyclicReferences; + + private List orphanedOrganisationUnits; + + private List organisationUnitsWithoutGroups; + + private SortedMap> organisationUnitsViolatingExclusiveGroupSets; + + private List organisationUnitGroupsWithoutGroupSets; + + private List validationRulesWithoutGroups; + + private Map invalidValidationRuleLeftSideExpressions; + + private Map invalidValidationRuleRightSideExpressions; + + //------------------------------------------------------------------------- + // Constructors + //------------------------------------------------------------------------- + + public DataIntegrityReport() + { + + } + + //------------------------------------------------------------------------- + // Getters and setters + //------------------------------------------------------------------------- + + public List getDataElementsWithoutDataSet() + { + return dataElementsWithoutDataSet; + } + + public void setDataElementsWithoutDataSet( List dataElementsWithoutDataSet ) + { + this.dataElementsWithoutDataSet = dataElementsWithoutDataSet; + } + + public List getDataElementsWithoutGroups() + { + return dataElementsWithoutGroups; + } + + public void setDataElementsWithoutGroups( List dataElementsWithoutGroups ) + { + this.dataElementsWithoutGroups = dataElementsWithoutGroups; + } + + public Map> getDataElementsAssignedToDataSetsWithDifferentPeriodTypes() + { + return dataElementsAssignedToDataSetsWithDifferentPeriodTypes; + } + + public void setDataElementsAssignedToDataSetsWithDifferentPeriodTypes( Map> dataElementsAssignedToDataSetsWithDifferentPeriodTypes ) + { + this.dataElementsAssignedToDataSetsWithDifferentPeriodTypes = dataElementsAssignedToDataSetsWithDifferentPeriodTypes; + } + + public SortedMap> getDataElementsViolatingExclusiveGroupSets() + { + return dataElementsViolatingExclusiveGroupSets; + } + + public void setDataElementsViolatingExclusiveGroupSets( SortedMap> dataElementsViolatingExclusiveGroupSets ) + { + this.dataElementsViolatingExclusiveGroupSets = dataElementsViolatingExclusiveGroupSets; + } + + public SortedMap> getDataElementsInDataSetNotInForm() + { + return dataElementsInDataSetNotInForm; + } + + public void setDataElementsInDataSetNotInForm( SortedMap> dataElementsInDataSetNotInForm ) + { + this.dataElementsInDataSetNotInForm = dataElementsInDataSetNotInForm; + } + + public Map> getCategoryOptionCombosNotInDataElementCategoryCombo() + { + return categoryOptionCombosNotInDataElementCategoryCombo; + } + + public void setCategoryOptionCombosNotInDataElementCategoryCombo( Map> categoryOptionCombosNotInDataElementCategoryCombo ) + { + this.categoryOptionCombosNotInDataElementCategoryCombo = categoryOptionCombosNotInDataElementCategoryCombo; + } + + public List getDataSetsNotAssignedToOrganisationUnits() + { + return dataSetsNotAssignedToOrganisationUnits; + } + + public void setDataSetsNotAssignedToOrganisationUnits( List dataSetsNotAssignedToOrganisationUnits ) + { + this.dataSetsNotAssignedToOrganisationUnits = dataSetsNotAssignedToOrganisationUnits; + } + + public List
getSectionsWithInvalidCategoryCombinations() + { + return sectionsWithInvalidCategoryCombinations; + } + + public void setSectionsWithInvalidCategoryCombinations( List
sectionsWithInvalidCategoryCombinations ) + { + this.sectionsWithInvalidCategoryCombinations = sectionsWithInvalidCategoryCombinations; + } + + public Collection> getIndicatorsWithIdenticalFormulas() + { + return indicatorsWithIdenticalFormulas; + } + + public void setIndicatorsWithIdenticalFormulas( Collection> indicatorsWithIdenticalFormulas ) + { + this.indicatorsWithIdenticalFormulas = indicatorsWithIdenticalFormulas; + } + + public List getIndicatorsWithoutGroups() + { + return indicatorsWithoutGroups; + } + + public void setIndicatorsWithoutGroups( List indicatorsWithoutGroups ) + { + this.indicatorsWithoutGroups = indicatorsWithoutGroups; + } + + public Map getInvalidIndicatorNumerators() + { + return invalidIndicatorNumerators; + } + + public void setInvalidIndicatorNumerators( Map invalidIndicatorNumerators ) + { + this.invalidIndicatorNumerators = invalidIndicatorNumerators; + } + + public Map getInvalidIndicatorDenominators() + { + return invalidIndicatorDenominators; + } + + public void setInvalidIndicatorDenominators( Map invalidIndicatorDenominators ) + { + this.invalidIndicatorDenominators = invalidIndicatorDenominators; + } + + public SortedMap> getIndicatorsViolatingExclusiveGroupSets() + { + return indicatorsViolatingExclusiveGroupSets; + } + + public void setIndicatorsViolatingExclusiveGroupSets( SortedMap> indicatorsViolatingExclusiveGroupSets ) + { + this.indicatorsViolatingExclusiveGroupSets = indicatorsViolatingExclusiveGroupSets; + } + + public List getDuplicatePeriods() + { + return duplicatePeriods; + } + + public void setDuplicatePeriods( List duplicatePeriods ) + { + this.duplicatePeriods = duplicatePeriods; + } + + public List getOrganisationUnitsWithCyclicReferences() + { + return organisationUnitsWithCyclicReferences; + } + + public void setOrganisationUnitsWithCyclicReferences( List organisationUnitsWithCyclicReferences ) + { + this.organisationUnitsWithCyclicReferences = organisationUnitsWithCyclicReferences; + } + + public List getOrphanedOrganisationUnits() + { + return orphanedOrganisationUnits; + } + + public void setOrphanedOrganisationUnits( List orphanedOrganisationUnits ) + { + this.orphanedOrganisationUnits = orphanedOrganisationUnits; + } + + public List getOrganisationUnitsWithoutGroups() + { + return organisationUnitsWithoutGroups; + } + + public void setOrganisationUnitsWithoutGroups( List organisationUnitsWithoutGroups ) + { + this.organisationUnitsWithoutGroups = organisationUnitsWithoutGroups; + } + + public SortedMap> getOrganisationUnitsViolatingExclusiveGroupSets() + { + return organisationUnitsViolatingExclusiveGroupSets; + } + + public void setOrganisationUnitsViolatingExclusiveGroupSets( SortedMap> organisationUnitsViolatingExclusiveGroupSets ) + { + this.organisationUnitsViolatingExclusiveGroupSets = organisationUnitsViolatingExclusiveGroupSets; + } + + public List getOrganisationUnitGroupsWithoutGroupSets() + { + return organisationUnitGroupsWithoutGroupSets; + } + + public void setOrganisationUnitGroupsWithoutGroupSets( List organisationUnitGroupsWithoutGroupSets ) + { + this.organisationUnitGroupsWithoutGroupSets = organisationUnitGroupsWithoutGroupSets; + } + + public List getValidationRulesWithoutGroups() + { + return validationRulesWithoutGroups; + } + + public void setValidationRulesWithoutGroups( List validationRulesWithoutGroups ) + { + this.validationRulesWithoutGroups = validationRulesWithoutGroups; + } + + public Map getInvalidValidationRuleLeftSideExpressions() + { + return invalidValidationRuleLeftSideExpressions; + } + + public void setInvalidValidationRuleLeftSideExpressions( Map invalidValidationRuleLeftSideExpressions ) + { + this.invalidValidationRuleLeftSideExpressions = invalidValidationRuleLeftSideExpressions; + } + + public Map getInvalidValidationRuleRightSideExpressions() + { + return invalidValidationRuleRightSideExpressions; + } + + public void setInvalidValidationRuleRightSideExpressions( Map invalidValidationRuleRightSideExpressions ) + { + this.invalidValidationRuleRightSideExpressions = invalidValidationRuleRightSideExpressions; + } +} === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/TaskCategory.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/TaskCategory.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/TaskCategory.java 2015-02-13 14:13:56 +0000 @@ -43,5 +43,6 @@ METADATA_EXPORT, AGGREGATE_QUERY_BUILDER, SENDING_REMINDER_MESSAGE, - SENDING_SMS + SENDING_SMS, + DATAINTEGRITY } === 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 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2015-03-04 15:31:53 +0000 @@ -616,7 +616,7 @@ for ( OrganisationUnit duplicate : duplicates ) { - targets.put( duplicate, duplicate.getGroups() ); + targets.put( duplicate, new HashSet<>( duplicate.getGroups() ) ); } } === added directory 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/tasks' === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/tasks/DataIntegrityTask.java 2015-03-05 13:40:39 +0000 @@ -0,0 +1,152 @@ +package org.hisp.dhis.dataintegrity.tasks; + +/* + * Copyright (c) 2004-2015, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * 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.scheduling.TaskId; +import org.hisp.dhis.system.notification.NotificationLevel; +import org.hisp.dhis.system.notification.Notifier; +import org.hisp.dhis.system.timer.SystemTimer; +import org.hisp.dhis.system.timer.Timer; +import org.springframework.scheduling.annotation.Async; + +import java.util.ArrayList; +import java.util.Collections; + +/** + * @author Halvdan Hoem Grelland + */ +@Async +public class DataIntegrityTask + implements Runnable +{ + private static final Log log = LogFactory.getLog( DataIntegrityTask.class ); + + private TaskId taskId; + + private DataIntegrityReport dataIntegrityReport = new DataIntegrityReport(); + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DataIntegrityService dataIntegrityService; + + private Notifier notifier; + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + public DataIntegrityTask( TaskId taskId, DataIntegrityService dataIntegrityService, Notifier notifier ) + { + this.taskId = taskId; + this.dataIntegrityService = dataIntegrityService; + this.notifier = notifier; + } + + // ------------------------------------------------------------------------- + // Runnable implementation + // ------------------------------------------------------------------------- + + @Override + public void run() + { + 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" ); + + timer.stop(); + + if ( taskId != null ) + { + notifier.notify( taskId, NotificationLevel.INFO, "Data integrity checks completed in " + timer.toString() + ".", true ) + .addTaskSummary( taskId, dataIntegrityReport ); + } + } +} === added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataIntegrityController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataIntegrityController.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataIntegrityController.java 2015-03-05 13:40:39 +0000 @@ -0,0 +1,83 @@ +package org.hisp.dhis.webapi.controller; + +/* + * Copyright (c) 2004-2015, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.dataintegrity.DataIntegrityService; +import org.hisp.dhis.dataintegrity.tasks.DataIntegrityTask; +import org.hisp.dhis.scheduling.TaskCategory; +import org.hisp.dhis.scheduling.TaskId; +import org.hisp.dhis.system.notification.Notifier; +import org.hisp.dhis.system.scheduling.Scheduler; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.webapi.utils.ContextUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Halvdan Hoem Grelland + */ +@Controller +@RequestMapping( method = RequestMethod.GET ) +public class DataIntegrityController +{ + @Autowired + private CurrentUserService currentUserService; + + @Autowired + private Scheduler scheduler; + + @Autowired + private DataIntegrityService dataIntegrityService; + + @Autowired + private Notifier notifier; + + public static final String RESOURCE_PATH = "/dataIntegrity"; + + //-------------------------------------------------------------------------- + // Asynchronous data integrity task + //-------------------------------------------------------------------------- + + @RequestMapping( value = DataIntegrityController.RESOURCE_PATH, method = RequestMethod.POST ) + public void runAsyncDataIntegrity( HttpServletResponse response, HttpServletRequest request ) + { + TaskId taskId = new TaskId( TaskCategory.DATAINTEGRITY, currentUserService.getCurrentUser() ); + notifier.clear( taskId ); + + scheduler.executeTask( new DataIntegrityTask( taskId, dataIntegrityService, notifier ) ); + + response.setHeader( "Location", ContextUtils.getRootPath( request ) + "/system/tasks/" + TaskCategory.DATAINTEGRITY ); + response.setStatus( HttpServletResponse.SC_ACCEPTED ); + } +} === 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 2015-02-17 06:00:52 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java 2015-03-05 13:40:39 +0000 @@ -131,9 +131,12 @@ TaskId taskId = new TaskId( taskCategory, currentUserService.getCurrentUser() ); - importSummary = (ImportSummary) notifier.getTaskSummary( taskId ); - - notifier.clear( taskId ); + // TODO Support DataIntegrityReport (make task summary generic). + if ( !taskCategory.equals( TaskCategory.DATAINTEGRITY ) ) + { + importSummary = (ImportSummary) notifier.getTaskSummary( taskId ); + notifier.clear( taskId ); + } } JacksonUtils.toJson( response.getOutputStream(), importSummary ); === removed 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 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java 1970-01-01 00:00:00 +0000 @@ -1,303 +0,0 @@ -package org.hisp.dhis.dataadmin.action.dataintegrity; - -/* - * Copyright (c) 2004-2015, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementGroup; -import org.hisp.dhis.dataelement.DataElementOperand; -import org.hisp.dhis.dataintegrity.DataIntegrityService; -import org.hisp.dhis.dataset.DataSet; -import org.hisp.dhis.dataset.Section; -import org.hisp.dhis.indicator.Indicator; -import org.hisp.dhis.indicator.IndicatorGroup; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitGroup; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.validation.ValidationRule; - -import com.opensymphony.xwork2.Action; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class GetDataIntegrityAction - implements Action -{ - private static final Log log = LogFactory.getLog( GetDataIntegrityAction.class ); - - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private DataIntegrityService dataIntegrityService; - - public void setDataIntegrityService( DataIntegrityService dataIntegrityService ) - { - this.dataIntegrityService = dataIntegrityService; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private List dataElementsWithoutDataSet; - - public List getDataElementsWithoutDataSet() - { - return dataElementsWithoutDataSet; - } - - private List dataElementsWithoutGroups; - - public Collection getDataElementsWithoutGroups() - { - return dataElementsWithoutGroups; - } - - private Map> dataElementsAssignedToDataSetsWithDifferentPeriodTypes; - - public Map> getDataElementsAssignedToDataSetsWithDifferentPeriodTypes() - { - return dataElementsAssignedToDataSetsWithDifferentPeriodTypes; - } - - private SortedMap> dataElementsViolatingExclusiveGroupSets; - - public SortedMap> getDataElementsViolatingExclusiveGroupSets() - { - return dataElementsViolatingExclusiveGroupSets; - } - - private SortedMap> dataElementsInDataSetNotInForm; - - public SortedMap> getDataElementsInDataSetNotInForm() - { - return dataElementsInDataSetNotInForm; - } - - private Map> categoryOptionCombosNotInDataElementCategoryCombo; - - public Map> getCategoryOptionCombosNotInDataElementCategoryCombo() - { - return categoryOptionCombosNotInDataElementCategoryCombo; - } - - private List dataSetsNotAssignedToOrganisationUnits; - - public List getDataSetsNotAssignedToOrganisationUnits() - { - return dataSetsNotAssignedToOrganisationUnits; - } - - private List
sectionsWithInvalidCategoryCombinations; - - public List
getSectionsWithInvalidCategoryCombinations() - { - return sectionsWithInvalidCategoryCombinations; - } - - private Collection> indicatorsWithIdenticalFormulas; - - public Collection> getIndicatorsWithIdenticalFormulas() - { - return indicatorsWithIdenticalFormulas; - } - - private List indicatorsWithoutGroups; - - public List getIndicatorsWithoutGroups() - { - return indicatorsWithoutGroups; - } - - private Map invalidIndicatorNumerators; - - public Map getInvalidIndicatorNumerators() - { - return invalidIndicatorNumerators; - } - - private Map invalidIndicatorDenominators; - - public Map getInvalidIndicatorDenominators() - { - return invalidIndicatorDenominators; - } - - private SortedMap> indicatorsViolatingExclusiveGroupSets; - - public SortedMap> getIndicatorsViolatingExclusiveGroupSets() - { - return indicatorsViolatingExclusiveGroupSets; - } - - private List duplicatePeriods; - - public List getDuplicatePeriods() - { - return duplicatePeriods; - } - - private List organisationUnitsWithCyclicReferences; - - public List getOrganisationUnitsWithCyclicReferences() - { - return organisationUnitsWithCyclicReferences; - } - - private List orphanedOrganisationUnits; - - public List getOrphanedOrganisationUnits() - { - return orphanedOrganisationUnits; - } - - private List organisationUnitsWithoutGroups; - - public List getOrganisationUnitsWithoutGroups() - { - return organisationUnitsWithoutGroups; - } - - private SortedMap> organisationUnitsViolatingExclusiveGroupSets; - - public SortedMap> getOrganisationUnitsViolatingExclusiveGroupSets() - { - return organisationUnitsViolatingExclusiveGroupSets; - } - - private List organisationUnitGroupsWithoutGroupSets; - - public List getOrganisationUnitGroupsWithoutGroupSets() - { - return organisationUnitGroupsWithoutGroupSets; - } - - private List validationRulesWithoutGroups; - - public List getValidationRulesWithoutGroups() - { - return validationRulesWithoutGroups; - } - - private Map invalidValidationRuleLeftSideExpressions; - - public Map getInvalidValidationRuleLeftSideExpressions() - { - return invalidValidationRuleLeftSideExpressions; - } - - private Map invalidValidationRuleRightSideExpressions; - - public Map getInvalidValidationRuleRightSideExpressions() - { - return invalidValidationRuleRightSideExpressions; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - { - dataElementsWithoutDataSet = new ArrayList<>( dataIntegrityService.getDataElementsWithoutDataSet() ); - dataElementsWithoutGroups = new ArrayList<>( dataIntegrityService.getDataElementsWithoutGroups() ); - dataElementsAssignedToDataSetsWithDifferentPeriodTypes = dataIntegrityService.getDataElementsAssignedToDataSetsWithDifferentPeriodTypes(); - dataElementsViolatingExclusiveGroupSets = dataIntegrityService.getDataElementsViolatingExclusiveGroupSets(); - dataElementsInDataSetNotInForm = dataIntegrityService.getDataElementsInDataSetNotInForm(); - - log.info( "Checked data elements" ); - - categoryOptionCombosNotInDataElementCategoryCombo = dataIntegrityService.getCategoryOptionCombosNotInDataElementCategoryCombo(); - - log.info( "Checked operands" ); - - dataSetsNotAssignedToOrganisationUnits = new ArrayList<>( dataIntegrityService.getDataSetsNotAssignedToOrganisationUnits() ); - sectionsWithInvalidCategoryCombinations = new ArrayList<>( dataIntegrityService.getSectionsWithInvalidCategoryCombinations() ); - - log.info( "Checked data sets" ); - - indicatorsWithIdenticalFormulas = dataIntegrityService.getIndicatorsWithIdenticalFormulas(); - indicatorsWithoutGroups = new ArrayList<>( dataIntegrityService.getIndicatorsWithoutGroups() ); - invalidIndicatorNumerators = dataIntegrityService.getInvalidIndicatorNumerators(); - invalidIndicatorDenominators = dataIntegrityService.getInvalidIndicatorDenominators(); - indicatorsViolatingExclusiveGroupSets = dataIntegrityService.getIndicatorsViolatingExclusiveGroupSets(); - - log.info( "Checked indicators" ); - - duplicatePeriods = dataIntegrityService.getDuplicatePeriods(); - - log.info( "Checked periods" ); - - organisationUnitsWithCyclicReferences = new ArrayList<>( dataIntegrityService - .getOrganisationUnitsWithCyclicReferences() ); - orphanedOrganisationUnits = new ArrayList<>( dataIntegrityService - .getOrphanedOrganisationUnits() ); - organisationUnitsWithoutGroups = new ArrayList<>( dataIntegrityService - .getOrganisationUnitsWithoutGroups() ); - organisationUnitsViolatingExclusiveGroupSets = dataIntegrityService.getOrganisationUnitsViolatingExclusiveGroupSets(); - organisationUnitGroupsWithoutGroupSets = new ArrayList<>( dataIntegrityService - .getOrganisationUnitGroupsWithoutGroupSets() ); - validationRulesWithoutGroups = new ArrayList<>( dataIntegrityService - .getValidationRulesWithoutGroups() ); - - log.info( "Checked organisation units" ); - - invalidValidationRuleLeftSideExpressions = dataIntegrityService.getInvalidValidationRuleLeftSideExpressions(); - invalidValidationRuleRightSideExpressions = dataIntegrityService.getInvalidValidationRuleRightSideExpressions(); - - log.info( "Checked validation rules" ); - - Collections.sort( dataElementsWithoutDataSet, IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( dataElementsWithoutGroups, IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( dataSetsNotAssignedToOrganisationUnits, IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( sectionsWithInvalidCategoryCombinations, IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( indicatorsWithoutGroups, IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( organisationUnitsWithCyclicReferences, IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( orphanedOrganisationUnits, IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( organisationUnitsWithoutGroups, IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( organisationUnitGroupsWithoutGroupSets, IdentifiableObjectNameComparator.INSTANCE ); - Collections.sort( validationRulesWithoutGroups, IdentifiableObjectNameComparator.INSTANCE ); - - return SUCCESS; - } -} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityReportAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityReportAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityReportAction.java 2015-03-04 16:26:10 +0000 @@ -0,0 +1,82 @@ +package org.hisp.dhis.dataadmin.action.dataintegrity; + +/* + * Copyright (c) 2004-2015, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.opensymphony.xwork2.Action; +import org.hisp.dhis.dataintegrity.DataIntegrityReport; +import org.hisp.dhis.scheduling.TaskCategory; +import org.hisp.dhis.scheduling.TaskId; +import org.hisp.dhis.system.notification.Notifier; +import org.hisp.dhis.user.CurrentUserService; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @author Halvdan Hoem Grelland + */ +public class GetDataIntegrityReportAction + implements Action +{ + @Autowired + private Notifier notifier; + + @Autowired + private CurrentUserService currentUserService; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private TaskCategory category; + + public void setCategory( TaskCategory category ) + { + this.category = category; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private DataIntegrityReport dataIntegrityReport; + + public DataIntegrityReport getDataIntegrityReport() + { + return dataIntegrityReport; + } + + @Override + public String execute() + { + TaskId taskId = new TaskId( category, currentUserService.getCurrentUser() ); + + dataIntegrityReport = (DataIntegrityReport) notifier.getTaskSummary( taskId ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2015-03-03 16:18:51 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2015-03-05 12:10:30 +0000 @@ -30,14 +30,6 @@ scope="prototype"> - - - - - - /main.vm - /dhis-web-maintenance-dataadmin/dataIntegrityForm.vm /dhis-web-maintenance-dataadmin/menu.vm + /dhis-web-maintenance-dataadmin/dataIntegrity.vm javascript/dataIntegrity.js F_PERFORM_MAINTENANCE - + /dhis-web-maintenance-dataadmin/responseDataIntegrity.vm + DATAINTEGRITY + plainTextError F_PERFORM_MAINTENANCE === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrity.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrity.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrity.vm 2015-03-04 16:54:01 +0000 @@ -0,0 +1,36 @@ +#macro( integrityItem $header $id ) +

${header} 

+ +
+ +#end +

+ $i18n.getString( "data_integrity" ) #openHelp( "dataIntegrity" ) +

+#parse( "dhis-web-commons/loader/loader.vm" ) + + +
=== removed 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 2015-01-07 13:01:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm 1970-01-01 00:00:00 +0000 @@ -1,38 +0,0 @@ - -#macro( integrityItem $header $id ) -

${header} 

- -
- -#end - -

$i18n.getString( "data_integrity_checks_performed" ) #openHelp( "dataIntegrity" )

- -#parse( "dhis-web-commons/loader/loader.vm" ) - - === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/dataIntegrity.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/dataIntegrity.js 2015-01-07 13:01:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/dataIntegrity.js 2015-03-05 13:08:37 +0000 @@ -1,15 +1,33 @@ +$( document ).ready( function() { + showLoader(); -$( document ).ready( function() -{ - showLoader(); - - $.getJSON( "getDataIntegrity.action", {}, populateIntegrityItems ); + $.ajax({ + url: '../api/dataIntegrity', + method: 'POST', + success: pollDataIntegrityCheckFinished, + error: function( xhr, txtStatus, err ) { + showErrorMessage( "Data integrity checks cannot be run. Request failed.", 3 ); + throw Error( xhr.responseText ); + } + } ); } ); -function populateIntegrityItems( json ) -{ - hideLoader(); - +var checkFinishedTimeout = null; + +function pollDataIntegrityCheckFinished() { + pingNotifications( 'DATAINTEGRITY', 'notificationsTable', function() { + $.getJSON( "getDataIntegrityReport.action", {}, function( json ) { + hideLoader(); + $( "#di-title" ).hide(); + $( "#di-completed" ).show(); + populateIntegrityItems( json ); + clearTimeout( checkFinishedTimeout ); + } ); + } ); + checkFinishedTimeout = setTimeout( "pollDataIntegrityCheckFinished()", 1500 ); +} + +function populateIntegrityItems( json ) { displayViolationList( json.dataElementsWithoutDataSet, "dataElementsWithoutDataSet", false ); displayViolationList( json.dataElementsWithoutGroups, "dataElementsWithoutGroups", false ); displayViolationList( json.dataElementsViolatingExclusiveGroupSets, "dataElementsViolatingExclusiveGroupSets", true ); @@ -34,35 +52,32 @@ displayViolationList( json.invalidValidationRuleRightSideExpressions, "invalidValidationRuleRightSideExpressions", true ); } -function displayViolationList( list, id, lineBreak ) -{ - if ( list.length > 0 ) - { - // Display image "drop-down" button - - $( "#" + id + "Button" ) - .attr({ src: "../images/down.png", title: "View violations" }) - .css({ cursor: "pointer" }) - .click( function() { $( "#" + id + "Div" ).slideToggle( "fast" ); } ); +function displayViolationList( list, id, lineBreak ) { + var $button = $( "#" + id + "Button" ); + var $container = $( "#" + id + "Div" ); + + if ( list.length > 0 ) { + // Display image "drop-down" button + $button + .attr( { src: "../images/down.png", title: "View violations" } ) + .css( { cursor: "pointer" } ) + .click( function() { $container.slideToggle( "fast" ); } ); // Populate violation div - var violations = ""; - for ( var i = 0; i < list.length; i++ ) - { + for ( var i = 0; i < list.length; i++ ) { violations += list[i] + "
"; violations += !!lineBreak ? "
" : ""; } - $( "#" + id + "Div" ).html( violations ); + $container.html( violations ); } else { - // Display image "check" button - - $( "#" + id + "Button" ).attr({ src: "../images/check.png", title: "No violations" }); + // Display image "check" button + $button.attr({ src: "../images/check.png", title: "No violations" }); } - $( "#" + id + "Div" ).hide(); + $container.hide(); } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseDataIntegrity.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseDataIntegrity.vm 2015-01-07 13:01:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseDataIntegrity.vm 2015-03-04 17:01:31 +0000 @@ -4,7 +4,7 @@ #foreach( $o in $list ) "$!encoder.jsonEncode( ${o.displayName} )"#if( $velocityCount < $size ),#end #end -] +] #end #macro( violationWithCollection $name $list ) @@ -22,9 +22,9 @@ #set( $size = $map.keySet().size() ) "$!encoder.jsonEncode( ${name} )": [ #foreach( $o in $map.keySet() ) -"$!encoder.jsonEncode( ${o.displayName} ): $map.get( $o )"#if( $velocityCount < $size ),#end +"$!encoder.jsonEncode( ${o.displayName} ): $map.get( $o )"#if( $velocityCount < $size ),#end #end -] +] #end #macro( violationWithMapList $name $map ) @@ -32,32 +32,32 @@ "$!encoder.jsonEncode( ${name} )": [ #foreach( $o in $map.keySet() ) #set( $listSize = $map.get( $o ).size() ) -"$!encoder.jsonEncode( ${o.displayName} ):#foreach( $p in $map.get( $o ) ) $!encoder.jsonEncode( ${p.displayName} )#if( $velocityCount < $listSize ), #end +"$!encoder.jsonEncode( ${o.displayName} ):#foreach( $p in $map.get( $o ) ) $!encoder.jsonEncode( ${p.displayName} )#if( $velocityCount < $listSize ), #end #end "#if( $velocityCount < $mapSize ),#end #end -] +] #end { - #violation( "dataElementsWithoutDataSet" $dataElementsWithoutDataSet ), - #violation( "dataElementsWithoutGroups" $dataElementsWithoutGroups ), - #violationWithMapList( "dataElementsViolatingExclusiveGroupSets" $dataElementsViolatingExclusiveGroupSets ), - #violationWithMapList( "dataElementsInDataSetNotInForm" $dataElementsInDataSetNotInForm ), - #violationWithMapList( "dataElementsAssignedToDataSetsWithDifferentPeriodTypes" $dataElementsAssignedToDataSetsWithDifferentPeriodTypes ), - #violationWithMapList( "categoryOptionCombosNotInDataElementCategoryCombo" $categoryOptionCombosNotInDataElementCategoryCombo ), - #violation( "dataSetsNotAssignedToOrganisationUnits" $dataSetsNotAssignedToOrganisationUnits ), - #violation( "sectionsWithInvalidCategoryCombinations" $sectionsWithInvalidCategoryCombinations ), - #violationWithCollection( "indicatorsWithIdenticalFormulas" $indicatorsWithIdenticalFormulas ), - #violation( "indicatorsWithoutGroups" $indicatorsWithoutGroups ), - #violationWithMap( "invalidIndicatorNumerators" $invalidIndicatorNumerators ), - #violationWithMap( "invalidIndicatorDenominators" $invalidIndicatorDenominators ), - #violationWithMapList( "indicatorsViolatingExclusiveGroupSets" $indicatorsViolatingExclusiveGroupSets ), - #violation( "duplicatePeriods" $duplicatePeriods ), - #violation( "organisationUnitsWithCyclicReferences" $organisationUnitsWithCyclicReferences ), - #violation( "orphanedOrganisationUnits" $orphanedOrganisationUnits ), - #violation( "organisationUnitsWithoutGroups" $organisationUnitsWithoutGroups ), - #violationWithMapList( "organisationUnitsViolatingExclusiveGroupSets" $organisationUnitsViolatingExclusiveGroupSets ), - #violation( "organisationUnitGroupsWithoutGroupSets" $organisationUnitGroupsWithoutGroupSets ), - #violation( "validationRulesWithoutGroups" $validationRulesWithoutGroups ), - #violationWithMap( "invalidValidationRuleLeftSideExpressions" $invalidValidationRuleLeftSideExpressions ), - #violationWithMap( "invalidValidationRuleRightSideExpressions" $invalidValidationRuleRightSideExpressions ) -} \ No newline at end of file +#violation( "dataElementsWithoutDataSet" $dataIntegrityReport.dataElementsWithoutDataSet ), +#violation( "dataElementsWithoutGroups" $dataIntegrityReport.dataElementsWithoutGroups ), +#violationWithMapList( "dataElementsViolatingExclusiveGroupSets" $dataIntegrityReport.dataElementsViolatingExclusiveGroupSets ), +#violationWithMapList( "dataElementsInDataSetNotInForm" $dataIntegrityReport.dataElementsInDataSetNotInForm ), +#violationWithMapList( "dataElementsAssignedToDataSetsWithDifferentPeriodTypes" $dataIntegrityReport.dataElementsAssignedToDataSetsWithDifferentPeriodTypes ), +#violationWithMapList( "categoryOptionCombosNotInDataElementCategoryCombo" $dataIntegrityReport.categoryOptionCombosNotInDataElementCategoryCombo ), +#violation( "dataSetsNotAssignedToOrganisationUnits" $dataIntegrityReport.dataSetsNotAssignedToOrganisationUnits ), +#violation( "sectionsWithInvalidCategoryCombinations" $dataIntegrityReport.sectionsWithInvalidCategoryCombinations ), +#violationWithCollection( "indicatorsWithIdenticalFormulas" $dataIntegrityReport.indicatorsWithIdenticalFormulas ), +#violation( "indicatorsWithoutGroups" $dataIntegrityReport.indicatorsWithoutGroups ), +#violationWithMap( "invalidIndicatorNumerators" $dataIntegrityReport.invalidIndicatorNumerators ), +#violationWithMap( "invalidIndicatorDenominators" $dataIntegrityReport.invalidIndicatorDenominators ), +#violationWithMapList( "indicatorsViolatingExclusiveGroupSets" $dataIntegrityReport.indicatorsViolatingExclusiveGroupSets ), +#violation( "duplicatePeriods" $dataIntegrityReport.duplicatePeriods ), +#violation( "organisationUnitsWithCyclicReferences" $dataIntegrityReport.organisationUnitsWithCyclicReferences ), +#violation( "orphanedOrganisationUnits" $dataIntegrityReport.orphanedOrganisationUnits ), +#violation( "organisationUnitsWithoutGroups" $dataIntegrityReport.organisationUnitsWithoutGroups ), +#violationWithMapList( "organisationUnitsViolatingExclusiveGroupSets" $dataIntegrityReport.organisationUnitsViolatingExclusiveGroupSets ), +#violation( "organisationUnitGroupsWithoutGroupSets" $dataIntegrityReport.organisationUnitGroupsWithoutGroupSets ), +#violation( "validationRulesWithoutGroups" $dataIntegrityReport.validationRulesWithoutGroups ), +#violationWithMap( "invalidValidationRuleLeftSideExpressions" $dataIntegrityReport.invalidValidationRuleLeftSideExpressions ), +#violationWithMap( "invalidValidationRuleRightSideExpressions" $dataIntegrityReport.invalidValidationRuleRightSideExpressions ) +}