=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReportService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReportService.java 2013-04-02 04:33:34 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReportService.java 2013-08-19 03:45:04 +0000 @@ -41,6 +41,8 @@ void saveOrUpdate( PatientTabularReport patientTabularReport ); PatientTabularReport getPatientTabularReport( int id ); + + PatientTabularReport getPatientTabularReport( String name ); void deletePatientTabularReport( PatientTabularReport patientTabularReport ); === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientreport/DefaultPatientTabularReportService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientreport/DefaultPatientTabularReportService.java 2013-04-02 04:33:34 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientreport/DefaultPatientTabularReportService.java 2013-08-19 03:45:04 +0000 @@ -73,7 +73,13 @@ { return tabularReportStore.get( id ); } - + + @Override + public PatientTabularReport getPatientTabularReport( String name ) + { + return tabularReportStore.getByName( name ); + } + @Override public Collection getPatientTabularReports( User user, String query, Integer min, Integer max ) { @@ -85,7 +91,7 @@ { tabularReportStore.save( patientTabularReport ); } - + @Override public int countPatientTabularReportList( User user, String query ) { === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateTabularReportAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateTabularReportAction.java 2012-03-12 08:10:06 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateTabularReportAction.java 2013-08-19 03:45:04 +0000 @@ -27,9 +27,9 @@ package org.hisp.dhis.caseentry.action.report; -import org.hisp.dhis.caseentry.state.SelectedStateManager; import org.hisp.dhis.i18n.I18n; -import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.patientreport.PatientTabularReport; +import org.hisp.dhis.patientreport.PatientTabularReportService; import com.opensymphony.xwork2.Action; @@ -45,11 +45,11 @@ // Dependencies // ------------------------------------------------------------------------- - private SelectedStateManager selectedStateManager; + private PatientTabularReportService tabularReportService; - public void setSelectedStateManager( SelectedStateManager selectedStateManager ) + public void setTabularReportService( PatientTabularReportService tabularReportService ) { - this.selectedStateManager = selectedStateManager; + this.tabularReportService = tabularReportService; } private I18n i18n; @@ -62,12 +62,19 @@ // ------------------------------------------------------------------------- // Input && Output // ------------------------------------------------------------------------- - - private String facilityLB; - - public void setFacilityLB( String facilityLB ) - { - this.facilityLB = facilityLB; + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private String name; + + public void setName( String name ) + { + this.name = name; } private String message; @@ -84,19 +91,18 @@ public String execute() throws Exception { - OrganisationUnit selectedOrgunit = selectedStateManager.getSelectedOrganisationUnit(); - - if ( selectedOrgunit == null ) - { - message = i18n.getString( "please_specify_an_orgunit" ); - return INPUT; - } - - if ( facilityLB.equals( "childrenOnly" ) && !selectedOrgunit.hasChild() ) - { - message = i18n.getString( "selected_orgunit_no_have_any_child" ); - return INPUT; - } + name = name.trim(); + + PatientTabularReport match = tabularReportService.getPatientTabularReport( name ); + + if ( match != null && (id == null || match.getId() != id.intValue()) ) + { + message = i18n.getString( "name_in_use" ); + + return INPUT; + } + + message = i18n.getString( "everything_is_ok" ); return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-08-12 06:23:01 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-08-19 03:45:04 +0000 @@ -933,8 +933,8 @@ id="org.hisp.dhis.caseentry.action.report.ValidateTabularReportAction" class="org.hisp.dhis.caseentry.action.report.ValidateTabularReportAction" scope="prototype"> - +