dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23561
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11463: Impl maintenance function for adding missing category option combos
------------------------------------------------------------
revno: 11463
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-07-22 13:47:18 +0200
message:
Impl maintenance function for adding missing category option combos
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/maintenance.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/maintenanceForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/GreySectionAction.java
--
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/dataelement/DataElementCategoryService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2013-05-10 16:29:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2013-07-22 11:47:18 +0000
@@ -400,6 +400,12 @@
void updateOptionCombos( DataElementCategoryCombo categoryCombo );
/**
+ * Generates the complete set of category option combos for all category
+ * combos.
+ */
+ void updateAllOptionCombos();
+
+ /**
* Populates all transient properties on each Operand in the given collection.
*
* @param operands the collection of Operands.
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2013-05-10 16:29:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2013-07-22 11:47:18 +0000
@@ -38,6 +38,8 @@
import java.util.Set;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.GenericDimensionalObjectStore;
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
import org.hisp.dhis.concept.Concept;
@@ -53,6 +55,8 @@
public class DefaultDataElementCategoryService
implements DataElementCategoryService
{
+ private static final Log log = LogFactory.getLog( DefaultDataElementCategoryService.class );
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -540,16 +544,34 @@
List<DataElementCategoryOptionCombo> generatedOptionCombos = categoryCombo.generateOptionCombosList();
Set<DataElementCategoryOptionCombo> persistedOptionCombos = categoryCombo.getOptionCombos();
+ boolean modified = false;
+
for ( DataElementCategoryOptionCombo optionCombo : generatedOptionCombos )
{
if ( !persistedOptionCombos.contains( optionCombo ) )
- {
+ {
categoryCombo.getOptionCombos().add( optionCombo );
addDataElementCategoryOptionCombo( optionCombo );
+
+ log.info( "Added missing category option combo: " + optionCombo + " for category combo: " + categoryCombo.getName() );
+ modified = true;
}
}
- updateDataElementCategoryCombo( categoryCombo );
+ if ( modified )
+ {
+ updateDataElementCategoryCombo( categoryCombo );
+ }
+ }
+
+ public void updateAllOptionCombos()
+ {
+ Collection<DataElementCategoryCombo> categoryCombos = getAllDataElementCategoryCombos();
+
+ for ( DataElementCategoryCombo categoryCombo : categoryCombos )
+ {
+ updateOptionCombos( categoryCombo );
+ }
}
public Map<String, Integer> getDataElementCategoryOptionComboUidIdMap()
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java 2013-06-19 13:43:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java 2013-07-22 11:47:18 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.analytics.AnalyticsTableService;
import org.hisp.dhis.common.DeleteNotAllowedException;
import org.hisp.dhis.completeness.DataSetCompletenessService;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.datamart.DataMartManager;
import org.hisp.dhis.maintenance.MaintenanceService;
import org.hisp.dhis.period.Period;
@@ -106,6 +107,13 @@
{
this.currentUserService = currentUserService;
}
+
+ private DataElementCategoryService categoryService;
+
+ public void setCategoryService( DataElementCategoryService categoryService )
+ {
+ this.categoryService = categoryService;
+ }
// -------------------------------------------------------------------------
// Input
@@ -153,6 +161,13 @@
this.prunePeriods = prunePeriods;
}
+ private boolean updateCategoryOptionCombos;
+
+ public void setUpdateCategoryOptionCombos( boolean updateCategoryOptionCombos )
+ {
+ this.updateCategoryOptionCombos = updateCategoryOptionCombos;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -160,6 +175,8 @@
public String execute()
throws Exception
{
+ String username = currentUserService.getCurrentUsername();
+
if ( clearAnalytics )
{
analyticsTableService.dropTables();
@@ -172,7 +189,7 @@
aggregatedDataValueService.dropDataMart();
aggregatedDataValueService.createDataMart();
- log.info( "'" + currentUserService.getCurrentUsername() + "': Cleared data mart" );
+ log.info( "'" + username + "': Cleared data mart" );
}
if ( dataMartIndex )
@@ -190,7 +207,7 @@
completenessService.dropIndex();
completenessService.createIndex();
- log.info( "'" + currentUserService.getCurrentUsername() + "': Rebuilt data mart indexes" );
+ log.info( "'" + username + "': Rebuilt data mart indexes" );
}
if ( zeroValues )
@@ -204,14 +221,21 @@
{
completenessService.deleteDataSetCompleteness();
- log.info( "'" + currentUserService.getCurrentUsername() + "': Cleared data completeness" );
+ log.info( "'" + username + "': Cleared data completeness" );
}
if ( prunePeriods )
{
prunePeriods();
- log.info( "'" + currentUserService.getCurrentUsername() + "': Pruned periods" );
+ log.info( "'" + username + "': Pruned periods" );
+ }
+
+ if ( updateCategoryOptionCombos )
+ {
+ categoryService.updateAllOptionCombos();
+
+ log.info( "'" + username + "': Updated category option combos" );
}
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2013-06-19 13:43:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2013-07-22 11:47:18 +0000
@@ -14,6 +14,7 @@
<property name="dataMartManager" ref="org.hisp.dhis.datamart.DataMartManager" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
</bean>
<!-- Resource table -->
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2013-05-27 15:33:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2013-07-22 11:47:18 +0000
@@ -320,4 +320,5 @@
generating_min_max_values=Generating min-max values
done=Done
period_structure=Period structure
- data_element_category_option_combo=Data element category option combinations
\ No newline at end of file
+data_element_category_option_combo=Data element category option combinations
+update_category_option_combos=Update category option combinations
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/maintenance.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/maintenance.js 2013-04-22 08:10:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/maintenance.js 2013-07-22 11:47:18 +0000
@@ -7,8 +7,9 @@
var zeroValues = document.getElementById( "zeroValues" ).checked;
var dataSetCompleteness = document.getElementById( "dataSetCompleteness" ).checked;
var prunePeriods = document.getElementById( "prunePeriods" ).checked;
+ var updateCategoryOptionCombos = document.getElementById( "updateCategoryOptionCombos" ).checked;
- if ( clearAnalytics || clearDataMart || dataMartIndex || zeroValues || dataSetCompleteness || prunePeriods )
+ if ( clearAnalytics || clearDataMart || dataMartIndex || zeroValues || dataSetCompleteness || prunePeriods || updateCategoryOptionCombos )
{
setWaitMessage( i18n_performing_maintenance );
@@ -17,7 +18,8 @@
"&dataMartIndex=" + dataMartIndex +
"&zeroValues=" + zeroValues +
"&dataSetCompleteness=" + dataSetCompleteness +
- "&prunePeriods=" + prunePeriods;
+ "&prunePeriods=" + prunePeriods +
+ "&updateCategoryOptionCombos=" + updateCategoryOptionCombos;
$.ajax({
type: "POST",
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/maintenanceForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/maintenanceForm.vm 2013-04-22 08:10:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/maintenanceForm.vm 2013-07-22 11:47:18 +0000
@@ -43,6 +43,11 @@
</p>
<p>
+ <input type="checkbox" id="updateCategoryOptionCombos"/>
+ <label for="updateCategoryOptionCombos">$i18n.getString( "update_category_option_combos" )</label>
+</p>
+
+<p>
<input type="button" value="Select all" id="selectAllButton" style="width:100px">
<input type="button" value="$i18n.getString( 'perform_maintenance' )" onclick="performMaintenance()" style="width:170px"/>
</p>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/GreySectionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/GreySectionAction.java 2013-07-20 11:17:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/GreySectionAction.java 2013-07-22 11:47:18 +0000
@@ -112,7 +112,7 @@
return sectionIsMultiDimensional;
}
- Map<Integer, Collection<DataElementCategoryOption>> optionsMap = new HashMap<Integer, Collection<DataElementCategoryOption>>();
+ private Map<Integer, Collection<DataElementCategoryOption>> optionsMap = new HashMap<Integer, Collection<DataElementCategoryOption>>();
public Map<Integer, Collection<DataElementCategoryOption>> getOptionsMap()
{