=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.java 2011-02-10 23:09:13 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.java 2011-03-01 04:17:29 +0000 @@ -42,6 +42,7 @@ import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.oust.manager.SelectionTreeManager; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; @@ -58,7 +59,7 @@ implements Action { private static final Log log = LogFactory.getLog( GetAnalysisAction.class ); - + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -70,11 +71,11 @@ this.serviceProvider = serviceProvider; } - private OrganisationUnitService organisationUnitService; + private SelectionTreeManager selectionTreeManager; - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) { - this.organisationUnitService = organisationUnitService; + this.selectionTreeManager = selectionTreeManager; } private PeriodService periodService; @@ -129,37 +130,37 @@ } private Collection dataSets; - + public void setDataSets( Collection dataSets ) { this.dataSets = dataSets; } - private Integer organisationUnit; - - public void setOrganisationUnit( Integer organisationUnit ) - { - this.organisationUnit = organisationUnit; - } - private Double standardDeviation; public void setStandardDeviation( Double standardDeviation ) { this.standardDeviation = standardDeviation; } - + + private String message; + + public String getMessage() + { + return message; + } + // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- - + private Collection dataValues = new ArrayList(); public Collection getDataValues() { return dataValues; } - + private boolean maxExceeded; public boolean isMaxExceeded() @@ -175,9 +176,9 @@ { Set dataElements = new HashSet(); Collection periods = null; - OrganisationUnit unit = null; - - if ( fromDate != null && toDate != null && dataSets != null && organisationUnit != null ) + OrganisationUnit unit = selectionTreeManager.getReloadedSelectedOrganisationUnit();; + + if ( fromDate != null && toDate != null && dataSets != null ) { periods = periodService.getPeriodsBetweenDates( format.parseDate( fromDate ), format.parseDate( toDate ) ); @@ -185,22 +186,22 @@ { dataElements.addAll( dataSetService.getDataSet( Integer.parseInt( id ) ).getDataElements() ); } - - unit = organisationUnitService.getOrganisationUnit( organisationUnit ); - - log.info( "From date: " + fromDate + ", To date: " + toDate + ", Organisation unit: " + unit + ", Std dev: " + standardDeviation + ", Key: " + key ); + + + log.info( "From date: " + fromDate + ", To date: " + toDate + ", Organisation unit: " + unit + + ", Std dev: " + standardDeviation + ", Key: " + key ); log.info( "Nr of data elements: " + dataElements.size() + " Nr of periods: " + periods.size() ); } - + DataAnalysisService service = serviceProvider.provide( key ); if ( service != null ) // Follow-up analysis has no input params - { + { dataValues = service.analyse( unit, dataElements, periods, standardDeviation ); - + maxExceeded = dataValues.size() > DataAnalysisService.MAX_OUTLIERS; } - + return SUCCESS; } } === added file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/ValidationRunAnalysisAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/ValidationRunAnalysisAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/ValidationRunAnalysisAction.java 2011-03-01 04:17:29 +0000 @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2004-2010, 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.validationrule.action.dataanalysis; + +import java.util.Date; + +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.oust.manager.SelectionTreeManager; + +import com.opensymphony.xwork2.ActionSupport; + +/** + * @author Chau Thu Tran + * @version $Id ValidationRunAnalysisAction.java Mar 1, 2011 9:54:31 AM $ + */ +public class ValidationRunAnalysisAction + extends ActionSupport +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private SelectionTreeManager selectionTreeManager; + + public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) + { + this.selectionTreeManager = selectionTreeManager; + } + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + private String fromDate; + + public void setFromDate( String fromDate ) + { + this.fromDate = fromDate; + } + + private String toDate; + + public void setToDate( String toDate ) + { + this.toDate = toDate; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private String message; + + public String getMessage() + { + return message; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + OrganisationUnit selectedOrganisationUnit = selectionTreeManager.getReloadedSelectedOrganisationUnit(); + + if ( selectedOrganisationUnit == null ) + { + message = i18n.getString( "specify_organisationunit" ); + + return INPUT; + } + + Date sDate = format.parseDate( fromDate.trim() ); + + if ( sDate == null ) + { + message = i18n.getString( "enter_a_valid_start_date" ); + + return INPUT; + } + + Date eDate = format.parseDate( toDate.trim() ); + + if ( eDate == null ) + { + message = i18n.getString( "enter_a_valid_ending_date" ); + + return INPUT; + } + + if ( eDate.before( sDate ) ) + { + message = i18n.getString( "end_date_cannot_be_before_start_date" ); + + return INPUT; + } + + message = i18n.getString( "everything_is_ok" ); + + return SUCCESS; + } + +} === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml 2011-01-25 19:26:03 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml 2011-03-01 04:17:29 +0000 @@ -248,8 +248,8 @@ scope="prototype"> - + + + + + + /dhis-web-validationrule/responseSuccess.vm + + /dhis-web-validationrule/responseSuccess.vm + /dhis-web-validationrule/responseError.vm + /dhis-web-validationrule/responseInput.vm + + === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/dataAnalysisForm.vm' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/dataAnalysisForm.vm 2010-07-04 23:55:46 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/dataAnalysisForm.vm 2011-03-01 04:17:29 +0000 @@ -107,7 +107,7 @@ - + @@ -116,6 +116,9 @@