← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1365: Minor fix

 

------------------------------------------------------------
revno: 1365
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-01-28 21:03:16 +0100
message:
  Minor fix
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/history/DefaultHistoryRetriever.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/period/PeriodService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java	2010-01-28 19:59:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java	2010-01-28 20:03:16 +0000
@@ -233,7 +233,7 @@
      * @param historyLength the number of Periods in the provided collection.
      * @return a collection of Periods.
      */
-    Collection<Period> getPeriods( Period lastPeriod, int historyLength );
+    List<Period> getPeriods( Period lastPeriod, int historyLength );
     
     // -------------------------------------------------------------------------
     // PeriodType

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java	2010-01-28 19:59:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java	2010-01-28 20:03:16 +0000
@@ -296,7 +296,7 @@
         return period;
     }
     
-    public Collection<Period> getPeriods( Period lastPeriod, int historyLength )
+    public List<Period> getPeriods( Period lastPeriod, int historyLength )
     {
         List<Period> periods = new ArrayList<Period>( historyLength );
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/history/DefaultHistoryRetriever.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/history/DefaultHistoryRetriever.java	2010-01-28 18:24:22 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/history/DefaultHistoryRetriever.java	2010-01-28 20:03:16 +0000
@@ -27,8 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
 import org.hisp.dhis.dataelement.DataElement;
@@ -38,7 +36,6 @@
 import org.hisp.dhis.minmax.MinMaxDataElement;
 import org.hisp.dhis.minmax.MinMaxDataElementService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.CalendarPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 
@@ -108,7 +105,7 @@
         // Create history points
         // ---------------------------------------------------------------------
 
-        List<Period> periods = getPeriods( lastPeriod, historyLength );
+        List<Period> periods = periodService.getPeriods( lastPeriod, historyLength );
 
         double max = 1;
         double average = 0;
@@ -232,35 +229,6 @@
         return value;
     }
 
-    private List<Period> getPeriods( Period lastPeriod, int historyLength )
-    {
-        List<Period> periods = new ArrayList<Period>( historyLength );
-
-        CalendarPeriodType periodType = (CalendarPeriodType) lastPeriod.getPeriodType();
-
-        Period period = lastPeriod;
-        Period p = new Period();
-
-        for ( int i = 0; i < historyLength; ++i )
-        {
-
-            p = periodService.getPeriodFromDates( period.getStartDate(), period.getEndDate(), periodType );
-            if ( p != null )
-            {
-                periods.add( p );
-            }
-            else
-            {
-                periods.add( period );
-            }
-            period = periodType.getPreviousPeriod( period );
-        }
-
-        Collections.reverse( periods );
-
-        return periods;
-    }
-
     private Double getValue( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
         OrganisationUnit organisationUnit, Period period )
     {