← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1921: Fixed bug <https://bugs.launchpad.net/bugs/586680>

 

------------------------------------------------------------
revno: 1921
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-05-28 16:12:03 +0700
message:
  Fixed bug <https://bugs.launchpad.net/bugs/586680>
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml


--
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/dataset/DataSetService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java	2010-05-28 09:12:03 +0000
@@ -99,7 +99,7 @@
      * @return The DataSet with the given code.
      */
     DataSet getDataSetByCode( String code );
-    
+
     /**
      * Returns all DataSets associated with the specified source.
      */
@@ -109,13 +109,13 @@
      * Returns all DataSets associated with the specified sources.
      */
     Collection<DataSet> getDataSetsBySources( Collection<? extends Source> sources );
-    
+
     /**
      * Returns the number of Sources among the specified Sources associated with
      * the specified DataSet.
      */
     int getSourcesAssociatedWithDataSet( DataSet dataSet, Collection<? extends Source> sources );
-    
+
     /**
      * Get all DataSets.
      * 
@@ -147,33 +147,35 @@
     List<DataSet> getAvailableDataSets();
 
     /**
-     * Get list of assigned (ie. which had corresponding dataentryform) datasets.
+     * Get list of assigned (ie. which had corresponding dataentryform)
+     * datasets.
      * 
      * @return A List containing assigned DataSets.
      */
     List<DataSet> getAssignedDataSets();
-    
+
     /**
-     * Get list of assigned (ie. which had corresponding dataentryform) datasets for specific period type.
+     * Get list of assigned (ie. which had corresponding dataentryform) datasets
+     * for specific period type.
      * 
      * @return A List containing assigned DataSets for specific period type.
      */
     List<DataSet> getAssignedDataSetsByPeriodType( PeriodType periodType );
-    
+
     /**
      * Searches through the data sets with the corresponding given identifiers.
-     * If the given data element is a member of one of the data sets, that
-     * data sets period type is returned. This implies that if the data element
-     * is a member of more than one data set, which period type being returned
-     * is undefined. If null is passed as the second argument, all data sets
-     * will be searched. 
+     * If the given data element is a member of one of the data sets, that data
+     * sets period type is returned. This implies that if the data element is a
+     * member of more than one data set, which period type being returned is
+     * undefined. If null is passed as the second argument, all data sets will
+     * be searched.
      * 
      * @param dataElement the data element to find the period type for.
      * @param dataSetIdentifiers the data set identifiers to search through.
      * @return the period type of the given data element.
      */
     PeriodType getPeriodType( DataElement dataElement, Collection<Integer> dataSetIdentifiers );
-    
+
     /**
      * Returns a distinct collection of data elements associated with the data
      * sets with the given corresponding data set identifiers.
@@ -182,7 +184,16 @@
      * @return a distinct collection of data elements.
      */
     Collection<DataElement> getDistinctDataElements( Collection<Integer> dataSetIdentifiers );
-    
+
+    /**
+     * Returns a collection of data elements associated with the given
+     * corresponding data set.
+     * 
+     * @param dataSet the data set object.
+     * @return a collection of data elements.
+     */
+    Collection<DataElement> getDataElements( DataSet dataSet );
+
     // -------------------------------------------------------------------------
     // FrequencyOverrideAssociation
     // -------------------------------------------------------------------------
@@ -238,6 +249,6 @@
      * @return A collection of FrequencyOverrideAssociations for the given
      *         Source.
      */
-    Collection<FrequencyOverrideAssociation> getFrequencyOverrideAssociationsBySource( Source source );       
-    
+    Collection<FrequencyOverrideAssociation> getFrequencyOverrideAssociationsBySource( Source source );
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2010-04-19 09:54:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2010-05-28 09:12:03 +0000
@@ -58,6 +58,7 @@
     implements DataSetService
 {
     private Logger logger = Logger.getLogger( getClass() );
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -82,15 +83,14 @@
     {
         i18nService = service;
     }
-    
+
     private CurrentUserService currentUserService;
-    
+
     public void setCurrentUserService( CurrentUserService currentUserService )
     {
         this.currentUserService = currentUserService;
     }
 
-
     // -------------------------------------------------------------------------
     // DataSet
     // -------------------------------------------------------------------------
@@ -100,26 +100,20 @@
         int id = dataSetStore.addDataSet( dataSet );
 
         i18nService.addObject( dataSet );
-        
-        logger.log( AuditLogLevel.AUDIT_TRAIL, 
-            AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
-            AuditLogUtil.ACTION_ADD , 
-            DataSet.class.getSimpleName(), 
-            dataSet.getName()) );
-        
+
+        logger.log( AuditLogLevel.AUDIT_TRAIL, AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
+            AuditLogUtil.ACTION_ADD, DataSet.class.getSimpleName(), dataSet.getName() ) );
+
         return id;
     }
 
     public void updateDataSet( DataSet dataSet )
     {
         dataSetStore.updateDataSet( dataSet );
-        
-        logger.log( AuditLogLevel.AUDIT_TRAIL, 
-            AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
-            AuditLogUtil.ACTION_EDIT, 
-            DataSet.class.getSimpleName(), 
-            dataSet.getName()) );
-        
+
+        logger.log( AuditLogLevel.AUDIT_TRAIL, AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
+            AuditLogUtil.ACTION_EDIT, DataSet.class.getSimpleName(), dataSet.getName() ) );
+
         i18nService.verify( dataSet );
     }
 
@@ -128,12 +122,9 @@
         i18nService.removeObject( dataSet );
 
         dataSetStore.deleteDataSet( dataSet );
-        
-        logger.log( AuditLogLevel.AUDIT_TRAIL, 
-            AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
-            AuditLogUtil.ACTION_DELETE, 
-            DataSet.class.getSimpleName(), 
-            dataSet.getName()) );
+
+        logger.log( AuditLogLevel.AUDIT_TRAIL, AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
+            AuditLogUtil.ACTION_DELETE, DataSet.class.getSimpleName(), dataSet.getName() ) );
     }
 
     public DataSet getDataSet( int id )
@@ -287,7 +278,8 @@
 
         for ( DataSet dataSet : dataSetListByPeriodType )
         {
-            // DataEntryForm dataEntryForm = dataEntryFormService.getDataEntryFormByDataSet( dataSet );
+            // DataEntryForm dataEntryForm =
+            // dataEntryFormService.getDataEntryFormByDataSet( dataSet );
 
             if ( dataSet.getSources() != null )
             {
@@ -297,7 +289,7 @@
 
         return assignedDataSetListByPeriodType;
     }
-   
+
     public Collection<DataElement> getDistinctDataElements( Collection<Integer> dataSetIdentifiers )
     {
         Collection<DataSet> dataSets = getDataSets( dataSetIdentifiers );
@@ -312,6 +304,11 @@
         return dataElements;
     }
 
+    public Collection<DataElement> getDataElements( DataSet dataSet )
+    {
+        return i18n( i18nService, dataSet.getDataElements() );
+    }
+
     // -------------------------------------------------------------------------
     // FrequencyOverrideAssociation
     // -------------------------------------------------------------------------
@@ -344,5 +341,6 @@
     public Collection<FrequencyOverrideAssociation> getFrequencyOverrideAssociationsBySource( Source source )
     {
         return dataSetStore.getFrequencyOverrideAssociationsBySource( source );
-    }   
+    }
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2010-05-28 09:12:03 +0000
@@ -46,6 +46,7 @@
 import org.hisp.dhis.datalock.DataSetLock;
 import org.hisp.dhis.datalock.DataSetLockService;
 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.de.comments.StandardCommentsManager;
@@ -147,21 +148,28 @@
     {
         this.i18n = i18n;
     }
-    
+
     private DataSetLockService dataSetLockService;
-    
-    public void setDataSetLockService( DataSetLockService dataSetLockService)
+
+    public void setDataSetLockService( DataSetLockService dataSetLockService )
     {
         this.dataSetLockService = dataSetLockService;
     }
 
     private DataElementCategoryService categoryService;
-    
+
     public void setCategoryService( DataElementCategoryService categoryService )
     {
         this.categoryService = categoryService;
     }
 
+    private DataSetService dataSetService;
+
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
     // -------------------------------------------------------------------------
     // DisplayPropertyHandler
     // -------------------------------------------------------------------------
@@ -311,13 +319,13 @@
         Period period = selectedStateManager.getSelectedPeriod();
 
         DataSetLock dataSetLock = dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period );
-        
+
         if ( dataSetLock != null && dataSetLock.getSources().contains( organisationUnit ) )
         {
             disabled = "disabled";
         }
 
-        Collection<DataElement> dataElements = dataSet.getDataElements();
+        Collection<DataElement> dataElements = new ArrayList<DataElement>( dataSetService.getDataElements( dataSet ) );
 
         if ( dataElements.size() == 0 )
         {
@@ -325,14 +333,15 @@
         }
 
         DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
-        
+
         optionComboId = defaultOptionCombo.getId();
 
         // ---------------------------------------------------------------------
         // Get the min/max values
         // ---------------------------------------------------------------------
 
-        Collection<MinMaxDataElement> minMaxDataElements = minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataElements );
+        Collection<MinMaxDataElement> minMaxDataElements = minMaxDataElementService.getMinMaxDataElements(
+            organisationUnit, dataElements );
 
         minMaxMap = new HashMap<Integer, MinMaxDataElement>( minMaxDataElements.size() );
 
@@ -358,7 +367,8 @@
         // Prepare values for unsaved CalculatedDataElements
         // ---------------------------------------------------------------------
 
-        calculatedValueMap = dataEntryScreenManager.populateValuesForCalculatedDataElements( organisationUnit, dataSet, period );
+        calculatedValueMap = dataEntryScreenManager.populateValuesForCalculatedDataElements( organisationUnit, dataSet,
+            period );
 
         // ---------------------------------------------------------------------
         // Make the standard comments available

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.java	2010-05-28 09:12:03 +0000
@@ -40,6 +40,7 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.dataset.SectionService;
 import org.hisp.dhis.dataset.comparator.SectionOrderComparator;
@@ -127,6 +128,13 @@
         this.i18n = i18n;
     }
 
+    private DataSetService dataSetService;
+
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -230,7 +238,7 @@
 
         Period period = selectedStateManager.getSelectedPeriod();
 
-        Collection<DataElement> dataElements = dataSet.getDataElements();
+        Collection<DataElement> dataElements = new ArrayList<DataElement>( dataSetService.getDataElements( dataSet ) );
 
         if ( dataElements.size() == 0 )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java	2010-05-28 09:12:03 +0000
@@ -53,6 +53,7 @@
 import org.hisp.dhis.datalock.DataSetLock;
 import org.hisp.dhis.datalock.DataSetLockService;
 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.de.comments.StandardCommentsManager;
@@ -168,6 +169,13 @@
         this.dataSetLockService = dataSetLockService;
     }
 
+    private DataSetService dataSetService;
+
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
     // -------------------------------------------------------------------------
     // Comparator
     // -------------------------------------------------------------------------
@@ -385,7 +393,7 @@
             disabled = "disabled";
         }
 
-        List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
+        List<DataElement> dataElements = new ArrayList<DataElement>( dataSetService.getDataElements( dataSet ) );
 
         if ( dataElements.isEmpty() )
         {
@@ -442,7 +450,7 @@
                 if ( !cat.getCategoryOptions().isEmpty() )
                 {
                     catColSpan = catColSpan / cat.getCategoryOptions().size();
-                    int total = optionCombos.size() / ( catColSpan * cat.getCategoryOptions().size() );
+                    int total = optionCombos.size() / (catColSpan * cat.getCategoryOptions().size());
                     Collection<Integer> cols = new ArrayList<Integer>( total );
 
                     for ( int i = 0; i < total; i++ )
@@ -451,9 +459,9 @@
                     }
 
                     /*
-                     * TODO Cols are made to be a collection simply to facilitate a
-                     * for loop in the velocity template - there should be a better
-                     * way of "for" doing a loop.
+                     * TODO Cols are made to be a collection simply to
+                     * facilitate a for loop in the velocity template - there
+                     * should be a better way of "for" doing a loop.
                      */
 
                     colRepeat.put( cat.getId(), cols );
@@ -526,7 +534,7 @@
 
         dataEntryForm = dataEntryFormService.getDataEntryFormByDataSet( dataSet );
 
-        cdeFormExists = ( dataEntryForm != null );
+        cdeFormExists = (dataEntryForm != null);
 
         if ( cdeFormExists )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2010-05-17 14:19:14 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2010-05-28 09:12:03 +0000
@@ -75,6 +75,7 @@
 		<property name="dataSetLockService" ref="org.hisp.dhis.datalock.DataSetLockService" />
 		<property name="dataElementOrderManager"
 			ref="org.hisp.dhis.order.manager.DataElementOrderManager" />
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
 		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
 		<property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
 		<property name="standardCommentsManager"
@@ -95,6 +96,7 @@
 		<property name="dataSetLockService" ref="org.hisp.dhis.datalock.DataSetLockService" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />    
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />    
 		<property name="dataEntryScreenManager"
 			ref="org.hisp.dhis.de.screen.DataEntryScreenManager" />
 		<property name="standardCommentsManager"
@@ -111,6 +113,7 @@
 
 	<bean id="org.hisp.dhis.de.action.SectionFormAction" class="org.hisp.dhis.de.action.SectionFormAction"
 		scope="prototype">
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
 		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="standardCommentsManager"

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2010-03-17 06:25:32 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2010-05-28 09:12:03 +0000
@@ -56,7 +56,7 @@
 				../dhis-web-commons/calendar/calendar-setup.js,
 				../dhis-web-commons/util/validate/jquery.validate.js,../dhis-web-commons/util/jquery.metadata.js
       		,../dhis-web-commons/util/validate/additional-methods.js,../dhis-web-commons/util/validate/messages_locale.js
-      </param>
+			</param>
 			<param name="stylesheets">style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>
 		</action>
 
@@ -73,7 +73,7 @@
 				../dhis-web-commons/calendar/calendar-lang.js,
 				../dhis-web-commons/calendar/calendar-setup.js,../dhis-web-commons/util/validate/jquery.validate.js,../dhis-web-commons/util/jquery.metadata.js
       		,../dhis-web-commons/util/validate/additional-methods.js,../dhis-web-commons/util/validate/messages_locale.js
-      </param>
+			</param>
 			<param name="stylesheets">style/dhis-web-dataentry.css</param>
 		</action>
 
@@ -90,7 +90,7 @@
 				../dhis-web-commons/calendar/calendar.js,
 				../dhis-web-commons/calendar/calendar-lang.js,
 				../dhis-web-commons/calendar/calendar-setup.js
-      </param>
+			</param>
 			<param name="stylesheets">style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>
 		</action>