← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19918: more ValueType replacements

 

------------------------------------------------------------
revno: 19918
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-09-01 13:14:53 +0700
message:
  more ValueType replacements
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java
  dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dataelementhistory/DefaultHistoryRetriever.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/caseaggregation/GetAggPSDataElementsAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetFilteredDataElementsAction.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-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2015-06-23 15:59:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2015-09-01 06:14:53 +0000
@@ -28,14 +28,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 import org.apache.commons.lang3.BooleanUtils;
+import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.i18n.I18n;
@@ -44,6 +38,13 @@
 import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValue;
 import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueService;
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 /**
  * @author Chau Thu Tran
  */
@@ -246,27 +247,27 @@
 
                 tabindex++;
 
+                ValueType valueType = dataElement.getValueType();
+
                 if ( dataElement.getOptionSet() != null && dataElement.getOptionSet().getOptions().size() < 7
                     && programStage.getProgram().getDataEntryMethod() )
                 {
                     String idField = programStageUid + "-" + dataElementUid + "-val";
                     inputHTML = populateCustomDataEntryForOptionSet( dataElement, idField, entityInstanceDataValue, i18n );
                 }
-                else if ( DataElement.VALUE_TYPE_INT.equals( dataElement.getType() )
-                    || DataElement.VALUE_TYPE_STRING.equals( dataElement.getType() )
-                    || DataElement.VALUE_TYPE_USER_NAME.equals( dataElement.getType() ) )
+                else if ( valueType.isText() || valueType.isNumeric() || ValueType.USERNAME == valueType )
                 {
                     inputHTML = populateCustomDataEntryForTextBox( dataElement, inputHTML, dataElementValue );
                 }
-                else if ( DataElement.VALUE_TYPE_DATE.equals( dataElement.getType() ) )
+                else if ( ValueType.DATE == valueType || ValueType.DATETIME == valueType )
                 {
                     inputHTML = populateCustomDataEntryForDate( inputHTML, dataElementValue );
                 }
-                else if ( DataElement.VALUE_TYPE_TRUE_ONLY.equals( dataElement.getType() ) )
+                else if ( ValueType.TRUE_ONLY == valueType )
                 {
                     inputHTML = populateCustomDataEntryForTrueOnly( dataElement, inputHTML, dataElementValue );
                 }
-                else if ( DataElement.VALUE_TYPE_BOOL.equals( dataElement.getType() ) )
+                else if ( ValueType.BOOLEAN == valueType )
                 {
                     inputHTML = populateCustomDataEntryForBoolean( dataElement, inputHTML, dataElementValue, i18n );
                 }
@@ -284,7 +285,7 @@
                 }
                 else
                 {
-                    if ( DataElement.VALUE_TYPE_DATE.equals( dataElement.getType() ) )
+                    if ( ValueType.DATE == valueType || ValueType.DATETIME == valueType )
                     {
                         inputHTML += jQueryCalendar;
                     }
@@ -439,21 +440,21 @@
 
                 tabindex++;
 
-                if ( DataElement.VALUE_TYPE_INT.equals( dataElement.getType() )
-                    || DataElement.VALUE_TYPE_STRING.equals( dataElement.getType() )
-                    || DataElement.VALUE_TYPE_USER_NAME.equals( dataElement.getType() ) )
+                ValueType valueType = dataElement.getValueType();
+
+                if ( valueType.isText() || valueType.isNumeric() || ValueType.USERNAME == valueType )
                 {
                     inputHTML = populateCustomDataEntryForTextBox( dataElement, inputHTML, dataElementValue );
                 }
-                else if ( DataElement.VALUE_TYPE_DATE.equals( dataElement.getType() ) )
+                else if ( ValueType.DATE == valueType || ValueType.DATETIME == valueType )
                 {
                     inputHTML = populateCustomDataEntryForDate( inputHTML, dataElementValue );
                 }
-                else if ( DataElement.VALUE_TYPE_TRUE_ONLY.equals( dataElement.getType() ) )
+                else if ( ValueType.TRUE_ONLY == valueType )
                 {
                     inputHTML = populateCustomDataEntryForTrueOnly( dataElement, inputHTML, dataElementValue );
                 }
-                else if ( DataElement.VALUE_TYPE_BOOL.equals( dataElement.getType() ) )
+                else if ( ValueType.BOOLEAN == valueType )
                 {
                     inputHTML = populateCustomDataEntryForBoolean( dataElement, inputHTML, dataElementValue, i18n );
                 }
@@ -471,7 +472,7 @@
                 }
                 else
                 {
-                    if ( DataElement.VALUE_TYPE_DATE.equals( dataElement.getType() ) )
+                    if ( ValueType.DATE == valueType || ValueType.DATETIME == valueType )
                     {
                         inputHTML += jQueryCalendar;
                     }
@@ -683,7 +684,8 @@
     private String populateCustomDataEntryForTrueOnly( DataElement dataElement, String inputHTML,
         String dataElementValue )
     {
-        final String jsCodeForInputs = " name=\"entryfield\" tabIndex=\"$TABINDEX\" $DISABLED data=\"{compulsory:$COMPULSORY, deName:'$DATAELEMENTNAME', deType:'$DATAELEMENTTYPE'}\" onchange=\"saveVal( '$DATAELEMENTID' )\" onkeypress=\"return keyPress(event, this)\" ";
+        final String jsCodeForInputs = " name=\"entryfield\" tabIndex=\"$TABINDEX\" $DISABLED data=\"{compulsory:$COMPULSORY, deName:'$DATAELEMENTNAME', deType:'$DATAELEMENTTYPE'}\" onchange=\"saveVal( '$DATAELEMENTID' )\" onkeypress=\"return keyPress" +
+            "(event, this)\" ";
 
         String checked = "";
         if ( !dataElementValue.equals( EMPTY ) && dataElementValue.equals( "true" ) )
@@ -826,7 +828,7 @@
         {
             return null;
         }
-        
+
         List<DataElement> dataElements = programStage.getAllDataElements();
 
         Map<String, DataElement> map = new HashMap<>();
@@ -841,9 +843,9 @@
 
     /**
      * Replaces i18n string in the custom form code.
-     * 
+     *
      * @param dataEntryFormCode the data entry form html.
-     * @param i18n the I18n object.
+     * @param i18n              the I18n object.
      * @return internationalized data entry form html.
      */
     private String populateI18nStrings( String dataEntryFormCode, I18n i18n )

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java	2015-07-06 10:12:37 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java	2015-09-01 06:14:53 +0000
@@ -28,14 +28,25 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.awt.Color;
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.List;
-
+import com.lowagie.text.Chunk;
+import com.lowagie.text.Document;
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.Element;
+import com.lowagie.text.Font;
+import com.lowagie.text.Paragraph;
+import com.lowagie.text.Phrase;
+import com.lowagie.text.Rectangle;
+import com.lowagie.text.pdf.PdfAnnotation;
+import com.lowagie.text.pdf.PdfAppearance;
+import com.lowagie.text.pdf.PdfBorderDictionary;
+import com.lowagie.text.pdf.PdfContentByte;
+import com.lowagie.text.pdf.PdfFormField;
+import com.lowagie.text.pdf.PdfPCell;
+import com.lowagie.text.pdf.PdfPTable;
+import com.lowagie.text.pdf.PdfWriter;
+import com.lowagie.text.pdf.RadioCheckField;
+import com.lowagie.text.pdf.TextField;
+import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataset.DataSet;
@@ -63,24 +74,13 @@
 import org.hisp.dhis.program.ProgramStageService;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import com.lowagie.text.Chunk;
-import com.lowagie.text.Document;
-import com.lowagie.text.DocumentException;
-import com.lowagie.text.Element;
-import com.lowagie.text.Font;
-import com.lowagie.text.Paragraph;
-import com.lowagie.text.Phrase;
-import com.lowagie.text.Rectangle;
-import com.lowagie.text.pdf.PdfAnnotation;
-import com.lowagie.text.pdf.PdfAppearance;
-import com.lowagie.text.pdf.PdfBorderDictionary;
-import com.lowagie.text.pdf.PdfContentByte;
-import com.lowagie.text.pdf.PdfFormField;
-import com.lowagie.text.pdf.PdfPCell;
-import com.lowagie.text.pdf.PdfPTable;
-import com.lowagie.text.pdf.PdfWriter;
-import com.lowagie.text.pdf.RadioCheckField;
-import com.lowagie.text.pdf.TextField;
+import java.awt.*;
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.List;
 
 /**
  * @author James Chang
@@ -89,7 +89,7 @@
 public class DefaultPdfDataEntryFormService
     implements PdfDataEntryFormService
 {
-    private static final Color COLOR_BACKGROUDTEXTBOX = Color.getHSBColor( 0.0f, 0.0f, 0.961f);
+    private static final Color COLOR_BACKGROUDTEXTBOX = Color.getHSBColor( 0.0f, 0.0f, 0.961f );
 
     private static final String TEXT_BLANK = " ";
 
@@ -102,7 +102,7 @@
 
     private static final int PERIODRANGE_PREVYEARS_YEARLY = 5;
     private static final int PERIODRANGE_FUTUREYEARS_YEARLY = 6;
-    
+
     private static final Integer MAX_OPTIONS_DISPLAYED = 30;
 
     private static final Integer PROGRAM_FORM_ROW_NUMBER = 10;
@@ -164,15 +164,15 @@
         throws Exception
     {
         DataSet dataSet = dataSetService.getDataSet( dataSetUid );
-                       
+
         if ( dataSet == null )
         {
             throw new Exception( "Error - DataSet not found for UID " + dataSetUid );
         }
-            
+
         // Get I18n locale language translated version of DataSet
         dataSet = dataSetService.getDataSet( dataSet.getId(), true, true, false );
-            
+
         setDataSet_DocumentTopSection( document, dataSet );
 
         document.add( Chunk.NEWLINE );
@@ -191,9 +191,9 @@
         document.add( mainTable );
 
 
-        document.add( Chunk.NEWLINE );             
-        document.add( Chunk.NEWLINE );
-        
+        document.add( Chunk.NEWLINE );
+        document.add( Chunk.NEWLINE );
+
         insertSaveAsButton( document, writer, PdfDataEntryFormUtil.LABELCODE_BUTTON_SAVEAS, dataSet.getDisplayName() );
     }
 
@@ -244,7 +244,7 @@
         throws IOException, DocumentException
     {
         boolean hasBorder = true;
-        
+
         // Add Section Name and Section Spacing
         insertTable_TextRow( writer, mainTable, TEXT_BLANK );
 
@@ -256,49 +256,50 @@
 
         // Create A Table To Add For Each Section
         PdfPTable table = new PdfPTable( 2 );
-        
-        table.setWidths(new int[] { 2, 1 });
+
+        table.setWidths( new int[]{ 2, 1 } );
         table.setWidthPercentage( 100.0f );
         table.setHorizontalAlignment( Element.ALIGN_LEFT );
-        
-        
+
+
         // For each DataElement and Category Combo of the dataElement, create
         // row.
         for ( DataElement dataElement : dataElements )
         {
-            for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo()
-                .getSortedOptionCombos() )
+            for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getSortedOptionCombos() )
             {
                 String categoryOptionComboDisplayName = "";
 
                 // Hide Default category option combo name
                 if ( !categoryOptionCombo.isDefault() )
+                {
                     categoryOptionComboDisplayName = categoryOptionCombo.getDisplayName();
+                }
 
-                addCell_Text( table, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), dataElement.getFormNameFallback() + " " + categoryOptionComboDisplayName,
-                    Element.ALIGN_RIGHT );
+                addCell_Text( table, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), dataElement.getFormNameFallback() + " " +
+                    categoryOptionComboDisplayName, Element.ALIGN_RIGHT );
 
                 String strFieldLabel = PdfDataEntryFormUtil.LABELCODE_DATAENTRYTEXTFIELD + dataElement.getUid() + "_"
                     + categoryOptionCombo.getUid();
 
-                String dataElementTextType = dataElement.getType();
+                ValueType valueType = dataElement.getValueType();
 
                 // Yes Only case - render as check-box
-                if ( dataElementTextType.equals( DataElement.VALUE_TYPE_TRUE_ONLY ) )
+                if ( ValueType.TRUE_ONLY == valueType )
                 {
                     addCell_WithCheckBox( table, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel );
                 }
-                else if ( dataElementTextType.equals( DataElement.VALUE_TYPE_BOOL ) )
+                if ( ValueType.BOOLEAN == valueType )
                 {
                     // Create Yes - true, No - false, Select..
-                    String[] optionList = new String[] { "[No Value]", "Yes", "No" };
-                    String[] valueList = new String[] { "", "true", "false" };
+                    String[] optionList = new String[]{ "[No Value]", "Yes", "No" };
+                    String[] valueList = new String[]{ "", "true", "false" };
 
                     // addCell_WithRadioButton(table, writer, strFieldLabel);
                     addCell_WithDropDownListField( table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel, optionList, valueList );
                 }
-                else if ( dataElementTextType.equals( DataElement.VALUE_TYPE_INT ) )
-                {                    
+                if ( valueType.isNumeric() )
+                {
                     rectangle = new Rectangle( TEXTBOXWIDTH_NUMBERTYPE, PdfDataEntryFormUtil.CONTENT_HEIGHT_DEFAULT );
 
                     addCell_WithTextField( table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel, PdfFieldCell.TYPE_TEXT_NUMBER );
@@ -379,7 +380,7 @@
         throws IOException, DocumentException
     {
         boolean hasBorder = false;
-        
+
         // Add one to column count due to date entry + one hidden height set
         // field.
         int colCount = programStageDataElements.size() + 1 + 1;
@@ -504,19 +505,19 @@
     private void insertTable_OrgAndPeriod( PdfPTable mainTable, PdfWriter writer, List<Period> periods )
         throws IOException, DocumentException
     {
-        boolean hasBorder = false;        
+        boolean hasBorder = false;
         float width = 220.0f;
-        
+
         // Input TextBox size
         Rectangle rectangle = new Rectangle( width, PdfDataEntryFormUtil.CONTENT_HEIGHT_DEFAULT );
 
         // Add Organization ID/Period textfield
         // Create A table to add for each group AT HERE
         PdfPTable table = new PdfPTable( 2 ); // Code 1
-        table.setWidths(new int[] { 1, 3 });
+        table.setWidths( new int[]{ 1, 3 } );
         table.setHorizontalAlignment( Element.ALIGN_LEFT );
-        
-        
+
+
         addCell_Text( table, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), "Organization unit identifier", Element.ALIGN_RIGHT );
         addCell_WithTextField( table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), PdfDataEntryFormUtil.LABELCODE_ORGID,
             PdfFieldCell.TYPE_TEXT_ORGUNIT );
@@ -542,7 +543,7 @@
         throws IOException, DocumentException
     {
         boolean hasBorder = false;
-        
+
         // Add Organization ID/Period textfield
         // Create A table to add for each group AT HERE
         PdfPTable table = new PdfPTable( 1 ); // Code 1
@@ -575,19 +576,19 @@
 
         // Add to the main table
         PdfPCell cell_withInnerTable = new PdfPCell( table );
-        
+
         cell_withInnerTable.setBorder( Rectangle.NO_BORDER );
-        
+
         mainTable.addCell( cell_withInnerTable );
-    }    
-    
+    }
+
     // Insert 'Save As' button to document.
     //@SuppressWarnings( "unused" )
     private void insertSaveAsButton( Document document, PdfWriter writer, String name, String dataSetName )
         throws DocumentException
     {
         boolean hasBorder = false;
-        
+
         // Button Table
         PdfPTable tableButton = new PdfPTable( 1 );
 
@@ -595,12 +596,12 @@
         float buttonHeight = PdfDataEntryFormUtil.UNITSIZE_DEFAULT + 5;
 
         tableButton.setHorizontalAlignment( Element.ALIGN_CENTER );
-        
-        String jsAction ="var newFileName = this.getField(\"" + PdfDataEntryFormUtil.LABELCODE_PERIODID + "\").value + ' ' + "
+
+        String jsAction = "var newFileName = this.getField(\"" + PdfDataEntryFormUtil.LABELCODE_PERIODID + "\").value + ' ' + "
             + "  this.getField(\"" + PdfDataEntryFormUtil.LABELCODE_ORGID + "\").value + ' ' + "
             + "  \"" + dataSetName + ".pdf\";"
             + "var returnVal = app.alert('This will save this PDF file as ' + newFileName + '.  Do you want to Continue?', 1, 2);"
-            + "if(returnVal == 4) { "                        
+            + "if(returnVal == 4) { "
             + "  var aMyPath = this.path.split(\"/\");"
             + "  aMyPath.pop();"
             + "  aMyPath.push(newFileName);"
@@ -608,8 +609,8 @@
             + "  this.saveAs({cPath:cMyPath, bPromptToOverwrite:true});"
             + "  app.alert('File Saved.', 1);"
             + "} ";
-                
-        addCell_WithPushButtonField( tableButton, writer, PdfDataEntryFormUtil.getPdfPCell(buttonHeight, PdfDataEntryFormUtil.CELL_COLUMN_TYPE_ENTRYFIELD, hasBorder ),  name, jsAction );
+
+        addCell_WithPushButtonField( tableButton, writer, PdfDataEntryFormUtil.getPdfPCell( buttonHeight, PdfDataEntryFormUtil.CELL_COLUMN_TYPE_ENTRYFIELD, hasBorder ), name, jsAction );
 
         document.add( tableButton );
     }
@@ -670,7 +671,7 @@
     }
 
     private void addCell_WithDropDownListField( PdfPTable table, Rectangle rect, PdfWriter writer, PdfPCell cell, String strfldName, String[] optionList,
-        String[] valueList) throws IOException, DocumentException
+        String[] valueList ) throws IOException, DocumentException
     {
         TextField textList = new TextField( writer, rect, strfldName );
 
@@ -693,7 +694,7 @@
         throws IOException, DocumentException
     {
         float sizeDefault = PdfDataEntryFormUtil.UNITSIZE_DEFAULT;
-        
+
         RadioCheckField checkbox = new RadioCheckField( writer, new Rectangle( sizeDefault, sizeDefault ), "Yes", "On" );
 
         checkbox.setBorderWidth( 1 );
@@ -702,8 +703,8 @@
         PdfFormField checkboxfield = checkbox.getCheckField();
         checkboxfield.setFieldName( strfldName + "_" + PdfFieldCell.TPYEDEFINE_NAME + PdfFieldCell.TYPE_CHECKBOX );
 
-        setCheckboxAppearance(checkboxfield, writer.getDirectContent(), sizeDefault);
-        
+        setCheckboxAppearance( checkboxfield, writer.getDirectContent(), sizeDefault );
+
         cell.setCellEvent( new PdfFieldCell( checkboxfield, sizeDefault, sizeDefault, PdfFieldCell.TYPE_CHECKBOX, writer ) );
 
         table.addCell( cell );
@@ -715,7 +716,7 @@
         PdfFormField radiogroupField = PdfFormField.createRadioButton( writer, true );
         radiogroupField.setFieldName( strfldName );
 
-        cell.setCellEvent( new PdfFieldCell( radiogroupField, new String[] { "Yes", "No", "null" }, new String[] {
+        cell.setCellEvent( new PdfFieldCell( radiogroupField, new String[]{ "Yes", "No", "null" }, new String[]{
             "true", "false", "" }, "", 30.0f, PdfDataEntryFormUtil.UNITSIZE_DEFAULT, PdfFieldCell.TYPE_RADIOBUTTON, writer ) );
 
         table.addCell( cell );
@@ -724,7 +725,7 @@
     }
 
     private void addCell_WithPushButtonField( PdfPTable table, PdfWriter writer, PdfPCell cell, String strfldName, String jsAction )
-    {        
+    {
         cell.setCellEvent( new PdfFieldCell( null, jsAction, "BTN_SAVEPDF", "Save PDF", PdfFieldCell.TYPE_BUTTON,
             writer ) );
 
@@ -746,24 +747,24 @@
     public String[] getPeriodTitles( List<Period> periods, I18nFormat format )
     {
         String[] periodTitles = new String[periods.size()];
-     
+
         // For Weekly, since formatPeriod has logic to only get ISO date
         // add weekly date range info here.
         SimpleDateFormat simpleDateFormat_Weekly = null;
-        
-        if( periods.size() > 1 && periods.get(  0 ).getPeriodType().getName() == WeeklyPeriodType.NAME )
+
+        if ( periods.size() > 1 && periods.get( 0 ).getPeriodType().getName() == WeeklyPeriodType.NAME )
         {
             simpleDateFormat_Weekly = new SimpleDateFormat( Period.DEFAULT_DATE_FORMAT );
         }
-        
+
         for ( int i = 0; i < periods.size(); i++ )
         {
             Period period = periods.get( i );
             periodTitles[i] = format.formatPeriod( period );
-            
-            if(simpleDateFormat_Weekly != null)
+
+            if ( simpleDateFormat_Weekly != null )
             {
-                periodTitles[i] += " - " + simpleDateFormat_Weekly.format( period.getStartDate() ) 
+                periodTitles[i] += " - " + simpleDateFormat_Weekly.format( period.getStartDate() )
                     + " - " + simpleDateFormat_Weekly.format( period.getEndDate() );
             }
         }
@@ -792,33 +793,33 @@
             || periodType.getName() == FinancialJulyPeriodType.NAME
             || periodType.getName() == FinancialOctoberPeriodType.NAME )
         {
-            startYear = currYear - PERIODRANGE_PREVYEARS_YEARLY ;
-            endYear = currYear + PERIODRANGE_FUTUREYEARS_YEARLY ;                       
+            startYear = currYear - PERIODRANGE_PREVYEARS_YEARLY;
+            endYear = currYear + PERIODRANGE_FUTUREYEARS_YEARLY;
         }
-            
+
         period.setStartDate( simpleDateFormat.parse( String.valueOf( startYear ) + "-01-01" ) );
         period.setEndDate( simpleDateFormat.parse( String.valueOf( endYear ) + "-01-01" ) );
 
         return period;
     }
-    
-    private void setCheckboxAppearance(PdfFormField checkboxfield, PdfContentByte canvas, float width)
-    {            
+
+    private void setCheckboxAppearance( PdfFormField checkboxfield, PdfContentByte canvas, float width )
+    {
         PdfAppearance[] onOff = new PdfAppearance[2];
-        onOff[0] = canvas.createAppearance(width + 2, width + 2);
-        onOff[0].rectangle(1, 1, width, width);
+        onOff[0] = canvas.createAppearance( width + 2, width + 2 );
+        onOff[0].rectangle( 1, 1, width, width );
         onOff[0].stroke();
-        onOff[1] = canvas.createAppearance(width + 2, width + 2);
-        onOff[1].setRGBColorFill(255, 128, 128);
-        onOff[1].rectangle(1, 1, width, width);
+        onOff[1] = canvas.createAppearance( width + 2, width + 2 );
+        onOff[1].setRGBColorFill( 255, 128, 128 );
+        onOff[1].rectangle( 1, 1, width, width );
         onOff[1].fillStroke();
-        onOff[1].moveTo(1, 1);
-        onOff[1].lineTo(width + 1, width + 1);
-        onOff[1].moveTo(1, width + 1);
-        onOff[1].lineTo(width + 1, 1);          
+        onOff[1].moveTo( 1, 1 );
+        onOff[1].lineTo( width + 1, width + 1 );
+        onOff[1].moveTo( 1, width + 1 );
+        onOff[1].lineTo( width + 1, 1 );
         onOff[1].stroke();
-        
-        checkboxfield.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", onOff[0]);
-        checkboxfield.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "On", onOff[1]);
-    }    
+
+        checkboxfield.setAppearance( PdfAnnotation.APPEARANCE_NORMAL, "Off", onOff[0] );
+        checkboxfield.setAppearance( PdfAnnotation.APPEARANCE_NORMAL, "On", onOff[1] );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java	2015-07-02 07:05:55 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java	2015-09-01 06:14:53 +0000
@@ -28,38 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_DATAELEMENT;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_PROPERTY;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_TRACKED_ENTITY_ATTRIBUTE;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_TRACKED_ENTITY_PROGRAM_STAGE_PROPERTY;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.PARAM_PERIOD_END_DATE;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.PARAM_PERIOD_ID;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.PARAM_PERIOD_ISO_DATE;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.PARAM_PERIOD_START_DATE;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_ID;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_OBJECT;
-import static org.hisp.dhis.scheduling.CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_LAST_12_MONTH;
-import static org.hisp.dhis.scheduling.CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_LAST_3_MONTH;
-import static org.hisp.dhis.scheduling.CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_LAST_6_MONTH;
-import static org.hisp.dhis.scheduling.CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_LAST_MONTH;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 import org.hibernate.Criteria;
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Projections;
@@ -69,7 +37,9 @@
 import org.hisp.dhis.caseaggregation.CaseAggregationConditionStore;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.GridHeader;
+import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.commons.util.TextUtils;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -89,15 +59,29 @@
 import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
-import org.hisp.dhis.commons.util.TextUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.jdbc.support.rowset.SqlRowSet;
 
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.*;
+import static org.hisp.dhis.scheduling.CaseAggregateConditionSchedulingManager.*;
+
 /**
  * @author Chau Thu Tran
- * 
  * @version HibernateCaseAggregationConditionStore.java Nov 18, 2010 9:36:20 AM
  */
 public class HibernateCaseAggregationConditionStore
@@ -142,20 +126,20 @@
 
     @Autowired
     DataValueService dataValueService;
-    
+
     @Autowired
     private PeriodService periodService;
-    
+
     @Autowired
     private OrganisationUnitService orgunitService;
 
     @Autowired
     private DataElementCategoryService categoryService;
-    
+
 
     @Autowired
     private TrackedEntityAttributeService attributeService;
-    
+
     // -------------------------------------------------------------------------
     // Implementation Methods
     // -------------------------------------------------------------------------
@@ -296,24 +280,24 @@
     }
 
     @Override
-    public void insertAggregateValue( String sql, DataElement dataElement, DataElementCategoryOptionCombo optionCombo, 
+    public void insertAggregateValue( String sql, DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
         DataElementCategoryOptionCombo attributeOptionCombo, Collection<Integer> orgunitIds, Period period )
-    {        
+    {
         try
         {
-            SqlRowSet row = jdbcTemplate.queryForRowSet(sql);
-            while (row.next())
+            SqlRowSet row = jdbcTemplate.queryForRowSet( sql );
+            while ( row.next() )
             {
-                int value = row.getInt("value");
+                int value = row.getInt( "value" );
                 OrganisationUnit source = orgunitService.getOrganisationUnit( row.getInt( "sourceid" ) );
-                
+
                 DataValue dataValue = dataValueService.getDataValue( dataElement, period, source, optionCombo );
-                
+
                 if ( dataValue == null )
                 {
                     dataValue = new DataValue( dataElement, period, source, optionCombo, attributeOptionCombo );
                     dataValue.setValue( value + "" );
-                    dataValue.setStoredBy( row.getString("storedby") );
+                    dataValue.setStoredBy( row.getString( "storedby" ) );
                     dataValueService.addDataValue( dataValue );
                 }
                 else if ( dataValue != null && value == 0 && !dataElement.isZeroIsSignificant() )
@@ -324,7 +308,7 @@
                 {
                     dataValue.setValue( value + "" );
                     dataValueService.updateDataValue( dataValue );
-                } 
+                }
             }
         }
         catch ( Exception ex )
@@ -332,18 +316,18 @@
             ex.printStackTrace();
         }
     }
-    
+
     @Override
     public void insertAggregateValue( String sql, int dataElementId, int optionComboId, Collection<Integer> orgunitIds,
         Period period )
     {
-         try
+        try
         {
             final String deleteDataValueSql = "delete from datavalue where dataelementid=" + dataElementId
                 + " and categoryoptioncomboid=" + optionComboId + " and sourceid in ("
                 + TextUtils.getCommaDelimitedString( orgunitIds ) + ") " + "and periodid = " + period.getId();
             jdbcTemplate.update( deleteDataValueSql );
-            
+
             jdbcTemplate.update( sql );
 
         }
@@ -352,7 +336,7 @@
             ex.printStackTrace();
         }
     }
-    
+
     @Override
     public String parseExpressionToSql( boolean isInsert, CaseAggregationCondition aggregationCondition,
         int attributeOptionComboId, Collection<Integer> orgunitIds )
@@ -371,7 +355,7 @@
 
     @Override
     public String parseExpressionToSql( boolean isInsert, String caseExpression, String operator, Integer aggregateDeId,
-        String aggregateDeName, Integer optionComboId, String optionComboName,  int attributeOptioncomboId, Integer deSumId,
+        String aggregateDeName, Integer optionComboId, String optionComboName, int attributeOptioncomboId, Integer deSumId,
         Collection<Integer> orgunitIds )
     {
         String select = "SELECT '" + aggregateDeId + "' as dataelementid, '" + optionComboId
@@ -449,9 +433,9 @@
             }
 
             sql += "GROUP BY ou.organisationunitid ) from organisationunit ou where ou.organisationunitid in ( " + TextUtils.getCommaDelimitedString( orgunitIds ) + " ) ";
-            
+
         }
-        
+
         return sql;
     }
 
@@ -469,44 +453,44 @@
         {
             orgunitIds.retainAll( _orgunitIds );
         }
-        
-        if (  !orgunitIds.isEmpty()  )
+
+        if ( !orgunitIds.isEmpty() )
         {
             String sql = "select caseaggregationconditionid, aggregationdataelementid, optioncomboid, "
                 + "aggregationexpression as caseexpression, operator as caseoperator, desum as desumid "
                 + "from caseaggregationcondition where caseaggregationconditionid = " + condition.getCaseAggregateId();
-            
+
             SqlRowSet rs = jdbcTemplate.queryForRowSet( sql );
-    
+
             if ( rs.next() )
             {
-                 String caseExpression = rs.getString( "caseexpression" );
-                 int dataElementId = rs.getInt( "aggregationdataelementid" );
-                 int optionComboId = rs.getInt( "optioncomboid" );
-                 String caseOperator = rs.getString( "caseoperator" );
-                 int deSumId = rs.getInt( "desumid" );
-                 String insertParamsSql = parseExpressionToSql( true, caseExpression, caseOperator, dataElementId, "de_name", optionComboId, "optioncombo_name", attributeOptioncomboId, deSumId, _orgunitIds );
-                 
+                String caseExpression = rs.getString( "caseexpression" );
+                int dataElementId = rs.getInt( "aggregationdataelementid" );
+                int optionComboId = rs.getInt( "optioncomboid" );
+                String caseOperator = rs.getString( "caseoperator" );
+                int deSumId = rs.getInt( "desumid" );
+                String insertParamsSql = parseExpressionToSql( true, caseExpression, caseOperator, dataElementId, "de_name", optionComboId, "optioncombo_name", attributeOptioncomboId, deSumId, _orgunitIds );
+
                 for ( Period period : periods )
                 {
                     String insertSql = replacePeriodSql( insertParamsSql, period );
                     insertAggregateValue( insertSql, dataElementId, optionComboId, _orgunitIds, period );
                 }
-    
+
             }
         }
     }
 
     /**
      * Return standard SQL from query builder formula
-     * 
+     *
      * @param caseExpression The query builder expression
-     * @param operator There are six operators, includes Number of persons,
-     *        Number of visits, Sum, Average, Minimum and Maximum of data
-     *        element values.
-     * @param deType Aggregate Data element type
-     * @param orgunitIds The ids of organisation units where to aggregate data
-     *        value
+     * @param operator       There are six operators, includes Number of persons,
+     *                       Number of visits, Sum, Average, Minimum and Maximum of data
+     *                       element values.
+     * @param deType         Aggregate Data element type
+     * @param orgunitIds     The ids of organisation units where to aggregate data
+     *                       value
      */
     private String createSQL( String caseExpression, String operator, Collection<Integer> orgunitIds )
     {
@@ -516,7 +500,7 @@
         StringBuffer sqlResult = new StringBuffer();
 
         String sqlOrgunitCompleted = "";
-        
+
         // Date dataElement - dateOfIncident/executionDate/enrollmentDate
 
         Map<Integer, String> minusDe1SQLMap = new HashMap<>();
@@ -529,18 +513,18 @@
             String programStageIdStr = matcherMinus.group( 2 );
             String dataElementId = matcherMinus.group( 3 );
             String dateProperty = matcherMinus.group( 5 );
-            String compareSide =  matcherMinus.group( 6 ) +  matcherMinus.group( 7 );
+            String compareSide = matcherMinus.group( 6 ) + matcherMinus.group( 7 );
 
             Integer programId = null;
             Integer programStageId = null;
-            if( !programIdStr.equals(IN_CONDITION_GET_ALL))
+            if ( !programIdStr.equals( IN_CONDITION_GET_ALL ) )
             {
-                programId =  Integer.parseInt( programIdStr );
+                programId = Integer.parseInt( programIdStr );
             }
-            
-            if( !programStageIdStr.equals(IN_CONDITION_GET_ALL))
+
+            if ( !programStageIdStr.equals( IN_CONDITION_GET_ALL ) )
             {
-                programStageId =  Integer.parseInt( programStageIdStr );
+                programStageId = Integer.parseInt( programStageIdStr );
             }
 
             minusDe1SQLMap.put(
@@ -553,7 +537,7 @@
 
             idxDe1++;
         }
-        
+
         // dateOfIncident/executionDate/enrollmentDate - Date dataElement
 
         Map<Integer, String> minusDe2SQLMap = new HashMap<>();
@@ -566,13 +550,13 @@
             String programIdStr = matcherMinusDE1.group( 3 );
             String programStageIdStr = matcherMinusDE1.group( 4 );
             String dataElementId = matcherMinusDE1.group( 5 );
-            String compareSide =  matcherMinusDE1.group( 6 ) +  matcherMinusDE1.group( 7 );
-            
+            String compareSide = matcherMinusDE1.group( 6 ) + matcherMinusDE1.group( 7 );
+
             Integer programId = null;
             Integer programStageId = null;
             if ( !programIdStr.equals( IN_CONDITION_GET_ALL ) )
             {
-                programId = Integer.parseInt(programIdStr );
+                programId = Integer.parseInt( programIdStr );
             }
 
             if ( !programStageIdStr.equals( IN_CONDITION_GET_ALL ) )
@@ -590,14 +574,14 @@
 
             idxDe2++;
         }
-           
+
         // Date dataElement - Date dataElement
 
         Map<Integer, String> minus2DeSQLMap = new HashMap<>();
         int idx2De = 0;
         Pattern patternMinus2 = Pattern.compile( CaseAggregationCondition.minus2DataelementRegExp );
         Matcher matcherMinus2 = patternMinus2.matcher( caseExpression );
-        
+
         while ( matcherMinus2.find() )
         {
             String[] ids1 = matcherMinus2.group( 2 ).split( SEPARATOR_ID );
@@ -609,10 +593,10 @@
                     matcherMinus2.group( 6 ) + matcherMinus2.group( 7 ) ) );
             caseExpression = caseExpression.replace( matcherMinus2.group( 0 ),
                 CaseAggregationCondition.MINUS_2DATAELEMENT_OPERATOR + "_" + idx2De );
-            
+
             idx2De++;
         }
-        
+
         // currentDate/ dateOfIncident/executionDate/enrollmentDate - Date attribute
 
         Map<Integer, String> minusAttr1SQLMap = new HashMap<>();
@@ -626,21 +610,21 @@
             String compareSide = matcherMinus3.group( 4 ) + matcherMinus3.group( 5 );
             minusAttr1SQLMap.put(
                 idxAttr1,
-                getConditionForMisusAttribute1( attributeId, property , compareSide ) );
+                getConditionForMisusAttribute1( attributeId, property, compareSide ) );
 
             caseExpression = caseExpression.replace( matcherMinus3.group( 0 ),
                 CaseAggregationCondition.MINUS_ATTRIBUTE_OPERATOR_TYPE_ONE + "_" + idxAttr1 );
 
             idxAttr1++;
         }
-        
-        
+
+
         // Date attribute - currentDate/ dateOfIncident/executionDate/enrollmentDate
 
         Map<Integer, String> minusAttr2SQLMap = new HashMap<>();
         int idxAttr2 = 0;
         Pattern patternAttr2Minus = Pattern.compile( CaseAggregationCondition.minusAttributeRegExp2 );
-       
+
         Matcher matcherAttr2Minus = patternAttr2Minus.matcher( caseExpression );
         while ( matcherAttr2Minus.find() )
         {
@@ -653,8 +637,8 @@
 
             idxAttr2++;
         }
-        
-        
+
+
         //  Date attribute - Date attribute
 
         Map<Integer, String> minus2AttrSQLMap = new HashMap<>();
@@ -674,7 +658,7 @@
             idx2Attr++;
         }
 
-        
+
         // Run nornal expression
         String[] expression = caseExpression.split( "(AND|OR)" );
         caseExpression = caseExpression.replaceAll( "AND", " ) AND " );
@@ -797,29 +781,29 @@
             sql = sql
                 .replace( CaseAggregationCondition.MINUS_2DATAELEMENT_OPERATOR + "_" + i, minus2DeSQLMap.get( i ) );
         }
-        
+
         for ( int i = 0; i < idxAttr1; i++ )
         {
             sql = sql
                 .replace( CaseAggregationCondition.MINUS_ATTRIBUTE_OPERATOR_TYPE_ONE + "_" + i, minusAttr1SQLMap.get( i ) );
         }
-        
+
         for ( int i = 0; i < idxAttr2; i++ )
         {
             sql = sql
                 .replace( CaseAggregationCondition.MINUS_ATTRIBUTE_OPERATOR_TYPE_TWO + "_" + i, minusAttr2SQLMap.get( i ) );
         }
-        
+
         for ( int i = 0; i < idx2Attr; i++ )
         {
             sql = sql
                 .replace( CaseAggregationCondition.MINUS_2ATTRIBUTE_OPERATOR + "_" + i, minus2AttrSQLMap.get( i ) );
         }
-        
-        sql = sql.replaceAll( CaseAggregationCondition.CURRENT_DATE, "now()");
-        
+
+        sql = sql.replaceAll( CaseAggregationCondition.CURRENT_DATE, "now()" );
+
         sql += " ) ";
-        if( hasDataelementCriteria( caseExpression ) )
+        if ( hasDataelementCriteria( caseExpression ) )
         {
             sql += " and psi.organisationunitid=ou.organisationunitid ";
         }
@@ -827,18 +811,17 @@
         {
             sql += " and pi.organisationunitid=ou.organisationunitid ";
         }
-        
+
         return sql;
     }
 
     /**
      * Return standard SQL of the expression to compare data value as null
-     * 
      */
     private String getConditionForDataElement( boolean isExist, int programId, String programStageId,
         int dataElementId, Collection<Integer> orgunitIds )
     {
-        String keyExist = (isExist == true) ? "EXISTS" : "NOT EXISTS";
+        String keyExist = isExist ? "EXISTS" : "NOT EXISTS";
 
         String sql = " " + keyExist + " ( SELECT * "
             + "FROM trackedentitydatavalue _pdv inner join programstageinstance _psi "
@@ -856,8 +839,9 @@
 
         if ( isExist )
         {
-            DataElement dataElement = dataElementService.getDataElement( dataElementId );
-            if ( dataElement.getType().equals( DataElement.VALUE_TYPE_INT ) )
+            ValueType valueType = dataElementService.getDataElement( dataElementId ).getValueType();
+
+            if ( valueType.isNumeric() )
             {
                 sql += " AND ( cast( _pdv.value as " + statementBuilder.getDoubleColumnType() + " )  ) ";
             }
@@ -878,7 +862,6 @@
     /**
      * Return standard SQL of a dynamic tracked-entity-attribute expression. E.g
      * [CA:1] OR [CA:1.age]
-     * 
      */
     private String getConditionForTrackedEntityAttribute( String attributeId, Collection<Integer> orgunitIds,
         boolean isExist )
@@ -912,7 +895,7 @@
 
             if ( isExist )
             {
-                TrackedEntityAttribute attribute =attributeService.getTrackedEntityAttribute( Integer.parseInt( attributeId ) );
+                TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( Integer.parseInt( attributeId ) );
                 if ( attribute.getValueType().equals( TrackedEntityAttribute.TYPE_NUMBER ) )
                 {
                     sql += " AND cast( _pav.value as " + statementBuilder.getDoubleColumnType() + " )  ";
@@ -939,7 +922,6 @@
     /**
      * Return standard SQL of the program-property expression. E.g
      * [PC:executionDate]
-     * 
      */
     private String getConditionForTrackedEntityProgramStageProperty( String propertyName, String operator )
     {
@@ -954,7 +936,6 @@
      * Return standard SQL of the program expression. E.g
      * [PP:DATE@enrollmentdate#-DATE@dateofincident#] for geting the number of
      * days between date of enrollment and date of incident.
-     * 
      */
     private String getConditionForProgramProperty( String operator, String property )
     {
@@ -970,7 +951,6 @@
     /**
      * Return standard SQL to retrieve the number of persons enrolled into the
      * program. E.g [PG:1]
-     * 
      */
     private String getConditionForProgram( String programId, String operator, Collection<Integer> orgunitIds )
     {
@@ -990,7 +970,6 @@
     /**
      * Return standard SQL to retrieve the number of visits a program-stage. E.g
      * [PS:1]
-     * 
      */
     private String getConditionForProgramStage( String programStageId, Collection<Integer> orgunitIds )
     {
@@ -1000,8 +979,8 @@
         {
             sql += "AND _psi.programstageid=" + programStageId;
         }
-        
-        sql+= "  AND _psi.executiondate >= '" + PARAM_PERIOD_START_DATE
+
+        sql += "  AND _psi.executiondate >= '" + PARAM_PERIOD_START_DATE
             + "' AND _psi.executiondate <= '" + PARAM_PERIOD_END_DATE + "' AND _psi.organisationunitid in ("
             + TextUtils.getCommaDelimitedString( orgunitIds ) + ")  ";
 
@@ -1012,7 +991,6 @@
      * Return standard SQL to retrieve the x-time of a person visited one
      * program-stage. E.g a mother came to a hospital 3th time for third
      * trimester.
-     * 
      */
     private String getConditionForCountProgramStage( String programStageId, String operator,
         Collection<Integer> orgunitIds )
@@ -1031,7 +1009,6 @@
     /**
      * Return standard SQL to retrieve the number of days between report-date
      * and due-date. E.g [PSP:DATE@executionDate#-DATE@dueDate#]
-     * 
      */
     private String getConditionForProgramStageProperty( String property, String operator, Collection<Integer> orgunitIds )
     {
@@ -1047,9 +1024,8 @@
     /**
      * Return standard SQL to retrieve the number of children orgunits has all
      * program-stage-instance completed and due-date. E.g [PSIC:1]
-     * 
+     *
      * @flag True if there are many stages in the expression
-     * 
      */
     private String getConditionForOrgunitProgramStageCompleted( String programStageId, String operator,
         Collection<Integer> orgunitIds, boolean flag )
@@ -1079,24 +1055,24 @@
             + "                  AND _pdv.dataelementid=" + dataElementId
             + "                 AND _psi.organisationunitid in (" + TextUtils.getCommaDelimitedString( orgunitIds )
             + ") ";
-        
-        
-        if (programId != null) 
+
+
+        if ( programId != null )
         {
             sql += " AND _pi.programid = " + programId;
         }
- 
-        if (programId != null)
+
+        if ( programId != null )
         {
             sql += " AND _psi.programstageid = " + programStageId;
         }
-               
+
         sql += " AND ( _psi.executionDate BETWEEN '" + PARAM_PERIOD_START_DATE + "' AND '" + PARAM_PERIOD_END_DATE
             + "') " + "                 AND ( DATE(_pdv.value) - DATE(" + dateProperty + ") " + compareSide + "  ) ";
-       
-       return sql;
+
+        return sql;
     }
-    
+
     private String getConditionForMinusDataElement2( Collection<Integer> orgunitIds, Integer programId, Integer programStageId,
         Integer dataElementId, String dateProperty, String compareSide )
     {
@@ -1107,22 +1083,22 @@
             + "                  AND _pdv.dataelementid=" + dataElementId
             + "                 AND _psi.organisationunitid in (" + TextUtils.getCommaDelimitedString( orgunitIds )
             + ") ";
-        
-        
-        if (programId != null) 
+
+
+        if ( programId != null )
         {
             sql += " AND _pi.programid = " + programId;
         }
- 
-        if (programId != null)
+
+        if ( programId != null )
         {
             sql += " AND _psi.programstageid = " + programStageId;
         }
-        
-       sql += " AND ( _psi.executionDate BETWEEN '" + PARAM_PERIOD_START_DATE + "' AND '" + PARAM_PERIOD_END_DATE
+
+        sql += " AND ( _psi.executionDate BETWEEN '" + PARAM_PERIOD_START_DATE + "' AND '" + PARAM_PERIOD_END_DATE
             + "') " + "                 AND ( DATE(" + dateProperty + ") - DATE(_pdv.value) " + compareSide + "  ) ";
-       
-       return sql;
+
+        return sql;
     }
 
     private String getConditionForMisus2DataElement( Collection<Integer> orgunitIds, String programStageId1,
@@ -1172,53 +1148,52 @@
             + " and  _teav.trackedentityattributeid =  " + attribute2 + " ) as a2 "
             + " WHERE DATE(a1.value ) - DATE(a2.value) " + compareSide;
     }
-    
+
     private String getConditionForMisusAttribute1( String attribute, String dateProperty, String compareSide )
     {
-        if( dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE ) 
-            ||  dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE ) )
-    {
-       return " EXISTS ( select * from trackedentityattributevalue _teav "
-           + "inner join programinstance _pi on _teav.trackedentityinstanceid=_pi.trackedentityinstanceid "
-           + "where _teav.trackedentityattributeid=" + attribute + " and date(" + dateProperty + ") - date(_teav.value) " + compareSide ;
-    }
-    else if( dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_REPORT_DATE ) )
-    {
-        return " EXISTS ( select * from trackedentityattributevalue _teav "
-            + "inner join programinstance _pi on _teav.trackedentityinstanceid=_pi.trackedentityinstanceid "
-            + "inner join programstageinstance _psi on _psi.programinstanceid=_pi.programinstanceid "
-            + "where _teav.trackedentityattributeid=" + attribute + " and date(" + dateProperty + ") - date(_teav.value) " + compareSide ;
-    }
-    
-     return " EXISTS (select * from trackedentityattributevalue _teav where _teav.trackedentityattributeid="
-        + attribute + " and date(now()) - date(_teav.value)  " + compareSide;
-    }
-    
+        if ( dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE )
+            || dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE ) )
+        {
+            return " EXISTS ( select * from trackedentityattributevalue _teav "
+                + "inner join programinstance _pi on _teav.trackedentityinstanceid=_pi.trackedentityinstanceid "
+                + "where _teav.trackedentityattributeid=" + attribute + " and date(" + dateProperty + ") - date(_teav.value) " + compareSide;
+        }
+        else if ( dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_REPORT_DATE ) )
+        {
+            return " EXISTS ( select * from trackedentityattributevalue _teav "
+                + "inner join programinstance _pi on _teav.trackedentityinstanceid=_pi.trackedentityinstanceid "
+                + "inner join programstageinstance _psi on _psi.programinstanceid=_pi.programinstanceid "
+                + "where _teav.trackedentityattributeid=" + attribute + " and date(" + dateProperty + ") - date(_teav.value) " + compareSide;
+        }
+
+        return " EXISTS (select * from trackedentityattributevalue _teav where _teav.trackedentityattributeid="
+            + attribute + " and date(now()) - date(_teav.value)  " + compareSide;
+    }
+
     private String getConditionForMisusAttribute2( String attribute, String dateProperty, String compareSide )
     {
-        if( dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE ) 
-                ||  dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE ) )
+        if ( dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE )
+            || dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE ) )
         {
-           return " EXISTS ( select * from trackedentityattributevalue _teav "
-               + "inner join programinstance _pi on _teav.trackedentityinstanceid=_pi.trackedentityinstanceid "
-               + "where _teav.trackedentityattributeid=" + attribute + " and date(_teav.value) - date(" + dateProperty + ") " + compareSide ;
+            return " EXISTS ( select * from trackedentityattributevalue _teav "
+                + "inner join programinstance _pi on _teav.trackedentityinstanceid=_pi.trackedentityinstanceid "
+                + "where _teav.trackedentityattributeid=" + attribute + " and date(_teav.value) - date(" + dateProperty + ") " + compareSide;
         }
-        else if( dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_REPORT_DATE ) )
+        else if ( dateProperty.equals( CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_REPORT_DATE ) )
         {
             return " EXISTS ( select * from trackedentityattributevalue _teav "
                 + "inner join programinstance _pi on _teav.trackedentityinstanceid=_pi.trackedentityinstanceid "
                 + "inner join programstageinstance _psi on _psi.programinstanceid=_pi.programinstanceid "
-                + "where _teav.trackedentityattributeid=" + attribute + " and date(_teav.value) - date(" + dateProperty + ") " + compareSide ;
+                + "where _teav.trackedentityattributeid=" + attribute + " and date(_teav.value) - date(" + dateProperty + ") " + compareSide;
         }
-        
-         return " EXISTS (select * from trackedentityattributevalue _teav where _teav.trackedentityattributeid="
+
+        return " EXISTS (select * from trackedentityattributevalue _teav where _teav.trackedentityattributeid="
             + attribute + " and date(_teav.value) - date(now()) " + compareSide;
     }
 
     /**
      * Return the Ids of organisation units which entity instances registered or
      * events happened.
-     * 
      */
     @Override
     public Collection<Integer> getServiceOrgunit()
@@ -1354,8 +1329,8 @@
 
         CalendarPeriodType periodType = (CalendarPeriodType) PeriodType.getPeriodTypeByName( periodTypeName );
         List<Period> periods = new ArrayList<Period>( periodType.generatePeriods( startDate, endDate ) );
-        periods = periodService.reloadPeriods(periods );
-       
+        periods = periodService.reloadPeriods( periods );
+
         return periods;
     }
 
@@ -1424,7 +1399,7 @@
 
         return false;
     }
-   
+
     private String replacePeriodSql( String sql, Period period )
     {
         sql = sql.replaceAll( "COMBINE", "" );
@@ -1434,5 +1409,5 @@
         sql = sql.replaceAll( PARAM_PERIOD_ISO_DATE, period.getIsoDate() );
 
         return sql;
-    }    
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dataelementhistory/DefaultHistoryRetriever.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dataelementhistory/DefaultHistoryRetriever.java	2015-03-31 08:46:53 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dataelementhistory/DefaultHistoryRetriever.java	2015-09-01 06:14:53 +0000
@@ -28,8 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.List;
-
 import org.apache.commons.math3.util.Precision;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -41,6 +39,8 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 
+import java.util.List;
+
 /**
  * @author Torgeir Lorange Ostby
  */
@@ -80,7 +80,7 @@
     public DataElementHistory getHistory( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
         OrganisationUnit organisationUnit, Period lastPeriod, int historyLength )
     {
-        if ( !dataElement.getType().equals( DataElement.VALUE_TYPE_INT ) )
+        if ( !dataElement.getValueType().isNumeric() )
         {
             return null; // TODO
         }
@@ -172,10 +172,10 @@
     /**
      * Finds the lowest value entered in the periode given by
      * history.historyLenght.
-     * 
+     *
      * @param history DataElementHistory
      * @return the lowest Double value entred. If no values are entred,
-     *         Double.MAX_VALUE is returned
+     * Double.MAX_VALUE is returned
      */
     private Double getMinValue( DataElementHistory history )
     {
@@ -199,10 +199,10 @@
     /**
      * Finds the highest value entered in the periode given by
      * history.historyLenght.
-     * 
+     *
      * @param history DataElementHistory
      * @return the highest entred value. If no value is entred
-     *         Double.NEGATIVE_INFINITY is returned
+     * Double.NEGATIVE_INFINITY is returned
      */
     private Double getMaxValue( DataElementHistory history )
     {

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.java	2015-02-22 20:02:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.java	2015-09-01 06:14:53 +0000
@@ -28,13 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 import jxl.Workbook;
 import jxl.WorkbookSettings;
 import jxl.format.Colour;
@@ -46,7 +39,6 @@
 import jxl.write.WritableWorkbook;
 import jxl.write.WriteException;
 import jxl.write.biff.RowsExceededException;
-
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.GridHeader;
 import org.hisp.dhis.databrowser.MetaValue;
@@ -57,6 +49,13 @@
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author Dang Duy Hieu
  * @version $Id$
@@ -67,10 +66,10 @@
 
     public static final WritableCellFormat FORMAT_LABEL = new WritableCellFormat( new WritableFont( WritableFont.ARIAL, 13,
         WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK ) );
-    
+
     public static final WritableCellFormat FORMAT_TEXT = new WritableCellFormat( new WritableFont( WritableFont.ARIAL, 11,
         WritableFont.NO_BOLD, false ) );
-    
+
     public static void printDataElementHeaders( WritableSheet sheet, I18n i18n, int row,
         int column )
         throws RowsExceededException, WriteException
@@ -143,7 +142,7 @@
 
     }
 
-    public static void addOrganisationUnitCellToSheet( WritableSheet sheet, 
+    public static void addOrganisationUnitCellToSheet( WritableSheet sheet,
         OrganisationUnit unit, I18n i18n, I18nFormat i18nFormat, int row, int column )
         throws RowsExceededException, WriteException
     {
@@ -224,7 +223,7 @@
             for ( GridHeader col : grid.getVisibleHeaders() )
             {
                 //TODO use i18nFormat.formatDate for label
-                
+
                 sheet.addCell( new Label( column++, 3, col.getName(), cellFormat ) );
             }
         }
@@ -265,8 +264,8 @@
 
                 for ( Object rowItem : rows )
                 {
-                    String temp = (String)rowItem;
-                    
+                    String temp = (String) rowItem;
+
                     if ( temp == null )
                     {
                         temp = "";
@@ -296,9 +295,9 @@
 
     /**
      * Creates a writable workbook.
-     * 
+     *
      * @param outputStream The output stream to write the document content.
-     * @param pageSize the page size.
+     * @param pageSize     the page size.
      * @return A Document.
      */
     public static WritableWorkbook openWorkbook( OutputStream outputStream )
@@ -307,7 +306,7 @@
         {
             WorkbookSettings ws = new WorkbookSettings();
             ws.setEncoding( "UTF-8" );
-            
+
             return Workbook.createWorkbook( outputStream, ws );
         }
         catch ( IOException e )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/caseaggregation/GetAggPSDataElementsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/caseaggregation/GetAggPSDataElementsAction.java	2015-06-16 17:43:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/caseaggregation/GetAggPSDataElementsAction.java	2015-09-01 06:14:53 +0000
@@ -28,19 +28,17 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Iterator;
-import java.util.List;
-
+import com.opensymphony.xwork2.Action;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageService;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import com.opensymphony.xwork2.Action;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author Chau Thu Tran
- * 
  * @version $Id: GetAggPSDataElementsAction.java Dec 22, 2011 9:24:49 AM $
  */
 public class GetAggPSDataElementsAction
@@ -63,7 +61,7 @@
     {
         this.psId = psId;
     }
-    
+
     public Integer getPsId()
     {
         return psId;
@@ -84,7 +82,7 @@
     public String execute()
     {
         ProgramStage stage = programStageService.getProgramStage( psId );
-        
+
         dataElementList = stage.getAllDataElements();
 
         if ( dataElementList != null && !dataElementList.isEmpty() )
@@ -95,7 +93,7 @@
             {
                 DataElement de = deIterator.next();
 
-                if ( !de.getType().equals( DataElement.VALUE_TYPE_INT ) )
+                if ( !de.getValueType().isNumeric() )
                 {
                     deIterator.remove();
                 }

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetFilteredDataElementsAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetFilteredDataElementsAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetFilteredDataElementsAction.java	2015-09-01 06:14:53 +0000
@@ -28,14 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
+import com.opensymphony.xwork2.Action;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -45,7 +38,13 @@
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 
-import com.opensymphony.xwork2.Action;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
 
 /**
  * @author Lars Helge Overland
@@ -104,7 +103,7 @@
     {
         return periodTypeName;
     }
-    
+
     private String filter;
 
     public void setFilter( String filter )
@@ -154,7 +153,7 @@
             List<DataSet> dataSets = new ArrayList<>( dataSetService.getDataSetsByPeriodType( periodType ) );
 
             Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE );
-            
+
             // -----------------------------------------------------------------
             // Get available dataelements into the dataSets
             // -----------------------------------------------------------------
@@ -163,10 +162,10 @@
 
             for ( DataSet dataSet : dataSets )
             {
-                 members.addAll( dataSet.getDataElements() );
+                members.addAll( dataSet.getDataElements() );
             }
 
-            dataElements = new ArrayList<>(getIntegerDataElements( members ));
+            dataElements = new ArrayList<>( getIntegerDataElements( members ) );
         }
         else
         {
@@ -212,7 +211,7 @@
 
         while ( iterator.hasNext() )
         {
-            if ( !iterator.next().getType().equals( DataElement.VALUE_TYPE_INT ) )
+            if ( !iterator.next().getValueType().isNumeric() )
             {
                 iterator.remove();
             }