dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18427
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7768: Fixed bug with last 3 months in relative periods
------------------------------------------------------------
revno: 7768
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-07-30 15:09:47 +0200
message:
Fixed bug with last 3 months in relative periods
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.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/RelativePeriods.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java 2012-07-26 06:41:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java 2012-07-30 13:09:47 +0000
@@ -102,11 +102,6 @@
"month11",
"month12"};
- public static final String[] MONTHS_LAST_3 = {
- "lastmonth1",
- "lastmonth2",
- "lastmonth3"};
-
public static final String[] BIMONTHS_LAST_6 = {
"bimonth1",
"bimonth2",
@@ -484,7 +479,7 @@
if ( isLast3Months() )
{
- periods.addAll( getRollingRelativePeriodList( new MonthlyPeriodType(), MONTHS_LAST_3, date, dynamicNames, format ) );
+ periods.addAll( getRollingRelativePeriodList( new MonthlyPeriodType(), MONTHS_LAST_12, date, dynamicNames, format ).subList( 9, 12 ) );
}
if ( isLast6BiMonths() )
@@ -637,10 +632,10 @@
List<Period> periods = new ArrayList<Period>();
int c = 0;
- int index = relatives.size() - periodNames.length;
- for ( int i= index; i< relatives.size();i++ )
+
+ for ( Period period : relatives )
{
- periods.add( setName( relatives.get( i ), periodNames[c++], dynamicNames, format ) );
+ periods.add( setName( period, periodNames[c++], dynamicNames, format ) );
}
return periods;
=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java 2012-07-24 07:11:35 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java 2012-07-30 13:09:47 +0000
@@ -157,14 +157,14 @@
@Test
public void testGetLast3Months()
{
- RelativePeriods relativePeriods = new RelativePeriods();
- relativePeriods.setLast3Months( true );
- List<Period> relatives = relativePeriods.getRelativePeriods( getDate( 2012, 3, 1 ), null, false );
-
+ RelativePeriods relativePeriods = new RelativePeriods().setLast3Months( true );
+
+ List<Period> relatives = relativePeriods.getRelativePeriods( getDate( 2001, 7, 1 ), null, false );
+
assertEquals( 3, relatives.size() );
- assertTrue( relatives.contains( new Period( new MonthlyPeriodType(), getDate( 2012, 1, 1 ), getDate( 2012, 1, 31 ) ) ) );
- assertTrue( relatives.contains( new Period( new MonthlyPeriodType(), getDate( 2012, 2, 1 ), getDate( 2012, 2, 29 ) ) ) );
- assertTrue( relatives.contains( new Period( new MonthlyPeriodType(), getDate( 2012, 3, 1 ), getDate( 2012, 3, 31 ) ) ) );
+ assertTrue( relatives.contains( new Period( new MonthlyPeriodType(), getDate( 2001, 5, 1 ), getDate( 2001, 5, 31 ) ) ) );
+ assertTrue( relatives.contains( new Period( new MonthlyPeriodType(), getDate( 2001, 6, 1 ), getDate( 2001, 6, 30 ) ) ) );
+ assertTrue( relatives.contains( new Period( new MonthlyPeriodType(), getDate( 2001, 7, 1 ), getDate( 2001, 7, 31 ) ) ) );
}
@Test
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java 2012-06-18 10:29:46 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/inbound/HibernateIncomingSmsStore.java 2012-07-30 13:09:47 +0000
@@ -73,6 +73,7 @@
}
@Override
+ @SuppressWarnings("unchecked")
public Collection<IncomingSms> getSmsByStatus( SmsMessageStatus status )
{
Session session = sessionFactory.getCurrentSession();
@@ -81,6 +82,7 @@
}
@Override
+ @SuppressWarnings("unchecked")
public Collection<IncomingSms> getSmsByOriginator( String originator )
{
Criteria criteria = sessionFactory.getCurrentSession().createCriteria( IncomingSms.class );
@@ -89,6 +91,7 @@
}
@Override
+ @SuppressWarnings("unchecked")
public Collection<IncomingSms> getAllSmses()
{
return sessionFactory.getCurrentSession().createCriteria( IncomingSms.class ).addOrder( Order.desc( "id" ) ).list();