dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19730
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8733: Allow a date range instead of period range in Person Aggregate module.
------------------------------------------------------------
revno: 8733
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-10-26 16:02:41 +0700
message:
Allow a date range instead of period range in Person Aggregate module.
removed:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/LoadPeriodsAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultPeriodGenericManager.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/NextPeriodsAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PeriodGenericManager.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PreviousPeriodsAction.java
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/ValidationCaseAggregationAction.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/struts.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.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-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2012-10-26 03:05:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2012-10-26 09:02:41 +0000
@@ -39,7 +39,6 @@
import org.hisp.dhis.caseaggregation.CaseAggregationCondition;
import org.hisp.dhis.caseaggregation.CaseAggregationConditionService;
-import org.hisp.dhis.caseentry.state.PeriodGenericManager;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -97,13 +96,6 @@
this.dataValueService = dataValueService;
}
- private PeriodGenericManager periodGenericManager;
-
- public void setPeriodGenericManager( PeriodGenericManager periodGenericManager )
- {
- this.periodGenericManager = periodGenericManager;
- }
-
private I18nFormat format;
public void setFormat( I18nFormat format )
@@ -136,6 +128,20 @@
this.dataSetId = dataSetId;
}
+ private String startDate;
+
+ public void setStartDate( String startDate )
+ {
+ this.startDate = startDate;
+ }
+
+ private String endDate;
+
+ public void setEndDate( String endDate )
+ {
+ this.endDate = endDate;
+ }
+
private Map<String, String> mapStatusValues = new HashMap<String, String>();
public Map<String, String> getMapStatusValues()
@@ -211,7 +217,7 @@
// ---------------------------------------------------------------------
DataSet selectedDataSet = dataSetService.getDataSet( dataSetId );
-
+
Collection<CaseAggregationCondition> aggregationConditions = aggregationConditionService
.getAllCaseAggregationCondition();
@@ -219,15 +225,10 @@
// Get selected periods list
// ---------------------------------------------------------------------
- Period startPeriod = periodGenericManager.getSelectedPeriod(
- PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START,
- PeriodGenericManager.SESSION_KEY_BASE_PERIOD_START );
-
- Period endPeriod = periodGenericManager.getSelectedPeriod(
- PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END,
- PeriodGenericManager.SESSION_KEY_BASE_PERIOD_END );
-
- periods = getPeriodList( (CalendarPeriodType) selectedDataSet.getPeriodType(), startPeriod, endPeriod );
+ CalendarPeriodType periodType = (CalendarPeriodType) selectedDataSet.getPeriodType();
+
+ periods.addAll( periodType.generatePeriods( format.parseDate( startDate ),
+ format.parseDate( endDate ) ) );
// ---------------------------------------------------------------------
// Aggregation
@@ -239,7 +240,7 @@
{
DataElement dElement = condition.getAggregationDataElement();
DataElementCategoryOptionCombo optionCombo = condition.getOptionCombo();
-
+
for ( Period period : periods )
{
Integer resultValue = aggregationConditionService.parseConditition( condition, orgUnit, period );
@@ -315,21 +316,4 @@
}
return orgUnitTree;
}
-
- private List<Period> getPeriodList( CalendarPeriodType periodType, Period startPeriod, Period endPeriod )
- {
- Period period = periodType.createPeriod( startPeriod.getStartDate() );
-
- List<Period> periods = new ArrayList<Period>();
-
- periods.add( period );
-
- while ( period.getEndDate().before( endPeriod.getEndDate() ) )
- {
- period = periodType.getNextPeriod( period );
- periods.add( period );
- }
-
- return periods;
- }
}
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/LoadPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/LoadPeriodsAction.java 2011-05-01 09:07:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/LoadPeriodsAction.java 1970-01-01 00:00:00 +0000
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2004-2009, 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.caseaggregation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-
-import org.hisp.dhis.caseentry.state.PeriodGenericManager;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.period.CalendarPeriodType;
-import org.hisp.dhis.period.Period;
-
-import com.opensymphony.xwork2.Action;
-
-public class LoadPeriodsAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private DataSetService dataSetService;
-
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
- private PeriodGenericManager periodGenericManager;
-
- public void setPeriodGenericManager( PeriodGenericManager periodGenericManager )
- {
- this.periodGenericManager = periodGenericManager;
- }
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private Integer dataSetId;
-
- public void setDataSetId( Integer dataSetId )
- {
- this.dataSetId = dataSetId;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private List<Period> periods = new ArrayList<Period>();
-
- public Collection<Period> getPeriods()
- {
- return periods;
- }
-
- private boolean periodValid;
-
- public boolean isPeriodValid()
- {
- return periodValid;
- }
-
- private Collection<DataElement> significantZeros = new HashSet<DataElement>();
-
- public Collection<DataElement> getSignificantZeros()
- {
- return significantZeros;
- }
-
- // -------------------------------------------------------------------------
- // Implementation Action
- // -------------------------------------------------------------------------
-
- public String execute()
- {
- DataSet selectedDataSet = dataSetService.getDataSet( dataSetId );
-
- periodGenericManager.clearSelectedPeriod();
- periodGenericManager.clearBasePeriod();
-
- periodGenericManager.setPeriodType( selectedDataSet.getPeriodType().getName() );
-
- if ( selectedDataSet != null )
- {
- periods = getPeriodList( (CalendarPeriodType) selectedDataSet.getPeriodType() );
- }
-
- return SUCCESS;
- }
-
- // -------------------------------------------------------------------------
- // Support method
- // -------------------------------------------------------------------------
-
- private List<Period> getPeriodList( CalendarPeriodType periodType )
- {
- Period basePeriod = periodType.createPeriod();
-
- List<Period> periods = periodType.generatePeriods( basePeriod );
-
- Date now = new Date();
-
- Iterator<Period> iterator = periods.iterator();
-
- while ( iterator.hasNext() )
- {
- if ( iterator.next().getStartDate().after( now ) )
- {
- iterator.remove();
- }
- }
-
- return periods;
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/ValidationCaseAggregationAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/ValidationCaseAggregationAction.java 2011-03-31 01:49:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/ValidationCaseAggregationAction.java 2012-10-26 09:02:41 +0000
@@ -27,11 +27,9 @@
package org.hisp.dhis.caseentry.action.caseaggregation;
-import org.hisp.dhis.caseentry.state.PeriodGenericManager;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
-import org.hisp.dhis.period.Period;
import com.opensymphony.xwork2.Action;
@@ -48,8 +46,6 @@
private SelectionTreeManager selectionTreeManager;
- private PeriodGenericManager periodGenericManager;
-
private I18n i18n;
// -------------------------------------------------------------------------
@@ -57,20 +53,11 @@
// -------------------------------------------------------------------------
private String message;
-
- private int sDateLB;
-
- private int eDateLB;
// -------------------------------------------------------------------------
// Getters/Setters
// -------------------------------------------------------------------------
-
- public void setPeriodGenericManager( PeriodGenericManager periodGenericManager )
- {
- this.periodGenericManager = periodGenericManager;
- }
-
+
public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
{
this.selectionTreeManager = selectionTreeManager;
@@ -81,16 +68,6 @@
this.i18n = i18n;
}
- public void setEDateLB( int dateLB )
- {
- eDateLB = dateLB;
- }
-
- public void setSDateLB( int dateLB )
- {
- sDateLB = dateLB;
- }
-
public String getMessage()
{
return message;
@@ -117,28 +94,6 @@
return INPUT;
}
- // ---------------------------------------------------------------------
- // Check start-date and end-date
- // ---------------------------------------------------------------------
-
- periodGenericManager.setSelectedPeriodIndex( PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START,
- sDateLB );
- Period startPeriod = periodGenericManager.getSelectedPeriod(
- PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START,
- PeriodGenericManager.SESSION_KEY_BASE_PERIOD_START );
-
- periodGenericManager.setSelectedPeriodIndex( PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END,
- eDateLB );
- Period endPeriod = periodGenericManager.getSelectedPeriod(
- PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END,
- PeriodGenericManager.SESSION_KEY_BASE_PERIOD_END );
-
- if ( startPeriod.getEndDate().after( endPeriod.getEndDate() ) )
- {
- message = i18n.getString("please_select_to_date_greater_or_equals_to_from_date");
- return INPUT;
- }
-
return SUCCESS;
}
}
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultPeriodGenericManager.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultPeriodGenericManager.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultPeriodGenericManager.java 1970-01-01 00:00:00 +0000
@@ -1,204 +0,0 @@
-package org.hisp.dhis.caseentry.state;
-
-/*
- * 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.
- */
-
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.period.CalendarPeriodType;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.period.PeriodType;
-
-import com.opensymphony.xwork2.ActionContext;
-
-/**
- * @author Chau Thu Tran
- * @version $Id$
- */
-public class DefaultPeriodGenericManager
- implements PeriodGenericManager
-{
- private static final Log log = LogFactory.getLog( DefaultPeriodGenericManager.class );
-
- public static final String SESSION_KEY_SELECTED_PERIOD_TYPE = "SESSION_KEY_SELECTED_PERIOD_TYPE";
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private PeriodService periodService;
-
- public void setPeriodService( PeriodService periodService )
- {
- this.periodService = periodService;
- }
-
- // -------------------------------------------------------------------------
- // Implementation methodss
- // -------------------------------------------------------------------------
-
- public void setSelectedPeriodIndex( String key, Integer index )
- {
- getSession().put( key, index );
- }
-
- public Integer getSelectedPeriodIndex( String key )
- {
- return (Integer) getSession().get( key );
- }
-
- public Period getSelectedPeriod( String key, String baseKey )
- {
- Integer index = getSelectedPeriodIndex( key );
-
- if ( index == null )
- {
- return null;
- }
-
- List<Period> periods = getPeriodList( key, baseKey );
-
- if ( index >= 0 && index < periods.size() )
- {
- return periods.get( index );
- }
-
- return null;
- }
-
- public void clearSelectedPeriod()
- {
- getSession().remove( SESSION_KEY_SELECTED_PERIOD_INDEX_START );
- getSession().remove( SESSION_KEY_SELECTED_PERIOD_INDEX_END );
- }
-
- public List<Period> getPeriodList( String key, String baseKey )
- {
- Period basePeriod = getBasePeriod( baseKey );
-
- CalendarPeriodType periodType = (CalendarPeriodType) getPeriodType();
-
- List<Period> periods = periodType.generatePeriods( basePeriod );
-
- Date now = new Date();
-
- Iterator<Period> iterator = periods.iterator();
-
- while ( iterator.hasNext() )
- {
- if ( iterator.next().getStartDate().after( now ) )
- {
- iterator.remove();
- }
- }
-
- return periods;
- }
-
- public void nextPeriodSpan( String key, String baseKey )
- {
- List<Period> periods = getPeriodList( key, baseKey );
- CalendarPeriodType periodType = (CalendarPeriodType) getPeriodType();
-
- Period basePeriod = periods.get( periods.size() - 1 );
- Period newBasePeriod = periodType.getNextPeriod( basePeriod );
-
- if ( newBasePeriod.getStartDate().before( new Date() ) ) // Future
- // periods not
- // allowed
- {
- getSession().put( baseKey, newBasePeriod );
- }
- }
-
- public void previousPeriodSpan( String key, String baseKey )
- {
- List<Period> periods = getPeriodList( key, baseKey );
- CalendarPeriodType periodType = (CalendarPeriodType) getPeriodType();
-
- Period basePeriod = periods.get( 0 );
- Period newBasePeriod = periodType.getPreviousPeriod( basePeriod );
-
- getSession().put( baseKey, newBasePeriod );
- }
-
- // -------------------------------------------------------------------------
- // Supporting methods
- // -------------------------------------------------------------------------
-
- private PeriodType getPeriodType()
- {
- return (PeriodType) getSession().get( SESSION_KEY_SELECTED_PERIOD_TYPE );
- }
-
- private Period getBasePeriod( String baseKey )
- {
- Period basePeriod = (Period) getSession().get( baseKey );
-
- PeriodType periodType = getPeriodType();
-
- if ( basePeriod == null )
- {
- log.debug( "Base period is null, creating new" );
-
- basePeriod = periodType.createPeriod();
- getSession().put( baseKey, basePeriod );
- }
- else if ( !basePeriod.getPeriodType().equals( periodType ) )
- {
- log.debug( "Wrong type of base period, transforming" );
-
- basePeriod = periodType.createPeriod( basePeriod.getStartDate() );
- getSession().put( baseKey, basePeriod );
- }
-
- return basePeriod;
- }
-
- private static final Map<String, Object> getSession()
- {
- return ActionContext.getContext().getSession();
- }
-
- @Override
- public void setPeriodType( String periodTypeName )
- {
- getSession().put( SESSION_KEY_SELECTED_PERIOD_TYPE, periodService.getPeriodTypeByName( periodTypeName ) );
- }
-
- public void clearBasePeriod()
- {
- getSession().remove( SESSION_KEY_BASE_PERIOD_START );
- getSession().remove( SESSION_KEY_BASE_PERIOD_END );
- }
-}
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/NextPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/NextPeriodsAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/NextPeriodsAction.java 1970-01-01 00:00:00 +0000
@@ -1,109 +0,0 @@
-package org.hisp.dhis.caseentry.state;
-
-/*
- * 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.
- */
-
-import java.util.List;
-
-import org.hisp.dhis.period.Period;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Torgeir Lorange Ostby
- * @version $Id: NextPeriodsAction.java 2966 2007-03-03 14:38:20Z torgeilo $ *
- * @modifier Dang Duy Hieu
- * @since 2009-10-14
- */
-public class NextPeriodsAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private PeriodGenericManager periodGenericManager;
-
- public void setPeriodGenericManager( PeriodGenericManager periodGenericManager )
- {
- this.periodGenericManager = periodGenericManager;
- }
-
- // -------------------------------------------------------------------------
- // Input && Output
- // -------------------------------------------------------------------------
-
- private boolean startField;
-
- public void setStartField( boolean startField )
- {
- this.startField = startField;
- }
-
- private List<Period> periods;
-
- public List<Period> getPeriods()
- {
- return periods;
- }
-
- private Integer index;
-
- public void setIndex( Integer index )
- {
- this.index = index;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- String selectedPeriodKey = "";
- String basePeriodKey = "";
-
- if ( startField )
- {
- selectedPeriodKey = PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START;
- basePeriodKey = PeriodGenericManager.SESSION_KEY_BASE_PERIOD_START;
- }
- else
- {
- selectedPeriodKey = PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END;
- basePeriodKey = PeriodGenericManager.SESSION_KEY_BASE_PERIOD_END;
- }
-
- periodGenericManager.setSelectedPeriodIndex( selectedPeriodKey, index );
- periodGenericManager.nextPeriodSpan( selectedPeriodKey, basePeriodKey );
-
- periods = periodGenericManager.getPeriodList( selectedPeriodKey, basePeriodKey );
-
- return SUCCESS;
- }
-}
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PeriodGenericManager.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PeriodGenericManager.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PeriodGenericManager.java 1970-01-01 00:00:00 +0000
@@ -1,62 +0,0 @@
-package org.hisp.dhis.caseentry.state;
-
-/*
- * 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.
- */
-
-import java.util.List;
-
-import org.hisp.dhis.period.Period;
-
-/**
- * @author Chau Thu Tran
- * @version $Id$
- */
-public interface PeriodGenericManager
-{
- final String SESSION_KEY_BASE_PERIOD_START = "SESSION_KEY_BASE_PERIOD_START";
- final String SESSION_KEY_BASE_PERIOD_END = "SESSION_KEY_BASE_PERIOD_END";
- final String SESSION_KEY_SELECTED_PERIOD_INDEX_START = "SESSION_KEY_SELECTED_PERIOD_INDEX_START";
- final String SESSION_KEY_SELECTED_PERIOD_INDEX_END = "SESSION_KEY_SELECTED_PERIOD_INDEX_END";
-
- void setSelectedPeriodIndex( String key, Integer index );
-
- Integer getSelectedPeriodIndex( String key );
-
- Period getSelectedPeriod( String key, String baseKey );
-
- void setPeriodType( String periodTypeName );
-
- void clearSelectedPeriod();
-
- void clearBasePeriod();
-
- List<Period> getPeriodList( String key, String baseKey );
-
- void nextPeriodSpan( String key, String baseKey );
-
- void previousPeriodSpan( String key, String baseKey );
-}
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PreviousPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PreviousPeriodsAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PreviousPeriodsAction.java 1970-01-01 00:00:00 +0000
@@ -1,107 +0,0 @@
-package org.hisp.dhis.caseentry.state;
-
-/*
- * 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.
- */
-
-import java.util.List;
-
-import org.hisp.dhis.period.Period;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Torgeir Lorange Ostby
- * @author Dang Duy Hieu
- */
-public class PreviousPeriodsAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private PeriodGenericManager periodGenericManager;
-
- public void setPeriodGenericManager( PeriodGenericManager periodGenericManager )
- {
- this.periodGenericManager = periodGenericManager;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private boolean startField;
-
- public void setStartField( boolean startField )
- {
- this.startField = startField;
- }
-
- private List<Period> periods;
-
- public List<Period> getPeriods()
- {
- return periods;
- }
-
- private Integer index;
-
- public void setIndex( Integer index )
- {
- this.index = index;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- String selectedPeriodKey = "";
- String basePeriodKey = "";
-
- if ( startField )
- {
- selectedPeriodKey = PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START;
- basePeriodKey = PeriodGenericManager.SESSION_KEY_BASE_PERIOD_START;
- }
- else
- {
- selectedPeriodKey = PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END;
- basePeriodKey = PeriodGenericManager.SESSION_KEY_BASE_PERIOD_END;
- }
-
- periodGenericManager.setSelectedPeriodIndex( selectedPeriodKey, index );
- periodGenericManager.previousPeriodSpan( selectedPeriodKey, basePeriodKey );
-
- periods = periodGenericManager.getPeriodList( selectedPeriodKey, basePeriodKey );
-
- 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 2012-10-09 03:53:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-10-26 09:02:41 +0000
@@ -266,24 +266,13 @@
scope="prototype">
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
</bean>
-
- <bean
- id="org.hisp.dhis.caseentry.action.caseaggregation.LoadPeriodsAction"
- class="org.hisp.dhis.caseentry.action.caseaggregation.LoadPeriodsAction"
- scope="prototype">
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="periodGenericManager"
- ref="org.hisp.dhis.caseentry.state.PeriodGenericManager" />
- </bean>
-
+
<bean
id="org.hisp.dhis.caseentry.action.caseaggregation.ValidationCaseAggregationAction"
class="org.hisp.dhis.caseentry.action.caseaggregation.ValidationCaseAggregationAction"
scope="prototype">
<property name="selectionTreeManager"
ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
- <property name="periodGenericManager"
- ref="org.hisp.dhis.caseentry.state.PeriodGenericManager" />
</bean>
<bean
@@ -296,8 +285,6 @@
<property name="aggregationConditionService"
ref="org.hisp.dhis.caseaggregation.CaseAggregationConditionService" />
<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
- <property name="periodGenericManager"
- ref="org.hisp.dhis.caseentry.state.PeriodGenericManager" />
</bean>
<bean
@@ -328,24 +315,6 @@
ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
</bean>
- <bean id="org.hisp.dhis.caseentry.state.PeriodGenericManager"
- class="org.hisp.dhis.caseentry.state.DefaultPeriodGenericManager"
- scope="singleton">
- <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
- </bean>
-
- <bean id="org.hisp.dhis.caseentry.state.NextPeriodsAction" class="org.hisp.dhis.caseentry.state.NextPeriodsAction"
- scope="prototype">
- <property name="periodGenericManager"
- ref="org.hisp.dhis.caseentry.state.PeriodGenericManager" />
- </bean>
-
- <bean id="org.hisp.dhis.caseentry.state.PreviousPeriodsAction"
- class="org.hisp.dhis.caseentry.state.PreviousPeriodsAction" scope="prototype">
- <property name="periodGenericManager"
- ref="org.hisp.dhis.caseentry.state.PeriodGenericManager" />
- </bean>
-
<bean
id="org.hisp.dhis.caseentry.action.caseentry.ValidateProgramInstanceAction"
class="org.hisp.dhis.caseentry.action.caseentry.ValidateProgramInstanceAction"
=== 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 2012-10-26 05:42:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-10-26 09:02:41 +0000
@@ -347,13 +347,6 @@
<param name="requiredAuthorities">F_PATIENT_AGGREGATION</param>
</action>
- <action name="loadPeriods"
- class="org.hisp.dhis.caseentry.action.caseaggregation.LoadPeriodsAction">
- <result name="success" type="velocity-json">
- /dhis-web-caseentry/responsePeriods.vm
- </result>
- </action>
-
<action name="validateCaseAggregation"
class="org.hisp.dhis.caseentry.action.caseaggregation.ValidationCaseAggregationAction">
<result name="success" type="velocity-xml">
@@ -390,19 +383,6 @@
<param name="page">/dhis-web-caseentry/caseAggregationResultDetails.vm</param>
</action>
- <action name="nextPeriods" class="org.hisp.dhis.caseentry.state.NextPeriodsAction">
- <result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonPeriods.vm
- </result>
- </action>
-
- <action name="previousPeriods"
- class="org.hisp.dhis.caseentry.state.PreviousPeriodsAction">
- <result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonPeriods.vm
- </result>
- </action>
-
<!-- Patient -->
<action name="patient"
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm 2012-10-26 03:05:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm 2012-10-26 09:02:41 +0000
@@ -15,7 +15,7 @@
$i18n.getString( "dataset_list" )
</td>
<td>
- <select id="dataSetId" name="dataSetId" onchange="dataSetSelected()" style="width: 30em">
+ <select id="dataSetId" name="dataSetId" style="width: 30em">
<option value=''>[$i18n.getString('please_select')]</option>
#foreach ( $dataSet in $datasets )
<option value='$dataSet.id' title='$dataSet.name'>$dataSet.name</option>
@@ -25,25 +25,19 @@
</tr>
<tr>
- <td>
- $i18n.getString( "from" )
- </td>
- <td>
- <input type="button" class='small-button' value="<<" onclick="getPreviousPeriodForStart()" id="previousPeriodForStartBtn" disabled />
- <select id="sDateLB" name="sDateLB" style='width:295px;'></select>
- <input type="button" class='small-button'value=">>" onclick="getNextPeriodForStart()" id="nextPeriodForStartBtn" disabled />
+ <td>$i18n.getString( "from" )</td>
+ <td>
+ <input type='text' id="startDate" name="startDate" style="width:355px;"/>
</td>
</tr>
<tr>
- <td>
- $i18n.getString( "to" )
- </td>
- <td>
- <input type="button" class='small-button' value="<<" onclick="getPreviousPeriodForEnd()" id="previousPeriodForEndBtn" disabled />
- <select id="eDateLB" name="eDateLB" style='width:295px;'></select>
- <input type="button" class='small-button' value=">>" onclick="getNextPeriodForEnd()" id="nextPeriodForEndBtn" disabled />
- <i><span id='warningMessage' style="color:red"></span></i>
+ <td>$i18n.getString( "to" )</td>
+ <td>
+ <input type='text' id="endDate" name="endDate" style="width:355px;"/>
+ <script>
+ datePickerInRange( 'startDate','endDate' );
+ </script>
</td>
</tr>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js 2012-03-05 07:32:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js 2012-10-26 09:02:41 +0000
@@ -1,120 +1,17 @@
-function dataSetSelected()
-{
- var dataSetId = $( '#dataSetId' ).val();
-
- if ( dataSetId && dataSetId != 0 )
- {
- clearListById( 'sDateLB' );
- clearListById( 'eDateLB' );
-
- addOptionById( 'sDateLB', '', '[' + i18n_please_select + ']' );
- addOptionById( 'eDateLB', '', '[' + i18n_please_select + ']' );
-
- $.getJSON( "loadPeriods.action",
- {
- dataSetId:dataSetId
- }
- , function( json )
- {
- for ( i in json.periods ) {
- addOptionById( 'sDateLB', i, json.periods[i].name );
- addOptionById( 'eDateLB', i, json.periods[i].name );
- }
-
- enable('previousPeriodForStartBtn');
- enable('nextPeriodForStartBtn');
- enable('previousPeriodForEndBtn');
- enable('nextPeriodForEndBtn');
- } );
- }
- else
- {
- disable('previousPeriodForStartBtn');
- disable('nextPeriodForStartBtn');
- disable('previousPeriodForEndBtn');
- disable('nextPeriodForEndBtn');
- }
-
-}
-
-function getPreviousPeriodForStart()
-{
- var index = byId('sDateLB').options[byId('sDateLB').selectedIndex].value;
- jQuery.getJSON('previousPeriods.action' ,
- {
- startField: 'true',
- index: index
- }, responseListPeriodForStartReceived );
-}
-
-function getNextPeriodForStart()
-{
- var index = byId('sDateLB').options[byId('sDateLB').selectedIndex].value;
- jQuery.getJSON('nextPeriods.action',
- {
- startField:'true',
- index: index
- }, responseListPeriodForStartReceived );
-}
-
-function responseListPeriodForStartReceived( json )
-{
- clearListById('sDateLB');
-
- jQuery.each( json.periods, function(i, item ){
- addOptionById('sDateLB', i, item.name);
- });
-}
-
-function getPreviousPeriodForEnd()
-{
- var index = byId('eDateLB').options[byId('eDateLB').selectedIndex].value;
- jQuery.getJSON('previousPeriods.action',
- {
- startField: 'false',
- index: index
- }, responseListPeriodForEndReceived );
-}
-
-function getNextPeriodForEnd()
-{
- var index = byId('eDateLB').options[byId('eDateLB').selectedIndex].value;
- jQuery.getJSON('nextPeriods.action',
- {
- startField: 'false',
- index: index
- }, responseListPeriodForEndReceived );
-}
-
-function responseListPeriodForEndReceived( json )
-{
- clearListById('eDateLB');
-
- jQuery.each( json.periods, function(i, item ){
- addOptionById('eDateLB', i, item.name );
- });
-}
-
-function validationCaseAggregation( )
+
+function validationCaseAggregation()
{
$.get( 'validateCaseAggregation.action',
- {
- sDateLB:getFieldValue('sDateLB'),
- eDateLB:getFieldValue('eDateLB')
- }, validationCaseAggregationCompleted, 'xml' );
-
+ {}, validationCaseAggregationCompleted, 'xml' );
}
function validationCaseAggregationCompleted( message )
{
var type = $(message).find('message').attr('type');
-
- if( type == "success" )
- {
+ if( type == "success" ){
caseAggregationResult();
}
- else
- {
+ else{
showWarningMessage( $(message).find('message').text() );
}
}
@@ -147,7 +44,9 @@
$('#caseAggregationResult').load("caseAggregationResult.action",
{
facilityLB: getFieldValue('facilityLB'),
- dataSetId: getFieldValue('dataSetId')
+ dataSetId: getFieldValue('dataSetId'),
+ startDate: getFieldValue('startDate'),
+ endDate: getFieldValue('endDate')
}
, function(){
$( "#loaderDiv" ).hide();