=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2014-01-19 05:14:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2014-01-23 11:54:46 +0000 @@ -205,6 +205,12 @@ * can be completed. */ private boolean validCompleteOnly; + + /** + * Property indicating whether a comment is required for all fields in a form + * which are not entered, including false for boolean values. + */ + private boolean noValueRequiresComment; /** * Property indicating whether offline storage is enabled for this dataSet @@ -768,6 +774,19 @@ @JsonProperty @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public boolean isNoValueRequiresComment() + { + return noValueRequiresComment; + } + + public void setNoValueRequiresComment( boolean noValueRequiresComment ) + { + this.noValueRequiresComment = noValueRequiresComment; + } + + @JsonProperty + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public boolean isSkipOffline() { return skipOffline; === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2014-01-21 07:07:30 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2014-01-23 11:54:46 +0000 @@ -519,6 +519,7 @@ executeSql( "UPDATE dataset SET skipoffline = false WHERE skipoffline IS NULL" ); executeSql( "UPDATE dataset SET renderastabs = false WHERE renderastabs IS NULL" ); executeSql( "UPDATE dataset SET renderhorizontally = false WHERE renderhorizontally IS NULL" ); + executeSql( "UPDATE dataset SET novaluerequirescomment = false WHERE novaluerequirescomment IS NULL" ); executeSql( "UPDATE categorycombo SET skiptotal = false WHERE skiptotal IS NULL" ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml 2014-01-19 05:14:19 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml 2014-01-23 11:54:46 +0000 @@ -94,6 +94,8 @@ + + === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java 2013-12-21 19:02:27 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java 2014-01-23 11:54:46 +0000 @@ -29,7 +29,6 @@ */ import java.util.Collection; -import java.util.List; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; @@ -190,13 +189,6 @@ return dataValue; } - private List standardComments; - - public List getStandardComments() - { - return standardComments; - } - private Collection dataValueAudits; public Collection getDataValueAudits() === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java 2014-01-23 09:31:23 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java 2014-01-23 11:54:46 +0000 @@ -28,13 +28,26 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import com.opensymphony.xwork2.Action; +import static org.hisp.dhis.system.util.ListUtils.getCollection; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.dataanalysis.DataAnalysisService; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.datavalue.DataValue; +import org.hisp.dhis.datavalue.DataValueService; import org.hisp.dhis.datavalue.DeflatedDataValue; import org.hisp.dhis.expression.ExpressionService; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -46,14 +59,7 @@ import org.hisp.dhis.validation.ValidationRule; import org.hisp.dhis.validation.ValidationRuleService; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import static org.hisp.dhis.system.util.ListUtils.getCollection; +import com.opensymphony.xwork2.Action; /** * @author Margrethe Store @@ -109,6 +115,13 @@ { this.organisationUnitService = organisationUnitService; } + + private DataValueService dataValueService; + + public void setDataValueService( DataValueService dataValueService ) + { + this.dataValueService = dataValueService; + } // ------------------------------------------------------------------------- // Input @@ -137,6 +150,11 @@ private boolean multiOu; + public boolean isMultiOu() + { + return multiOu; + } + public void setMultiOu( boolean multiOu ) { this.multiOu = multiOu; @@ -173,6 +191,13 @@ { return dataValues; } + + private Map> commentViolations = new TreeMap>(); + + public Map> getCommentViolations() + { + return commentViolations; + } // ------------------------------------------------------------------------- // Action implementation @@ -223,9 +248,16 @@ { validationResults.put( organisationUnit, results ); } + + List violations = noValueRequiresCommentAnalysis( organisationUnit, dataSet, period ); + + if ( !violations.isEmpty() ) + { + commentViolations.put( organisationUnit, violations ); + } } - return dataValues.size() == 0 && validationResults.size() == 0 ? SUCCESS : INPUT; + return dataValues.isEmpty() && validationResults.isEmpty() & commentViolations.isEmpty() ? SUCCESS : INPUT; } // ------------------------------------------------------------------------- @@ -274,4 +306,35 @@ return validationResults; } + + // ------------------------------------------------------------------------- + // No value requires comment analysis + // ------------------------------------------------------------------------- + + private List noValueRequiresCommentAnalysis( OrganisationUnit organisationUnit, DataSet dataSet, Period period ) + { + List violations = new ArrayList(); + + if ( !dataSet.isNoValueRequiresComment() ) + { + return violations; + } + + for ( DataElement de : dataSet.getDataElements() ) + { + for ( DataElementCategoryOptionCombo co : de.getCategoryCombo().getOptionCombos() ) + { + DataValue dv = dataValueService.getDataValue( de, period, organisationUnit, co ); + + if ( dv == null || DataValue.FALSE.equals( dv.getValue() ) ) + { + violations.add( new DataElementOperand( de, co ) ); + } + } + } + + log.info( "Number of missing comments: " + violations.size() ); + + return violations; + } } === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2014-01-23 09:31:23 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2014-01-23 11:54:46 +0000 @@ -67,6 +67,7 @@ + === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties 2013-12-25 15:01:48 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties 2014-01-23 11:54:46 +0000 @@ -13,6 +13,7 @@ data_set=Data Set select=Select period=Period +form_field=Form field filter_on_section=Filter on section filter_in_section=Filter in section show_all_sections=Show all sections @@ -38,9 +39,10 @@ validation_result=Validation Result expression=Expression successful_validation=The data entry screen successfully passed validation -data_entry_screen_has_following_errors=The data entry screen has the following validation errors, please correct these before proceeding +data_entry_screen_has_following_errors=The data entry screen has the following validation errors, please correct +the_following_values_are_outliers=The following values are considered as outliers (min-max or std dev), please correct +the_following_fields_require_comment=The following input fields require a comment, please enter the_following_values_violate_rules=The following values violate validation rules -the_following_values_are_outliers=The following values are considered as outliers (min-max or std dev) value=Value operator=Operator no_organisationunit_selected=No Organisation Unit Selected @@ -54,7 +56,6 @@ data_entry=Data Entry followup=Follow-up validation_rule=Validation rule -the_following_values_are_outliers=The following values are considered as outliers (min-max or std dev). register_complete_dataset_success=Registered complete dataset register_complete_dataset_failed=Register complete dataset failed undo_register_complete_dataset_success=Undo register complete dataset success === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/validationResult.vm' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/validationResult.vm 2013-03-15 04:53:19 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/validationResult.vm 2014-01-23 11:54:46 +0000 @@ -1,13 +1,13 @@

$i18n.getString( "validation_result" )  

-

$i18n.getString( "data_entry_screen_has_following_errors" )

- #if( !$validationResults.isEmpty() ) #foreach( $key in $validationResults.keySet() ) #set( $results = $validationResults.get($key)) -

$key.displayName

+ #if( $multiOu )

$key.displayName

#end +

$i18n.getString( "data_entry_screen_has_following_errors" )

+ @@ -42,9 +42,10 @@ #foreach( $key in $dataValues.keySet() ) #set( $results = $dataValues.get( $key )) -

$key.displayName

+ #if( $multiOu )

$key.displayName

#end

$encoder.htmlEncode( $i18n.getString( "the_following_values_are_outliers" ) )

+
$i18n.getString( "validation_rule" )
@@ -55,7 +56,7 @@ #set( $mark = false ) #foreach( $value in $results ) - + @@ -69,3 +70,30 @@
$i18n.getString( "data_element" )
$value.dataElementName $value.categoryOptionComboNameParsed$encoder.htmlEncode( $value.dataElementName ) $encoder.htmlEncode( $value.categoryOptionComboNameParsed ) $value.min $value.value $value.max
#end #end + +#if ( !$commentViolations.isEmpty() ) + #foreach( $key in $commentViolations.keySet() ) + #set( $operands = $commentViolations.get( $key )) + + #if( $multiOu )

$key.displayName

#end + +

$encoder.htmlEncode( $i18n.getString( "the_following_fields_require_comment" ) )

+ + + + + + #set( $mark = false ) + #foreach( $operand in $operands ) + + + + #if( $mark ) + #set( $mark = false ) + #else + #set( $mark = true ) + #end + #end +
$i18n.getString( "form_field" )
$encoder.htmlEncode( $operand.prettyName )
+ #end +#end === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java 2014-01-19 05:53:05 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java 2014-01-23 11:54:46 +0000 @@ -219,6 +219,13 @@ { this.validCompleteOnly = validCompleteOnly; } + + private boolean noValueRequiresComment; + + public void setNoValueRequiresComment( boolean noValueRequiresComment ) + { + this.noValueRequiresComment = noValueRequiresComment; + } private boolean skipOffline; @@ -333,6 +340,7 @@ dataSet.setAllowFuturePeriods( allowFuturePeriods ); dataSet.setFieldCombinationRequired( fieldCombinationRequired ); dataSet.setValidCompleteOnly( validCompleteOnly ); + dataSet.setNoValueRequiresComment( noValueRequiresComment ); dataSet.setNotifyCompletingUser( notifyCompletingUser ); dataSet.setApproveData( approveData ); dataSet.setSkipOffline( skipOffline ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java 2014-01-19 05:53:05 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java 2014-01-23 11:54:46 +0000 @@ -237,6 +237,13 @@ this.validCompleteOnly = validCompleteOnly; } + private boolean noValueRequiresComment; + + public void setNoValueRequiresComment( boolean noValueRequiresComment ) + { + this.noValueRequiresComment = noValueRequiresComment; + } + private boolean skipOffline; public void setSkipOffline( boolean skipOffline ) @@ -358,6 +365,7 @@ dataSet.setAllowFuturePeriods( allowFuturePeriods ); dataSet.setFieldCombinationRequired( fieldCombinationRequired ); dataSet.setValidCompleteOnly( validCompleteOnly ); + dataSet.setNoValueRequiresComment( noValueRequiresComment ); dataSet.setNotifyCompletingUser( notifyCompletingUser ); dataSet.setApproveData( approveData ); dataSet.setSkipOffline( skipOffline ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties 2013-12-22 21:08:30 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties 2014-01-23 11:54:46 +0000 @@ -100,6 +100,7 @@ form_details=Form details complete_allowed_only_if_validation_passes=Complete allowed only if validation passes notification_recipients=Complete notification recipients +no_value_requires_comment=Missing value requires comment on complete skip_offline=Skip offline render_as_tabs=Render sections as tabs render_horizontally=Render Vertically === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm 2014-01-19 05:53:05 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm 2014-01-23 11:54:46 +0000 @@ -196,6 +196,15 @@ + + + + + + $i18n.getString( 'legend_set' ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2014-01-19 05:53:05 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2014-01-23 11:54:46 +0000 @@ -201,6 +201,15 @@ + + + + + + $i18n.getString( 'legend_set' )