dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23973
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11693: Add function for validating name of agregate tabular report.
------------------------------------------------------------
revno: 11693
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-08-19 13:54:13 +0700
message:
Add function for validating name of agregate tabular report.
added:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateAggregateReportAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReportService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientreport/DefaultPatientAggregateReportService.java
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/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
--
lp:dhis2
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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReportService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReportService.java 2013-04-02 04:33:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReportService.java 2013-08-19 06:54:13 +0000
@@ -44,6 +44,8 @@
PatientAggregateReport getPatientAggregateReport( int id );
+ PatientAggregateReport getPatientAggregateReport( String name );
+
void deletePatientAggregateReport( PatientAggregateReport patientAggregateReport );
Collection<PatientAggregateReport> getAllPatientAggregateReports();
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientreport/DefaultPatientAggregateReportService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientreport/DefaultPatientAggregateReportService.java 2013-04-02 04:33:34 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientreport/DefaultPatientAggregateReportService.java 2013-08-19 06:54:13 +0000
@@ -91,4 +91,9 @@
return patientAggregateReportStore.countList( user, query );
}
+ @Override
+ public PatientAggregateReport getPatientAggregateReport( String name )
+ {
+ return patientAggregateReportStore.getByName( name );
+ }
}
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateAggregateReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateAggregateReportAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateAggregateReportAction.java 2013-08-19 06:54:13 +0000
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2004-2012, 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.
+ */
+
+package org.hisp.dhis.caseentry.action.report;
+
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.patientreport.PatientAggregateReport;
+import org.hisp.dhis.patientreport.PatientAggregateReportService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $ValidationTabularReportAction.java Mar 12, 2012 12:36:48 PM$
+ */
+public class ValidateAggregateReportAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private PatientAggregateReportService aggregateReportService;
+
+ public void setAggregateReportService( PatientAggregateReportService aggregateReportService )
+ {
+ this.aggregateReportService = aggregateReportService;
+ }
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input && Output
+ // -------------------------------------------------------------------------
+
+ 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;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation Action
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ name = name.trim();
+
+ PatientAggregateReport match = aggregateReportService.getPatientAggregateReport( 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-19 03:45:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-08-19 06:54:13 +0000
@@ -1064,6 +1064,14 @@
<property name="organisationUnitGroupService"
ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
</bean>
+
+ <bean
+ id="org.hisp.dhis.caseentry.action.report.ValidateAggregateReportAction"
+ class="org.hisp.dhis.caseentry.action.report.ValidateAggregateReportAction"
+ scope="prototype">
+ <property name="aggregateReportService"
+ ref="org.hisp.dhis.patientreport.PatientAggregateReportService" />
+ </bean>
<!-- Reminder -->
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-08-19 03:45:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-08-19 06:54:13 +0000
@@ -644,7 +644,7 @@
events = Events
list_events = List events
orgunit_code = Code
-display_orgunit_code = Display orgunit code
+display_orgunit_code = Display organisation unit code
hide = Hide
none_program = None program
none_dataset = None dataset
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-08-12 06:23:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-08-19 06:54:13 +0000
@@ -1031,6 +1031,17 @@
/dhis-web-caseentry/jsonminOrganisationUnitPaths.vm
</result>
</action>
+
+ <action name="validateAggregateReport"
+ class="org.hisp.dhis.caseentry.action.report.ValidateAggregateReportAction">
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm
+ </result>
+ <result name="input" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseInput.vm
+ </result>
+ <param name="requiredAuthorities">F_GENERATE_BENEFICIARY_TABULAR_REPORT</param>
+ </action>
<!-- SMS Reminder -->
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2013-08-19 03:45:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2013-08-19 06:54:13 +0000
@@ -63,6 +63,7 @@
aggregatefavorite_rename: 'updateAggregateReportName.action',
aggregatefavorite_save: 'saveAggregateReport.action',
aggregatefavorite_delete: 'deleteAggregateReport.action',
+ aggregatefavorite_validate: 'validateAggregateReport.action',
generateaggregatereport_get: 'generateAggregateReport.action',
username_dataelement_get: 'getUsernameList.action',
organisationunit_getbyids: 'getOrganisationUnitPaths.action',
@@ -1210,37 +1211,65 @@
}
Ext.Ajax.request({
- url: TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.aggregatefavorite_save,
+ url: TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.aggregatefavorite_validate,
method: 'POST',
- params: p,
- success: function() {
- TR.store.aggregateFavorite.load({callback: function() {
- TR.util.mask.hideMask();
- if (fn) {
- fn();
- }
- }});
- }
- });
+ params: {name:name},
+ success: function(r) {
+ var json = Ext.JSON.decode(r.responseText);
+ if(json.response=='success'){
+ Ext.Ajax.request({
+ url: TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.aggregatefavorite_save,
+ method: 'POST',
+ params: p,
+ success: function() {
+ TR.store.aggregateFavorite.load({callback: function() {
+ TR.util.mask.hideMask();
+ if (fn) {
+ fn();
+ }
+ }});
+ }
+ });
+ }
+ else{
+ TR.util.notification.error(TR.i18n.error, json.message);
+ window.destroy();
+ TR.util.mask.hideMask();
+ }
+ }
+ });
},
updateName: function(id, name) {
- if (TR.store.aggregateFavorite.findExact('name', name) != -1) {
- return;
- }
TR.util.mask.showMask(TR.cmp.aggregateFavorite.window, TR.i18n.renaming + '...');
+
Ext.Ajax.request({
- url: TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.aggregatefavorite_rename,
+ url: TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.aggregatefavorite_validate,
method: 'POST',
- params: {id: id, name: name},
- success: function() {
- TR.store.aggregateFavorite.load({callback: function() {
- TR.cmp.aggregateFavorite.rename.window.close();
- TR.util.mask.hideMask();
- TR.cmp.aggregateFavorite.grid.getSelectionModel().select(TR.store.aggregateFavorite.getAt(TR.store.aggregateFavorite.findExact('name', name)));
- TR.cmp.aggregateFavorite.name.setValue(name);
- }});
- }
- });
+ params: {id:id, name:name},
+ success: function(r) {
+ var json = Ext.JSON.decode(r.responseText);
+ if(json.response=='success'){
+ Ext.Ajax.request({
+ url: TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.aggregatefavorite_rename,
+ method: 'POST',
+ params: {id: id, name: name},
+ success: function() {
+ TR.store.aggregateFavorite.load({callback: function() {
+ TR.cmp.aggregateFavorite.rename.window.close();
+ TR.util.mask.hideMask();
+ TR.cmp.aggregateFavorite.grid.getSelectionModel().select(TR.store.aggregateFavorite.getAt(TR.store.aggregateFavorite.findExact('name', name)));
+ TR.cmp.aggregateFavorite.name.setValue(name);
+ }});
+ }
+ });
+ }
+ else{
+ TR.util.notification.error(TR.i18n.error, json.message);
+ window.destroy();
+ TR.util.mask.hideMask();
+ }
+ }
+ });
},
del: function(fn) {
TR.util.mask.showMask(TR.cmp.aggregateFavorite.window, TR.i18n.deleting + '...');
@@ -3746,15 +3775,33 @@
p.name = name;
Ext.Ajax.request({
- url: TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.aggregatefavorite_save,
+ url: TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.aggregatefavorite_validate,
method: 'POST',
- params: p,
- success: function() {
- TR.store.aggregateFavorite.loadStore();
- window.destroy();
- TR.util.mask.hideMask();
- }
- });
+ params: {name:name},
+ success: function(r) {
+ var json = Ext.JSON.decode(r.responseText);
+ if(json.response=='success'){
+ Ext.Ajax.request({
+ url: TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.aggregatefavorite_save,
+ method: 'POST',
+ params: p,
+ success: function() {
+ TR.store.aggregateFavorite.load({callback: function() {
+ TR.util.mask.hideMask();
+ if (fn) {
+ fn();
+ }
+ }});
+ }
+ });
+ }
+ else{
+ TR.util.notification.error(TR.i18n.error, json.message);
+ window.destroy();
+ TR.util.mask.hideMask();
+ }
+ }
+ });
}
}
});