← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4599: - Data entry, substituting days and constants in indicator expressions before sending to client. ...

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 4599 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-09-16 10:06:19 +0200
message:
  - Data entry, substituting days and constants in indicator expressions before sending to client. - Implemented bimonthly period type (still lacks ISO methods).
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/BiMonthlyPeriodTypeTest.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/PeriodTypeTest.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/PeriodType.hbm.xml
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.js
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java
  dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/exportForm.vm


--
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/expression/ExpressionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java	2011-09-03 11:29:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java	2011-09-16 07:53:59 +0000
@@ -181,6 +181,9 @@
     String getExpressionDescription( String expression );
 
     /**
+     * Substitutes potential constant and days in the numerator and denominator
+     * on all indicators in the given collection.
+     *  
      * Populates the explodedNumerator and explodedDenominator property on all
      * indicators in the given collection. This method uses
      * explodeExpression( String ) internally to generate the exploded expressions.
@@ -189,8 +192,9 @@
      * overhead is avoided.
      * 
      * @param indicators the collection of indicators.
+     * @param 
      */
-    void explodeExpressions( Collection<Indicator> indicators );
+    void explodeAndSubstituteExpressions( Collection<Indicator> indicators, Integer days );
     
     /**
      * Replaces references to data element totals with references to all
@@ -202,6 +206,16 @@
     String explodeExpression( String expression );
     
     /**
+     * Substitutes potential constants and days in the given expression.
+     * 
+     * @param expression the expression to operate on.
+     * @param days the number of days to substitute for potential days in the
+     *        expression, 0 if null
+     * @return the substituted expression.
+     */
+    String substituteExpression( String expression, Integer days );
+    
+    /**
      * Converts an expression on the form [34] + [23], where the numbers are 
      * IDs of DataElements, to the form 200 + 450, where the numbers are the 
      * values of the DataValues registered for the Period and Source. "0" is

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java	2011-09-16 07:53:59 +0000
@@ -0,0 +1,150 @@
+package org.hisp.dhis.period;
+
+/*
+ * Copyright (c) 2004-2010, 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.
+ */
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang.NotImplementedException;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class BiMonthlyPeriodType
+    extends CalendarPeriodType
+{
+    /**
+     * The name of the BiMonthlyPeriodType, which is "BiMonthly".
+     */
+    public static final String NAME = "BiMonthly";
+
+    public static final int FREQUENCY_ORDER = 61;
+
+    // -------------------------------------------------------------------------
+    // PeriodType functionality
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String getName()
+    {
+        return NAME;
+    }
+
+    @Override
+    public Period createPeriod()
+    {
+        return createPeriod( createCalendarInstance() );
+    }
+
+    @Override
+    public Period createPeriod( Date date )
+    {
+        return createPeriod( createCalendarInstance( date ) );
+    }
+
+    private Period createPeriod( Calendar cal )
+    {
+        cal.set( Calendar.MONTH, cal.get( Calendar.MONTH ) - cal.get( Calendar.MONTH ) % 2 );
+        cal.set( Calendar.DAY_OF_MONTH, 1 );
+
+        Date startDate = cal.getTime();
+
+        cal.add( Calendar.MONTH, 1 );
+        cal.set( Calendar.DAY_OF_MONTH, cal.getActualMaximum( Calendar.DAY_OF_MONTH ) );
+
+        return new Period( this, startDate, cal.getTime() );
+    }
+
+    @Override
+    public int getFrequencyOrder()
+    {
+        return FREQUENCY_ORDER;
+    }
+
+    // -------------------------------------------------------------------------
+    // CalendarPeriodType functionality
+    // -------------------------------------------------------------------------
+
+    @Override
+    public Period getNextPeriod( Period period )
+    {
+        Calendar cal = createCalendarInstance( period.getStartDate() );
+        cal.add( Calendar.MONTH, 2 );
+        return createPeriod( cal );
+    }
+
+    @Override
+    public Period getPreviousPeriod( Period period )
+    {
+        Calendar cal = createCalendarInstance( period.getStartDate() );
+        cal.add( Calendar.MONTH, -2 );
+        return createPeriod( cal );
+    }
+
+    /**
+     * Generates quarterly Periods for the whole year in which the given
+     * Period's startDate exists.
+     */
+    @Override
+    public List<Period> generatePeriods( Date date )
+    {
+        Calendar cal = createCalendarInstance( date );
+        cal.set( Calendar.DAY_OF_YEAR, 1 );
+
+        int year = cal.get( Calendar.YEAR );
+        ArrayList<Period> periods = new ArrayList<Period>();
+
+        while ( cal.get( Calendar.YEAR ) == year )
+        {
+            periods.add( createPeriod( cal ) );
+            cal.add( Calendar.MONTH, 2 );
+        }
+
+        return periods;
+    }
+
+    @Override
+    public String getIsoDate( Period period )
+    {        
+        throw new NotImplementedException(); // TODO
+    }
+
+    @Override
+    public Period createPeriod( String isoDate )
+    {
+        throw new NotImplementedException(); // TODO
+    }
+
+    @Override
+    public String getIsoFormat()
+    {
+        throw new NotImplementedException(); // TODO
+    }
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java	2011-09-14 15:17:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java	2011-09-16 07:53:59 +0000
@@ -66,6 +66,7 @@
         periodTypes.add( new DailyPeriodType() );
         periodTypes.add( new WeeklyPeriodType() );
         periodTypes.add( new MonthlyPeriodType() );
+        periodTypes.add( new BiMonthlyPeriodType() );
         periodTypes.add( new QuarterlyPeriodType() );
         periodTypes.add( new SixMonthlyPeriodType() );
         periodTypes.add( new YearlyPeriodType() );
@@ -128,8 +129,10 @@
     {
         index -= 1;
         
-        if (index < 0 || index > periodTypes.size() - 1 )
+        if ( index < 0 || index > periodTypes.size() - 1 )
+        {
             return null;
+        }
 
         return periodTypes.get( index );
     }
@@ -256,26 +259,68 @@
     }
 
     /**
-     * Returns a PeriodType corresponding to the provided string
-     * The test is quite rudimentary, testing for string format rather than invalid periods.
+     * Returns a PeriodType corresponding to the provided string The test is
+     * quite rudimentary, testing for string format rather than invalid periods.
      * Currently only recognizes the basic subset of common period types.
-     *
-     * @param  isoPeriod String formatted period (2011, 201101, 2011W34, 2011Q1 etc
-     * @return the PeriodType or null if unrecognised
+     * 
+     * @param isoPeriod String formatted period (2011, 201101, 2011W34, 2011Q1
+     *        etc
+     * @return the PeriodType or null if unrecognized
      */
-    public static PeriodType getPeriodTypeFromIsoString(String isoPeriod)
+    public static PeriodType getPeriodTypeFromIsoString( String isoPeriod )
     {
-        if (isoPeriod.matches("\\b\\d{4}\\b")) return new YearlyPeriodType();
-        if (isoPeriod.matches("\\b\\d{6}\\b")) return new MonthlyPeriodType();
-        if (isoPeriod.matches("\\b\\d{4}W\\d[\\d]?\\b")) return new WeeklyPeriodType();
-        if (isoPeriod.matches("\\b\\d{8}\\b")) return new DailyPeriodType();
-        if (isoPeriod.matches("\\b\\d{4}Q\\d\\b")) return new QuarterlyPeriodType();
-        if (isoPeriod.matches("\\b\\d{4}S\\d\\b")) return new SixMonthlyPeriodType();
+        if ( isoPeriod.matches( "\\b\\d{4}\\b" ) )
+        {
+            return new YearlyPeriodType();
+        }
+        if ( isoPeriod.matches( "\\b\\d{6}\\b" ) )
+        {
+            return new MonthlyPeriodType();
+        }
+        if ( isoPeriod.matches( "\\b\\d{4}W\\d[\\d]?\\b" ) )
+        {
+            return new WeeklyPeriodType();
+        }
+        if ( isoPeriod.matches( "\\b\\d{8}\\b" ) )
+        {
+            return new DailyPeriodType();
+        }
+        if ( isoPeriod.matches( "\\b\\d{4}Q\\d\\b" ) )
+        {
+            return new QuarterlyPeriodType();
+        }
+        if ( isoPeriod.matches( "\\b\\d{4}S\\d\\b" ) )
+        {
+            return new SixMonthlyPeriodType();
+        }
 
         return null;
     }
 
     /**
+     * Creates a period based on the given external identifier, which is on the
+     * format [PeriodType]_[StartDate]. The start date is on the form yyyy-MM-dd.
+     * 
+     * @param externalId the external identifier.
+     * @return the period.
+     */
+    public static Period createPeriodExternalId( String externalId )
+    {
+        if ( externalId == null || externalId.split( "_" ).length <= 1 )
+        {
+            return null;
+        }
+        
+        final String[] id = externalId.split( "_" );
+        final PeriodType periodType = getPeriodTypeByName( id[0] );
+        return periodType.createPeriod( getMediumDate( id[1] ) );
+    }
+    
+    // -------------------------------------------------------------------------
+    // ISO format methods
+    // -------------------------------------------------------------------------
+
+    /**
      * Returns an iso8601 formatted string representation of the period
      * 
      * @param period
@@ -293,26 +338,6 @@
 
     public abstract String getIsoFormat();
     
-    /**
-     * Creates a period based on the given external identifier, which is on the
-     * format [PeriodType]_[StartDate]. The start date is on the form yyyy-MM-dd.
-     * 
-     * @param externalId the external identifier.
-     * @return the period.
-     */
-    public static Period createPeriodExternalId( String externalId )
-    {
-        if ( externalId == null || externalId.split( "_" ).length <= 1 )
-        {
-            return null;
-        }
-        
-        final String[] id = externalId.split( "_" );
-        final PeriodType periodType = getPeriodTypeByName( id[0] );
-        return periodType.createPeriod( getMediumDate( id[1] ) );
-    }
-    
-
     // -------------------------------------------------------------------------
     // hashCode and equals
     // -------------------------------------------------------------------------

=== added file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/BiMonthlyPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/BiMonthlyPeriodTypeTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/BiMonthlyPeriodTypeTest.java	2011-09-16 07:53:59 +0000
@@ -0,0 +1,127 @@
+package org.hisp.dhis.period;
+
+/*
+ * Copyright (c) 2004-2010, 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.
+ */
+
+import static junit.framework.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class BiMonthlyPeriodTypeTest
+{
+    private Cal startCal;
+    private Cal endCal;
+    private Cal testCal;
+    private CalendarPeriodType periodType;
+    
+    @Before
+    public void before()
+    {
+        startCal = new Cal();
+        endCal = new Cal();
+        testCal = new Cal();
+        periodType = new BiMonthlyPeriodType();
+    }
+    
+    @Test
+    public void testCreatePeriod()
+    {
+        testCal.set( 2009, 8, 15 );
+        
+        startCal.set( 2009, 7, 1 );
+        endCal.set( 2009, 8, 31 );
+
+        Period period = periodType.createPeriod( testCal.time() );
+        
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
+        
+        testCal.set( 2009, 3, 15 );
+        
+        startCal.set( 2009, 3, 1 );
+        endCal.set( 2009, 4, 30 );
+
+        period = periodType.createPeriod( testCal.time() );
+        
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
+    }
+
+    @Test
+    public void testGetNextPeriod()
+    {
+        testCal.set( 2009, 8, 15 );
+
+        Period period = periodType.createPeriod( testCal.time() );
+        
+        period = periodType.getNextPeriod( period );
+
+        startCal.set( 2009, 9, 1 );
+        endCal.set( 2009, 10, 31 );
+
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
+    }
+    
+    @Test
+    public void testGetPreviousPeriod()
+    {
+        testCal.set( 2009, 8, 15 );
+
+        Period period = periodType.createPeriod( testCal.time() );
+        
+        period = periodType.getPreviousPeriod( period );
+
+        startCal.set( 2009, 5, 1 );
+        endCal.set( 2009, 6, 30 );
+
+        assertEquals( startCal.time(), period.getStartDate() );
+        assertEquals( endCal.time(), period.getEndDate() );
+    }
+    
+    @Test
+    public void testGeneratePeriods()
+    {
+        testCal.set( 2009, 8, 15 );
+        
+        List<Period> periods = periodType.generatePeriods( testCal.time() );
+        
+        assertEquals( 6, periods.size() );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 3, 1 ).time() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 5, 1 ).time() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 9, 1 ).time() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new Cal( 2009, 11, 1 ).time() ), periods.get( 5 ) );
+    }
+}

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/PeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/PeriodTypeTest.java	2011-09-05 21:35:18 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/PeriodTypeTest.java	2011-09-16 07:53:59 +0000
@@ -34,14 +34,12 @@
 
 public class PeriodTypeTest
 {
-
     @Test
     public void testGetByIndex()
     {
         assertNull( PeriodType.getByIndex( -1 ) );
-        assertEquals( new YearlyPeriodType(), PeriodType.getByIndex( 6 ) );
-        assertNull( PeriodType.getByIndex( 999 ) );
-    
+        assertEquals( new YearlyPeriodType(), PeriodType.getByIndex( 7 ) );
+        assertNull( PeriodType.getByIndex( 999 ) );    
     }
 
     @Test
@@ -62,5 +60,4 @@
         assertNull(PeriodType.getPeriodTypeFromIsoString( "201er2345566"));
         assertNull(PeriodType.getPeriodTypeFromIsoString( "2011Q10"));
     }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java	2011-09-03 11:29:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java	2011-09-16 07:53:59 +0000
@@ -426,15 +426,21 @@
         return buffer != null ? buffer.toString() : null;
     }
 
-    public void explodeExpressions( Collection<Indicator> indicators )
+    public void explodeAndSubstituteExpressions( Collection<Indicator> indicators, Integer days )
     {
         if ( indicators != null )
-        {
+        {            
             for ( Indicator indicator : indicators )
             {
-                indicator.setExplodedNumerator( explodeExpression( indicator.getNumerator() ) );
-                indicator.setExplodedDenominator( explodeExpression( indicator.getDenominator() ) );
+                indicator.setExplodedNumerator( substituteExpression( indicator.getNumerator(), days ) );
+                indicator.setExplodedDenominator( substituteExpression( indicator.getDenominator(), days ) );
             }
+            
+            for ( Indicator indicator : indicators )
+            {
+                indicator.setExplodedNumerator( explodeExpression( indicator.getExplodedNumerator() ) );
+                indicator.setExplodedDenominator( explodeExpression( indicator.getExplodedDenominator() ) );
+            }     
         }
     }
     
@@ -477,7 +483,40 @@
 
         return buffer != null ? buffer.toString() : null;
     }
-
+    
+    public String substituteExpression( String expression, Integer days )
+    {
+        StringBuffer buffer = null;
+        
+        if ( expression != null )
+        {
+            buffer = new StringBuffer();
+
+            final Matcher matcher = FORMULA_PATTERN.matcher( expression );
+            while ( matcher.find() )
+            {
+                String match = matcher.group();
+
+                if ( DAYS_EXPRESSION.equals( match ) ) // Days
+                {
+                    match = days != null ? String.valueOf( days ) : NULL_REPLACEMENT;
+                }
+                else if ( match.matches( CONSTANT_EXPRESSION ) ) // Constant
+                {
+                    final Constant constant = constantService.getConstant( Integer.parseInt( stripConstantExpression( match ) ) );
+                    
+                    match = constant != null ? String.valueOf( constant.getValue() ) : NULL_REPLACEMENT; 
+                }
+                
+                matcher.appendReplacement( buffer, match );
+            }
+
+            matcher.appendTail( buffer );
+        }
+
+        return buffer != null ? buffer.toString() : null;
+    }
+    
     public String generateExpression( String expression, Period period, OrganisationUnit source,
         boolean nullIfNoValues, boolean aggregated, Integer days )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/PeriodType.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/PeriodType.hbm.xml	2011-05-29 11:10:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/PeriodType.hbm.xml	2011-09-16 07:53:59 +0000
@@ -17,6 +17,7 @@
     <subclass name="org.hisp.dhis.period.DailyPeriodType" discriminator-value="Daily" />
     <subclass name="org.hisp.dhis.period.WeeklyPeriodType" discriminator-value="Weekly" />
     <subclass name="org.hisp.dhis.period.MonthlyPeriodType" discriminator-value="Monthly" />
+    <subclass name="org.hisp.dhis.period.BiMonthlyPeriodType" discriminator-value="BiMonthly" />
     <subclass name="org.hisp.dhis.period.QuarterlyPeriodType" discriminator-value="Quarterly" />
     <subclass name="org.hisp.dhis.period.SixMonthlyPeriodType" discriminator-value="SixMonthly" />
     <subclass name="org.hisp.dhis.period.YearlyPeriodType" discriminator-value="Yearly" />

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.js	2011-08-18 12:04:09 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.js	2011-09-16 07:53:59 +0000
@@ -137,6 +137,33 @@
     };
 }
 
+function BiMonthlyPeriodType( dateFormat )
+{
+    this.generatePeriods = function( offset )
+    {
+        var periods = [];
+        var year = new Date().getFullYear() + offset;
+        var startDate = $.date( year + '-01-01', dateFormat );
+        var i = 0;
+        var j = 0;
+
+        while ( startDate.date().getFullYear() == year )
+        {
+            var period = [];
+            period['startDate'] = startDate.format( dateFormat );
+            period['name'] = monthNames[i] + ' - ' + monthNames[i + 1] + ' ' + year;
+            period['id'] = 'BiMonthly_' + period['startDate'];
+            periods[j] = period;
+
+            startDate.adjust( 'M', +2 );
+            i += 2;
+            j++;
+        }
+
+        return periods;
+    };
+}
+
 function QuarterlyPeriodType( dateFormat )
 {
     this.generatePeriods = function( offset )

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2011-09-09 06:18:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2011-09-16 07:53:59 +0000
@@ -114,6 +114,7 @@
 Daily					= Daily
 Weekly					= Weekly
 Monthly					= Monthly
+BiMonthly				= Bimonthly
 Quarterly				= Quarterly
 SixMonthly				= Six-monthly
 Yearly					= Yearly
@@ -132,6 +133,8 @@
 format.Weekly.endDate		= 
 format.Monthly.startDate	= MMMM yyyy
 format.Monthly.endDate		=
+format.BiMonthly.startDate	= MMM 'to '
+format.BiMonthly.endDate	= MMM yyyy
 format.Quarterly.startDate	= MMM 'to '
 format.Quarterly.endDate	= MMM yyyy
 format.SixMonthly.startDate	= MMM 'to '

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2011-09-03 11:29:44 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2011-09-16 07:53:59 +0000
@@ -147,7 +147,7 @@
         
         indicators = indicatorService.getIndicatorsWithDataSets();
         
-        expressionService.explodeExpressions( indicators );
+        expressionService.explodeAndSubstituteExpressions( indicators, null );
         
         OrganisationUnitDataSetAssociationSet organisationUnitSet = organisationUnitService.getOrganisationUnitDataSetAssociationSet();
         

=== modified file 'dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/exportForm.vm'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/exportForm.vm	2011-03-18 12:48:40 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/exportForm.vm	2011-09-16 07:53:59 +0000
@@ -171,7 +171,7 @@
 			<select id="periodType" name="periodType" style="min-width:224px" onchange="getAvailablePeriods( 'periodType', 'availablePeriods', 'selectedPeriods', '0' )">
 				<option value="">[ $i18n.getString( "select_period_type_all" ) ]</option>
 				#foreach ( $type in $periodTypes )
-					<option value="$type.name">$type.name</option>
+					<option value="$type.name">$i18n.getString( $type.name )</option>
 				#end
 			</select><br>
 			<select multiple size="6" id="availablePeriods" name="availablePeriods" style="min-width:325px" ondblclick="moveSelectedById( 'availablePeriods', 'selectedPeriods' )">