------------------------------------------------------------ revno: 10733 committer: Tran Chau <tran.hispviet...@gmail.com> branch nick: dhis2 timestamp: Thu 2013-05-02 16:43:44 +0700 message: Fix bug when to click on Test button in Add Aggregate Query Builder form. modified: dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/TestCaseAggregationConditionAction.java dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.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/caseaggregation/CaseAggregationConditionService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java 2013-05-02 08:41:20 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java 2013-05-02 09:43:44 +0000 @@ -80,4 +80,5 @@ void aggregate( List<CaseAggregateSchedule> caseAggregateSchedules, String taskStrategy ); boolean hasOrgunitProgramStageCompleted( String expresstion ); + } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2013-05-02 08:41:20 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2013-05-02 09:43:44 +0000 @@ -108,6 +108,7 @@ { this.aggregationConditionManager = aggregationConditionManager; } + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) { this.patientAttributeService = patientAttributeService; @@ -416,7 +417,7 @@ { return aggregationConditionManager.hasOrgunitProgramStageCompleted( expresstion ); } - + // ------------------------------------------------------------------------- // Support Methods // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/TestCaseAggregationConditionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/TestCaseAggregationConditionAction.java 2013-05-02 08:10:43 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/TestCaseAggregationConditionAction.java 2013-05-02 09:43:44 +0000 @@ -29,15 +29,13 @@ import java.util.Collection; import java.util.Date; +import java.util.HashSet; +import java.util.List; -import org.hisp.dhis.caseaggregation.CaseAggregationCondition; -import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.AGGRERATION_COUNT; -import org.hisp.dhis.caseaggregation.CaseAggregationConditionService; -import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.i18n.I18n; -import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.caseaggregation.CaseAggregationConditionManager; +import org.hisp.dhis.period.MonthlyPeriodType; import org.hisp.dhis.period.Period; -import org.hisp.dhis.program.Program; +import org.hisp.dhis.period.PeriodType; import com.opensymphony.xwork2.Action; @@ -55,25 +53,11 @@ // Dependency // ------------------------------------------------------------------------- - private CaseAggregationConditionService aggregationConditionService; - - public void setAggregationConditionService( CaseAggregationConditionService aggregationConditionService ) - { - this.aggregationConditionService = aggregationConditionService; - } - - private DataElementService dataElementService; - - public void setDataElementService( DataElementService dataElementService ) - { - this.dataElementService = dataElementService; - } - - private I18n i18n; - - public void setI18n( I18n i18n ) - { - this.i18n = i18n; + private CaseAggregationConditionManager caseAggregationConditionManager; + + public void setCaseAggregationConditionManager( CaseAggregationConditionManager caseAggregationConditionManager ) + { + this.caseAggregationConditionManager = caseAggregationConditionManager; } // ------------------------------------------------------------------------- @@ -116,41 +100,21 @@ public String execute() throws Exception { - CaseAggregationCondition aggCondition = new CaseAggregationCondition( "", operator, condition, null, null ); - if ( deSumId != null ) - { - aggCondition.setDeSum( dataElementService.getDataElement( deSumId ) ); - } - - Collection<Program> programs = aggregationConditionService.getProgramsInCondition( condition ); - - if ( operator.equals( AGGRERATION_COUNT ) ) - { - for ( Program program : programs ) - { - if ( program.getType() == Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) - { - message = i18n.getString( "select_operator_number_of_visits_for_this_condition" ); - return INPUT; - } - } - } - - OrganisationUnit orgunit = new OrganisationUnit(); - orgunit.setId( 1 ); - + Collection<Integer> orgunitIds = new HashSet<Integer>(); + orgunitIds.add( 0 ); + + MonthlyPeriodType periodType = new MonthlyPeriodType(); Period period = new Period(); period.setStartDate( new Date() ); period.setEndDate( new Date() ); - -// Double value = aggregationConditionService.getAggregateValue( aggCondition, orgunit, period ); - - Double value = null; - if ( value == null ) - { - return INPUT; - } - - return SUCCESS; + period.setPeriodType( periodType ); + + String sql = caseAggregationConditionManager.parseExpressionToSql( false, condition, operator, 0, + "dataelementname", 0, "optioncomboid", deSumId, orgunitIds, period ); + + List<Integer> ids = caseAggregationConditionManager.executeSQL( sql ); + + return (ids == null) ? INPUT : SUCCESS; + } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-24 04:07:59 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-05-02 09:43:44 +0000 @@ -860,11 +860,8 @@ id="org.hisp.dhis.patient.action.caseaggregation.TestCaseAggregationConditionAction" class="org.hisp.dhis.patient.action.caseaggregation.TestCaseAggregationConditionAction" scope="prototype"> - <property name="aggregationConditionService"> - <ref bean="org.hisp.dhis.caseaggregation.CaseAggregationConditionService" /> - </property> - <property name="dataElementService"> - <ref bean="org.hisp.dhis.dataelement.DataElementService" /> + <property name="caseAggregationConditionManager"> + <ref bean="org.hisp.dhis.caseaggregation.CaseAggregationConditionManager" /> </property> </bean> === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js 2013-04-28 08:54:29 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js 2013-05-02 09:43:44 +0000 @@ -344,12 +344,7 @@ if ( type == "input" ) { - if( json.message == '' ){ - showWarningMessage( i18n_run_fail ); - } - else{ - showWarningMessage( json.message ); - } + showWarningMessage( json.message ); } else {
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp