dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19705
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8708: Remove period-type params in scheduling case aggregate query builder.
------------------------------------------------------------
revno: 8708
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-10-25 20:31:14 +0700
message:
Remove period-type params in scheduling case aggregate query builder.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleAggQueryBuilderParamsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm
--
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/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2012-10-25 04:06:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2012-10-25 13:31:14 +0000
@@ -73,7 +73,6 @@
final String KEY_SCHEDULE_MESSAGE_TASKS = "scheduleMessage";
final String KEY_PHONE_NUMBER_AREA_CODE = "phoneNumberAreaCode";
final String KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS = "scheduleAggregateQueryBuilder";
- final String KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE = "keyScheduledAggregateQueryBuilderPeriodType";
final String KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL = "aggQueryBuilderorgUnitGroupSetAggregationLevel";
final String KEY_CONFIGURATION = "keyConfig";
@@ -87,7 +86,6 @@
final int DEFAULT_COMPLETENESS_OFFSET = 15;
final String DEFAULT_TIME_FOR_SENDING_MESSAGE = "08:00";
- final String DEFAULT_SCHEDULED_CASE_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES = MonthlyPeriodType.NAME;
final HashSet<String> DEFAULT_SCHEDULED_PERIOD_TYPES = new HashSet<String>() { {
add( MonthlyPeriodType.NAME );
add( QuarterlyPeriodType.NAME );
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java 2012-10-25 04:06:54 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java 2012-10-25 13:31:14 +0000
@@ -29,12 +29,12 @@
import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_ORGUNITGROUPSET_AGG_LEVEL;
import static org.hisp.dhis.setting.SystemSettingManager.KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE;
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 java.util.Set;
@@ -44,11 +44,14 @@
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.period.RelativePeriods;
import org.hisp.dhis.setting.SystemSettingManager;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -77,11 +80,13 @@
private DataElementService dataElementService;
private DataElementCategoryService categoryService;
-
+
+ private DataSetService dataSetService;
+
// -------------------------------------------------------------------------
// Params
// -------------------------------------------------------------------------
-
+
private boolean last6Months;
public void setLast6Months( boolean last6Months )
@@ -103,7 +108,7 @@
public CaseAggregateConditionTask( OrganisationUnitService organisationUnitService,
CaseAggregationConditionService aggregationConditionService, DataValueService dataValueService,
SystemSettingManager systemSettingManager, JdbcTemplate jdbcTemplate, DataElementService dataElementService,
- DataElementCategoryService categoryService )
+ DataElementCategoryService categoryService, DataSetService dataSetService )
{
this.organisationUnitService = organisationUnitService;
this.aggregationConditionService = aggregationConditionService;
@@ -112,6 +117,7 @@
this.jdbcTemplate = jdbcTemplate;
this.dataElementService = dataElementService;
this.categoryService = categoryService;
+ this.dataSetService = dataSetService;
}
// -------------------------------------------------------------------------
@@ -125,83 +131,88 @@
KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL, DEFAULT_ORGUNITGROUPSET_AGG_LEVEL );
Collection<OrganisationUnit> orgunits = organisationUnitService.getOrganisationUnitsAtLevel( level );
- Collection<CaseAggregationCondition> aggConditions = aggregationConditionService
- .getAllCaseAggregationCondition();
-
// ---------------------------------------------------------------------
// Get Period list in system-setting
// ---------------------------------------------------------------------
- String periodType = (String) systemSettingManager.getSystemSetting(
- KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE, KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE );
-
- List<Period> periods = getPeriods( periodType );
-
- // ---------------------------------------------------------------------
- // Aggregation
- // ---------------------------------------------------------------------
+ Collection<DataSet> dataSets = dataSetService.getAllDataSets();
- for ( OrganisationUnit orgUnit : orgunits )
+ for ( DataSet dataSet : dataSets )
{
- for ( CaseAggregationCondition aggCondition : aggConditions )
+ String periodType = dataSet.getPeriodType().getName();
+ List<Period> periods = getPeriods( periodType );
+
+ String sql = "select caseaggregationconditionid, aggregationdataelementid, optioncomboid "
+ + "from caseaggregationcondition cagg inner join datasetmembers dm "
+ + "on cagg.aggregationdataelementid=dm.dataelementid " + "inner join dataset ds "
+ + "on ds.datasetid = dm.datasetid " + "inner join periodtype pt "
+ + "on pt.periodtypeid=ds.periodtypeid " + "where ds.datasetid = " + dataSet.getId();
+
+ SqlRowSet rs = jdbcTemplate.queryForRowSet( sql );
+
+ while ( rs.next() )
{
// -------------------------------------------------------------
- // Get agg-dataelement and option-combo
+ // Get formula, agg-dataelement and option-combo
// -------------------------------------------------------------
- String sql = "select aggregationdataelementid, optioncomboid from caseaggregationcondition where caseaggregationconditionid="
- + aggCondition.getId();
- SqlRowSet rs = jdbcTemplate.queryForRowSet( sql );
- rs.next();
int dataelementId = rs.getInt( "aggregationdataelementid" );
int optionComboId = rs.getInt( "optioncomboid" );
- // -------------------------------------------------------------
- // Get agg-dataelement and option-combo
- // -------------------------------------------------------------
-
DataElement dElement = dataElementService.getDataElement( dataelementId );
DataElementCategoryOptionCombo optionCombo = categoryService
.getDataElementCategoryOptionCombo( optionComboId );
- for ( Period period : periods )
+ CaseAggregationCondition aggCondition = aggregationConditionService.getCaseAggregationCondition( rs
+ .getInt( "caseaggregationconditionid" ) );
+
+ // ---------------------------------------------------------------------
+ // Aggregation
+ // ---------------------------------------------------------------------
+
+ for ( OrganisationUnit orgUnit : orgunits )
{
- Double resultValue = aggregationConditionService.parseConditition( aggCondition, orgUnit, period );
-
- DataValue dataValue = dataValueService.getDataValue( orgUnit, dElement, period, optionCombo );
-
- if ( resultValue != null && resultValue != 0.0 )
- {
- // -----------------------------------------------------
- // Add dataValue
- // -----------------------------------------------------
- if ( dataValue == null )
- {
- dataValue = new DataValue( dElement, period, orgUnit, "" + resultValue, "", new Date(),
- null, optionCombo );
- dataValueService.addDataValue( dataValue );
- }
- // -----------------------------------------------------
- // Update dataValue
- // -----------------------------------------------------
- else
- {
- dataValue.setValue( "" + resultValue );
- dataValue.setTimestamp( new Date() );
- sql = "UPDATE datavalue" + " SET value='" + resultValue + "',lastupdated='" + new Date() + "' where dataelementId="
- + dataelementId + " and periodid=" + period.getId() + " and sourceid="
- + orgUnit.getId() + " and categoryoptioncomboid=" + optionComboId + " and storedby='"
- + STORED_BY_DHIS_SYSTEM + "'";
- jdbcTemplate.execute( sql );
- }
- }
-
- // ---------------------------------------------------------
- // Delete dataValue
- // ---------------------------------------------------------
- else if ( dataValue != null )
- {
- dataValueService.deleteDataValue( dataValue );
+ for ( Period period : periods )
+ {
+ Double resultValue = aggregationConditionService.parseConditition( aggCondition, orgUnit,
+ period );
+
+ DataValue dataValue = dataValueService.getDataValue( orgUnit, dElement, period, optionCombo );
+
+ if ( resultValue != null && resultValue != 0.0 )
+ {
+ // -----------------------------------------------------
+ // Add dataValue
+ // -----------------------------------------------------
+ if ( dataValue == null )
+ {
+ dataValue = new DataValue( dElement, period, orgUnit, "" + resultValue, "", new Date(),
+ null, optionCombo );
+ dataValueService.addDataValue( dataValue );
+ }
+ // -----------------------------------------------------
+ // Update dataValue
+ // -----------------------------------------------------
+ else
+ {
+ dataValue.setValue( "" + resultValue );
+ dataValue.setTimestamp( new Date() );
+ sql = "UPDATE datavalue" + " SET value='" + resultValue + "',lastupdated='"
+ + new Date() + "' where dataelementId=" + dataelementId + " and periodid="
+ + period.getId() + " and sourceid=" + orgUnit.getId()
+ + " and categoryoptioncomboid=" + optionComboId + " and storedby='"
+ + STORED_BY_DHIS_SYSTEM + "'";
+ jdbcTemplate.execute( sql );
+ }
+ }
+
+ // ---------------------------------------------------------
+ // Delete dataValue
+ // ---------------------------------------------------------
+ else if ( dataValue != null )
+ {
+ dataValueService.deleteDataValue( dataValue );
+ }
}
}
}
@@ -216,7 +227,7 @@
{
Set<String> periodTypes = new HashSet<String>();
periodTypes.add( periodType );
-
+
List<Period> relatives = new ArrayList<Period>();
if ( last6Months )
@@ -229,6 +240,15 @@
relatives.addAll( new RelativePeriods().getLast6To12Months( periodTypes ) );
}
+ Iterator<Period> iter = relatives.iterator();
+ Date currentDate = new Date();
+ while(iter.hasNext())
+ {
+ if(currentDate.before( iter.next().getEndDate() ))
+ {
+ iter.remove();
+ }
+ }
return relatives;
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2012-10-16 04:05:28 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2012-10-25 13:31:14 +0000
@@ -442,6 +442,7 @@
<constructor-arg ref="jdbcTemplate" />
<constructor-arg ref="org.hisp.dhis.dataelement.DataElementService" />
<constructor-arg ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+ <constructor-arg ref="org.hisp.dhis.dataset.DataSetService" />
</bean>
<bean id="aggregateLast12MonthsTask" class="org.hisp.dhis.patient.scheduling.CaseAggregateConditionTask"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleAggQueryBuilderParamsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleAggQueryBuilderParamsAction.java 2012-10-25 04:06:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleAggQueryBuilderParamsAction.java 2012-10-25 13:31:14 +0000
@@ -28,9 +28,7 @@
package org.hisp.dhis.patient.action.schedule;
import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_ORGUNITGROUPSET_AGG_LEVEL;
-import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_SCHEDULED_CASE_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES;
import static org.hisp.dhis.setting.SystemSettingManager.KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE;
import java.util.List;
@@ -130,9 +128,6 @@
public String execute()
throws Exception
{
- scheduledPeriodType = (String) systemSettingManager.getSystemSetting(
- KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE, DEFAULT_SCHEDULED_CASE_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES );
-
orgUnitGroupSetAggLevel = (Integer) systemSettingManager.getSystemSetting(
KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL, DEFAULT_ORGUNITGROUPSET_AGG_LEVEL );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java 2012-10-25 04:06:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java 2012-10-25 13:31:14 +0000
@@ -28,7 +28,6 @@
package org.hisp.dhis.patient.action.schedule;
import static org.hisp.dhis.setting.SystemSettingManager.KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE;
import java.util.HashMap;
import java.util.Map;
@@ -80,13 +79,6 @@
this.execute = execute;
}
- private String scheduledPeriodType;
-
- public void setScheduledPeriodType( String scheduledPeriodType )
- {
- this.scheduledPeriodType = scheduledPeriodType;
- }
-
private Integer orgUnitGroupSetAggLevel;
public void setOrgUnitGroupSetAggLevel( Integer orgUnitGroupSetAggLevel )
@@ -118,7 +110,7 @@
{
return running;
}
-
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -133,7 +125,6 @@
}
else
{
- systemSettingManager.saveSystemSetting( KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE, scheduledPeriodType );
systemSettingManager.saveSystemSetting( KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL,
orgUnitGroupSetAggLevel );
@@ -163,7 +154,7 @@
schedulingManager.scheduleTasks( keyCronMap );
}
}
-
+
status = schedulingManager.getTaskStatus();
running = Scheduler.STATUS_RUNNING.equals( status );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js 2012-10-25 04:06:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js 2012-10-25 13:31:14 +0000
@@ -46,8 +46,7 @@
$.post( 'scheduleCaseAggTasks.action',{
execute:false,
orgUnitGroupSetAggLevel:getFieldValue("orgUnitGroupSetAggLevel"),
- aggQueryBuilderStrategy:getFieldValue("aggQueryBuilderStrategy"),
- scheduledPeriodType: jQuery("[name=scheduledPeriodType]:checked").val()
+ aggQueryBuilderStrategy:getFieldValue("aggQueryBuilderStrategy")
}, function( json ){
var status = json.scheduleTasks.status;
if( status=='not_started' ){
@@ -72,8 +71,7 @@
$.post( 'scheduleCaseAggTasks.action',{
execute:true,
orgUnitGroupSetAggLevel:getFieldValue("orgUnitGroupSetAggLevel"),
- aggQueryBuilderStrategy:getFieldValue("aggQueryBuilderStrategy"),
- scheduledPeriodType: jQuery("[name=scheduledPeriodType]:checked").val()
+ aggQueryBuilderStrategy:getFieldValue("aggQueryBuilderStrategy")
},function( json ){
setMessage(i18n_execute_success);
});
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm 2012-10-25 04:06:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm 2012-10-25 13:31:14 +0000
@@ -18,24 +18,6 @@
<table>
<tr>
- <th>$i18n.getString( "aggregation_period_types" )</th>
-</tr>
-<tr>
- <td>
- <label for="weekly">$i18n.getString( "Weekly" )</label><input type="radio" id="weekly" class="scheduling" name="scheduledPeriodType" value="Weekly"#if( $scheduledPeriodType.contains( "Weekly" ) ) checked="checked"#end>
- <label for="monthly">$i18n.getString( "Monthly" )</label><input type="radio" id="monthly" class="scheduling" name="scheduledPeriodType" value="Monthly"#if( $scheduledPeriodType.contains( "Monthly" ) ) checked="checked"#end>
- <label for="biMonthly">$i18n.getString( "BiMonthly" )</label><input type="radio" id="biMonthly" class="scheduling" name="scheduledPeriodType" value="BiMonthly"#if( $scheduledPeriodType.contains( "BiMonthly" ) ) checked="checked"#end>
- <label for="quarterly">$i18n.getString( "Quarterly" )</label><input type="radio" id="quarterly" class="scheduling" name="scheduledPeriodType" value="Quarterly"#if( $scheduledPeriodType.contains( "Quarterly" ) ) checked="checked"#end>
- </td>
-</tr>
-<tr>
- <td>
- <label for="sixMonthly">$i18n.getString( "SixMonthly" )</label><input type="radio" id="sixMonthly" class="scheduling" name="scheduledPeriodType" value="SixMonthly"#if( $scheduledPeriodTypes.contains( "SixMonthly" ) ) checked="checked"#end>
- <label for="yearly">$i18n.getString( "Yearly" )</label><input type="radio" id="yearly" class="scheduling" name="scheduledPeriodType" value="Yearly"#if( $scheduledPeriodTypes.contains( "Yearly" ) ) checked="checked"#end>
- <label for="financialYearly">$i18n.getString( "financial_yearly" )</label><input type="radio" id="financialYearly" class="scheduling" name="scheduledPeriodType" value="FinancialJuly"#if( $scheduledPeriodTypes.contains( "FinancialJuly" ) ) checked="checked"#end>
- </td>
-</tr>
-<tr>
<td style="height:10px"></td>
</tr>
<tr>