← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15009: Moved DateIntervalType into its own class.

 

------------------------------------------------------------
revno: 15009
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-27 08:30:02 +0545
message:
  Moved DateIntervalType into its own class.
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateIntervalType.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/Calendar.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.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/calendar/Calendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/Calendar.java	2014-04-27 02:27:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/Calendar.java	2014-04-27 02:45:02 +0000
@@ -82,9 +82,9 @@
      * Gets interval of type based on DateUnit
      * @param dateUnit DateUnit representing local year, month, day
      * @return Interval for interval type based on dateUnit
-     * @see DateInterval.DateIntervalType
+     * @see DateIntervalType
      */
-    DateInterval toInterval( DateUnit dateUnit, DateInterval.DateIntervalType type );
+    DateInterval toInterval( DateUnit dateUnit, DateIntervalType type );
 
     /**
      * Gets current date as local DateUnit

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java	2014-04-27 02:30:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java	2014-04-27 02:45:02 +0000
@@ -62,7 +62,7 @@
     }
 
     @Override
-    public DateInterval toInterval( DateUnit dateUnit, DateInterval.DateIntervalType type )
+    public DateInterval toInterval( DateUnit dateUnit, DateIntervalType type )
     {
         switch ( type )
         {
@@ -85,7 +85,7 @@
         from.setDayOfWeek( isoWeekday( from ) );
         to.setDayOfWeek( isoWeekday( to ) );
 
-        return new DateInterval( from, to, DateInterval.DateIntervalType.ISO8601_YEAR );
+        return new DateInterval( from, to, DateIntervalType.ISO8601_YEAR );
     }
 
     private DateInterval toMonthIsoInterval( DateUnit dateUnit )
@@ -96,7 +96,7 @@
         from.setDayOfWeek( isoWeekday( from ) );
         to.setDayOfWeek( isoWeekday( to ) );
 
-        return new DateInterval( from, to, DateInterval.DateIntervalType.ISO8601_MONTH );
+        return new DateInterval( from, to, DateIntervalType.ISO8601_MONTH );
     }
 
     private DateInterval toWeekIsoInterval( DateUnit dateUnit )
@@ -106,7 +106,7 @@
         DateTime from = dateTime.weekOfWeekyear().toInterval().getStart();
         DateTime to = dateTime.weekOfWeekyear().toInterval().getEnd().minusDays( 1 );
 
-        return new DateInterval( DateUnit.fromDateTime( from ), DateUnit.fromDateTime( to ), DateInterval.DateIntervalType.ISO8601_WEEK );
+        return new DateInterval( DateUnit.fromDateTime( from ), DateUnit.fromDateTime( to ), DateIntervalType.ISO8601_WEEK );
     }
 
     @Override

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java	2014-04-27 02:30:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java	2014-04-27 02:45:02 +0000
@@ -38,15 +38,6 @@
  */
 public class DateInterval
 {
-    public enum DateIntervalType
-    {
-        /**
-         * Gives interval for a year, month or week based on ISO 8601.
-         * @see <a href="http://en.wikipedia.org/wiki/ISO_8601";>http://en.wikipedia.org/wiki/ISO_8601</a>
-         */
-        ISO8601_YEAR, ISO8601_MONTH, ISO8601_WEEK
-    }
-
     /**
      * Start of interval. Required.
      */

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateIntervalType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateIntervalType.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateIntervalType.java	2014-04-27 02:45:02 +0000
@@ -0,0 +1,41 @@
+package org.hisp.dhis.calendar;
+
+/*
+ * Copyright (c) 2004-2014, 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.
+ */
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public enum DateIntervalType
+{
+    /**
+      * Gives interval for a year, month or week based on ISO 8601.
+      * @see <a href="http://en.wikipedia.org/wiki/ISO_8601";>http://en.wikipedia.org/wiki/ISO_8601</a>
+      */
+     ISO8601_YEAR, ISO8601_MONTH, ISO8601_WEEK
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.java	2014-04-27 02:25:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.java	2014-04-27 02:45:02 +0000
@@ -31,6 +31,7 @@
 import org.hisp.dhis.calendar.AbstractCalendar;
 import org.hisp.dhis.calendar.Calendar;
 import org.hisp.dhis.calendar.DateInterval;
+import org.hisp.dhis.calendar.DateIntervalType;
 import org.hisp.dhis.calendar.DateUnit;
 import org.joda.time.DateTime;
 import org.joda.time.Days;
@@ -127,7 +128,7 @@
     }
 
     @Override
-    public DateInterval toInterval( DateUnit dateUnit, DateInterval.DateIntervalType type )
+    public DateInterval toInterval( DateUnit dateUnit, DateIntervalType type )
     {
         switch ( type )
         {
@@ -150,7 +151,7 @@
         from = toIso( from );
         to = toIso( to );
 
-        return new DateInterval( from, to );
+        return new DateInterval( from, to, DateIntervalType.ISO8601_YEAR );
     }
 
     private DateInterval toMonthIsoInterval( DateUnit dateUnit )
@@ -161,7 +162,7 @@
         from = toIso( from );
         to = toIso( to );
 
-        return new DateInterval( from, to );
+        return new DateInterval( from, to, DateIntervalType.ISO8601_MONTH );
     }
 
     private DateInterval toWeekIsoInterval( DateUnit dateUnit )
@@ -171,7 +172,7 @@
         DateTime from = dateTime.weekOfWeekyear().toInterval().getStart();
         DateTime to = dateTime.weekOfWeekyear().toInterval().getEnd().minusDays( 1 );
 
-        return new DateInterval( DateUnit.fromDateTime( from ), DateUnit.fromDateTime( to ) );
+        return new DateInterval( DateUnit.fromDateTime( from ), DateUnit.fromDateTime( to ), DateIntervalType.ISO8601_WEEK );
     }
 
     @Override