← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13334: Introduced a new association to category option combo on DataValue called attributeOptionCombo. T...

 

------------------------------------------------------------
revno: 13334
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-12-19 19:12:57 +0100
message:
  Introduced a new association to category option combo on DataValue called attributeOptionCombo. This to allow persistence of information (attributes) common for a data set/form, like implementing partner or project.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/J2MEDataValueSMSListener.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueDimensionTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueServiceTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueStoreTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodServiceTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaServiceTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/DataMartServiceMultiDimensionTest.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataValueImporter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectService.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java
  dhis-2/dhis-support/dhis-support-jdbc-test/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandlerTest.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandler.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/SaveAggregateDataValueAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRepresentativeAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/history/DefaultHistoryRetriever.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationResultDetailsAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/EditDataValueAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/MarkForFollowupAction.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java	2013-12-19 09:06:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java	2013-12-19 18:12:57 +0000
@@ -55,26 +55,16 @@
     public static final String TRUE = "true";
     public static final String FALSE = "false";
 
-    /**
-     * Part of the DataValue's composite ID
-     */
     private DataElement dataElement;
 
-    /**
-     * Part of the DataValue's composite ID
-     */
     private Period period;
 
-    /**
-     * Part of the DataValue's composite ID
-     */
     private OrganisationUnit source;
 
-    /**
-     * Part of the DataValue's composite ID
-     */
     private DataElementCategoryOptionCombo categoryOptionCombo;
 
+    private DataElementCategoryOptionCombo attributeOptionCombo;
+
     private String value;
 
     private String storedBy;
@@ -99,12 +89,14 @@
      * @param source the organisation unit.
      * @param categoryOptionCombo the category option combo.
      */
-    public DataValue( DataElement dataElement, Period period, OrganisationUnit source, DataElementCategoryOptionCombo categoryOptionCombo )
+    public DataValue( DataElement dataElement, Period period, OrganisationUnit source, 
+        DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo )
     {
         this.dataElement = dataElement;
         this.period = period;
         this.source = source;
         this.categoryOptionCombo = categoryOptionCombo;
+        this.attributeOptionCombo = attributeOptionCombo;
     }
 
     /**
@@ -112,18 +104,20 @@
      * @param period the period.
      * @param source the organisation unit.
      * @param categoryOptionCombo the category option combo.
+     * @param attributeOptionCombo the attribute option combo.
      * @param value the value.
      * @param storedBy the user that stored this data value.
      * @param timestamp the time of creation of this data value.
      * @param comment the comment.
      */
     public DataValue( DataElement dataElement, Period period, OrganisationUnit source, DataElementCategoryOptionCombo categoryOptionCombo, 
-        String value, String storedBy, Date timestamp, String comment )
+        DataElementCategoryOptionCombo attributeOptionCombo, String value, String storedBy, Date timestamp, String comment )
     {
         this.dataElement = dataElement;
         this.period = period;
         this.source = source;
         this.categoryOptionCombo = categoryOptionCombo;
+        this.attributeOptionCombo = attributeOptionCombo;
         this.value = value;
         this.storedBy = storedBy;
         this.timestamp = timestamp;
@@ -280,6 +274,16 @@
         return value;
     }
 
+    public DataElementCategoryOptionCombo getAttributeOptionCombo()
+    {
+        return attributeOptionCombo;
+    }
+
+    public void setAttributeOptionCombo( DataElementCategoryOptionCombo attributeOptionCombo )
+    {
+        this.attributeOptionCombo = attributeOptionCombo;
+    }
+
     public void setValue( String value )
     {
         this.value = value;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java	2013-10-08 17:20:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java	2013-12-19 18:12:57 +0000
@@ -102,18 +102,26 @@
     /**
      * Returns a DataValue.
      * 
-     * @param source the Source of the DataValue.
      * @param dataElement the DataElement of the DataValue.
      * @param period the Period of the DataValue.
+     * @param source the Source of the DataValue.
+     * @param categoryOptionCombo the category option combo.
+     * @param attributeOptionCombo the attribute option combo.
      * @return the DataValue which corresponds to the given parameters, or null
      *         if no match.
      */
-    DataValue getDataValue( OrganisationUnit source, DataElement dataElement, Period period, DataElementCategoryOptionCombo optionCombo );
+    DataValue getDataValue( DataElement dataElement, Period period, OrganisationUnit source, DataElementCategoryOptionCombo optionCombo );
 
     /**
-     * Returns a non-persisted data value.
+     * Returns a non-persisted DataValue.
+     * 
+     * @param dataElementId data element id
+     * @param periodId period id
+     * @param sourceId source id
+     * @param categoryOptionComboId category option combo id
+     * @param attributeOptionComboId attribute option combo id
      */
-    DataValue getDataValue( int dataElementId, int categoryOptionComboId, int periodId, int sourceId );
+    DataValue getDataValue( int dataElementId, int periodId, int sourceId, int categoryOptionComboId );
     
     // -------------------------------------------------------------------------
     // Collections of DataValues

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java	2013-10-08 17:20:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java	2013-12-19 18:12:57 +0000
@@ -93,18 +93,27 @@
     /**
      * Returns a DataValue.
      * 
-     * @param source the Source of the DataValue.
      * @param dataElement the DataElement of the DataValue.
      * @param period the Period of the DataValue.
+     * @param source the Source of the DataValue.
+     * @param categoryOptionCombo the category option combo.
+     * @param attributeOptionCombo the attribute option combo.
      * @return the DataValue which corresponds to the given parameters, or null
      *         if no match.
      */
-    DataValue getDataValue( OrganisationUnit source, DataElement dataElement, Period period, DataElementCategoryOptionCombo optionCombo );
+    DataValue getDataValue( DataElement dataElement, Period period, OrganisationUnit source, 
+        DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo );
 
     /**
      * Returns a non-persisted DataValue.
+     * 
+     * @param dataElementId data element id
+     * @param periodId period id
+     * @param sourceId source id
+     * @param categoryOptionComboId category option combo id
+     * @param attributeOptionComboId attribute option combo id
      */
-    DataValue getDataValue( int dataElementId, int categoryOptionComboId, int periodId, int sourceId );
+    DataValue getDataValue( int dataElementId, int periodId, int sourceId, int categoryOptionComboId, int attributeOptionComboId );
     
     // -------------------------------------------------------------------------
     // Collections of DataValues
@@ -173,7 +182,7 @@
      *         Period, and any of the DataElements, or an empty collection if no
      *         values match.
      */
-    Collection<DataValue> getDataValues( OrganisationUnit source, Period period, Collection<DataElement> dataElements, Collection<DataElementCategoryOptionCombo> optionCombos );
+    Collection<DataValue> getDataValues( OrganisationUnit source, Period period, Collection<DataElement> dataElements, Collection<DataElementCategoryOptionCombo> categoryOptionCombos );
     
     /**
      * Returns all DataValues for a given DataElement, Period, and collection of 
@@ -211,7 +220,7 @@
      * @return a collection of all DataValues which match the given DataElement,
      *         Periods, and Sources.
      */
-    Collection<DataValue> getDataValues( DataElement dataElement, DataElementCategoryOptionCombo optionCombo, 
+    Collection<DataValue> getDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombos, 
         Collection<Period> periods, Collection<OrganisationUnit> sources );
     
     /**
@@ -221,7 +230,7 @@
      * @return a collection of all DataValues which match the given collection of
      *         DataElementCategoryOptionCombos.
      */
-    Collection<DataValue> getDataValues( Collection<DataElementCategoryOptionCombo> optionCombos );
+    Collection<DataValue> getDataValues( Collection<DataElementCategoryOptionCombo> categoryOptionCombos );
     
     /**
      * Returns all DataValues for a given collection of DataElements.

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java	2013-10-08 17:20:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java	2013-12-19 18:12:57 +0000
@@ -37,6 +37,7 @@
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementOperand;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
@@ -61,6 +62,13 @@
         this.dataValueStore = dataValueStore;
     }
 
+    private DataElementCategoryService categoryService;
+
+    public void setCategoryService( DataElementCategoryService categoryService )
+    {
+        this.categoryService = categoryService;
+    }
+
     // -------------------------------------------------------------------------
     // Basic DataValue
     // -------------------------------------------------------------------------
@@ -69,6 +77,16 @@
     {
         if ( !dataValue.isNullValue() && dataValueIsValid( dataValue.getValue(), dataValue.getDataElement() ) == null )
         {
+            if ( dataValue.getCategoryOptionCombo() == null )
+            {
+                dataValue.setCategoryOptionCombo( categoryService.getDefaultDataElementCategoryOptionCombo() );
+            }
+            
+            if ( dataValue.getAttributeOptionCombo() == null )
+            {
+                dataValue.setAttributeOptionCombo( categoryService.getDefaultDataElementCategoryOptionCombo() );
+            }
+            
             dataValueStore.addDataValue( dataValue );
         }
     }
@@ -103,15 +121,18 @@
         return dataValueStore.deleteDataValuesByDataElement( dataElement );
     }
 
-    public DataValue getDataValue( OrganisationUnit source, DataElement dataElement, Period period,
-        DataElementCategoryOptionCombo optionCombo )
+    public DataValue getDataValue( DataElement dataElement, Period period, OrganisationUnit source, DataElementCategoryOptionCombo categoryOptionCombo )
     {
-        return dataValueStore.getDataValue( source, dataElement, period, optionCombo );
+        DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+        
+        return dataValueStore.getDataValue( dataElement, period, source, categoryOptionCombo, defaultOptionCombo );
     }
     
-    public DataValue getDataValue( int dataElementId, int categoryOptionComboId, int periodId, int sourceId )
+    public DataValue getDataValue( int dataElementId, int periodId, int sourceId, int categoryOptionComboId )
     {
-        return dataValueStore.getDataValue( dataElementId, categoryOptionComboId, periodId, sourceId );
+        DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+        
+        return dataValueStore.getDataValue( dataElementId, periodId, sourceId, categoryOptionComboId, defaultOptionCombo.getId() );
     }
     
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java	2013-12-19 08:23:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java	2013-12-19 18:12:57 +0000
@@ -148,8 +148,8 @@
         return query.executeUpdate();
     }
 
-    public DataValue getDataValue( OrganisationUnit source, DataElement dataElement, Period period,
-        DataElementCategoryOptionCombo optionCombo )
+    public DataValue getDataValue( DataElement dataElement, Period period, OrganisationUnit source, 
+        DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo )
     {
         Session session = sessionFactory.getCurrentSession();
 
@@ -164,19 +164,21 @@
         criteria.add( Restrictions.eq( "source", source ) );
         criteria.add( Restrictions.eq( "dataElement", dataElement ) );
         criteria.add( Restrictions.eq( "period", storedPeriod ) );
-        criteria.add( Restrictions.eq( "categoryOptionCombo", optionCombo ) );
+        criteria.add( Restrictions.eq( "categoryOptionCombo", categoryOptionCombo ) );
+        criteria.add( Restrictions.eq( "attributeOptionCombo", attributeOptionCombo ) );
 
         return (DataValue) criteria.uniqueResult();
     }
     
-    public DataValue getDataValue( int dataElementId, int categoryOptionComboId, int periodId, int sourceId )
+    public DataValue getDataValue( int dataElementId, int periodId, int sourceId, int categoryOptionComboId, int attributeOptionComboId )
     {
         final String sql =
             "SELECT * FROM datavalue " +
             "WHERE dataelementid = " + dataElementId + " " +
+            "AND periodid = " + periodId + " " +
+            "AND sourceid = " + sourceId + " " +
             "AND categoryoptioncomboid = " + categoryOptionComboId + " " +
-            "AND periodid = " + periodId + " " +
-            "AND sourceid = " + sourceId;
+            "AND attributeoptioncomboid = " + attributeOptionComboId;
         
         try
         {
@@ -272,11 +274,11 @@
 
     @SuppressWarnings( "unchecked" )
     public Collection<DataValue> getDataValues( OrganisationUnit source, Period period, Collection<DataElement> dataElements,
-        Collection<DataElementCategoryOptionCombo> optionCombos )
+        Collection<DataElementCategoryOptionCombo> categoryOptionCombos )
     {
         Period storedPeriod = periodStore.reloadPeriod( period );
 
-        if ( storedPeriod == null || dataElements == null || dataElements.isEmpty() || optionCombos == null || optionCombos.isEmpty() )
+        if ( storedPeriod == null || dataElements == null || dataElements.isEmpty() || categoryOptionCombos == null || categoryOptionCombos.isEmpty() )
         {
             return Collections.emptySet();
         }
@@ -287,7 +289,7 @@
         criteria.add( Restrictions.eq( "source", source ) );
         criteria.add( Restrictions.eq( "period", storedPeriod ) );
         criteria.add( Restrictions.in( "dataElement", dataElements ) );
-        criteria.add( Restrictions.in( "categoryOptionCombo", optionCombos ) );
+        criteria.add( Restrictions.in( "categoryOptionCombo", categoryOptionCombos ) );
 
         return criteria.list();
     }
@@ -345,7 +347,7 @@
     }
 
     @SuppressWarnings( "unchecked" )
-    public Collection<DataValue> getDataValues( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
+    public Collection<DataValue> getDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo,
         Collection<Period> periods, Collection<OrganisationUnit> sources )
     {
         Collection<Period> storedPeriods = new ArrayList<Period>();
@@ -369,7 +371,7 @@
 
         Criteria criteria = session.createCriteria( DataValue.class );
         criteria.add( Restrictions.eq( "dataElement", dataElement ) );
-        criteria.add( Restrictions.eq( "categoryOptionCombo", optionCombo ) );
+        criteria.add( Restrictions.eq( "categoryOptionCombo", categoryOptionCombo ) );
         criteria.add( Restrictions.in( "period", storedPeriods ) );
         criteria.add( Restrictions.in( "source", sources ) );
 
@@ -377,17 +379,17 @@
     }
 
     @SuppressWarnings( "unchecked" )
-    public Collection<DataValue> getDataValues( Collection<DataElementCategoryOptionCombo> optionCombos )
+    public Collection<DataValue> getDataValues( Collection<DataElementCategoryOptionCombo> categoryOptionCombos )
     {
         Session session = sessionFactory.getCurrentSession();
 
-        if ( optionCombos == null || optionCombos.isEmpty() )
+        if ( categoryOptionCombos == null || categoryOptionCombos.isEmpty() )
         {
             return new HashSet<DataValue>();
         }
         
         Criteria criteria = session.createCriteria( DataValue.class );
-        criteria.add( Restrictions.in( "categoryOptionCombo", optionCombos ) );
+        criteria.add( Restrictions.in( "categoryOptionCombo", categoryOptionCombos ) );
 
         return criteria.list();
     }
@@ -459,12 +461,12 @@
         while ( rowSet.next() )
         {
             String dataElement = rowSet.getString( 1 );
-            String optionCombo = rowSet.getString( 2 );
+            String categoryOptionCombo = rowSet.getString( 2 );
             Double value = MathUtils.parseDouble( rowSet.getString( 3 ) );
             
             if ( value != null )
             {
-                map.put( new DataElementOperand( dataElement, optionCombo ), value );
+                map.put( new DataElementOperand( dataElement, categoryOptionCombo ), value );
             }
         }
         
@@ -500,7 +502,7 @@
         while ( rowSet.next() )
         {
             String dataElement = rowSet.getString( 1 );
-            String optionCombo = rowSet.getString( 2 );
+            String categoryOptionCombo = rowSet.getString( 2 );
             Double value = MathUtils.parseDouble( rowSet.getString( 3 ) );
             Date lastUpdated = rowSet.getDate( 4 );
             Date periodStartDate = rowSet.getDate( 5 );
@@ -511,7 +513,7 @@
 
             if ( value != null )
             {
-                DataElementOperand dataElementOperand = new DataElementOperand( dataElement, optionCombo );
+                DataElementOperand dataElementOperand = new DataElementOperand( dataElement, categoryOptionCombo );
                 Long existingPeriodInterval = checkForDuplicates.get( dataElementOperand );
                 
                 if ( existingPeriodInterval != null && existingPeriodInterval < periodInterval )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java	2013-12-19 08:23:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java	2013-12-19 18:12:57 +0000
@@ -333,7 +333,7 @@
 
         Period period = getPeriod( command, date );
 
-        DataValue dv = dataValueService.getDataValue( orgunit, code.getDataElement(), period, optionCombo );
+        DataValue dv = dataValueService.getDataValue( code.getDataElement(), period, orgunit, optionCombo );
 
         String value = parsedMessage.get( upperCaseCode );
         
@@ -454,7 +454,7 @@
 
             period = getPeriod( command, date );
 
-            DataValue dv = dataValueService.getDataValue( orgunit, code.getDataElement(), period, optionCombo );
+            DataValue dv = dataValueService.getDataValue( code.getDataElement(), period, orgunit, optionCombo );
 
             if ( dv == null && !StringUtils.isEmpty( code.getCode() ) )
             {
@@ -493,7 +493,7 @@
 
             period = getPeriod( command, date );
 
-            DataValue dv = dataValueService.getDataValue( orgunit, code.getDataElement(), period, optionCombo );
+            DataValue dv = dataValueService.getDataValue( code.getDataElement(), period, orgunit, optionCombo );
 
             if ( dv == null && !StringUtils.isEmpty( code.getCode() ) )
             {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/J2MEDataValueSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/J2MEDataValueSMSListener.java	2013-12-19 08:23:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/J2MEDataValueSMSListener.java	2013-12-19 18:12:57 +0000
@@ -198,7 +198,7 @@
         DataElementCategoryOptionCombo optionCombo = dataElementCategoryService.getDataElementCategoryOptionCombo( code
             .getOptionId() );
 
-        DataValue dv = dataValueService.getDataValue( orgUnit, code.getDataElement(), period, optionCombo );
+        DataValue dv = dataValueService.getDataValue( code.getDataElement(), period, orgUnit, optionCombo );
 
         String value = parsedMessage.get( upperCaseCode );
         if ( !StringUtils.isEmpty( value ) )
@@ -357,7 +357,7 @@
             DataElementCategoryOptionCombo optionCombo = dataElementCategoryService
                 .getDataElementCategoryOptionCombo( code.getOptionId() );
 
-            DataValue dv = dataValueService.getDataValue( orgunit, code.getDataElement(), period, optionCombo );
+            DataValue dv = dataValueService.getDataValue( code.getDataElement(), period, orgunit, optionCombo );
 
             if ( dv == null && !StringUtils.isEmpty( code.getCode() ) )
             {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java	2013-12-13 16:03:24 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java	2013-12-19 18:12:57 +0000
@@ -166,9 +166,10 @@
     @Override
     public int countDataSetSmsCommands( DataSet dataSet )
     {
-        Query query = getQuery( "select count(distinct c) from SMSCommand c where c.dataSet=:dataSet", true );
+        Query query = getQuery( "select count(distinct c) from SMSCommand c where c.dataset=:dataSet", true );
         query.setEntity( "dataSet", dataSet );
-
+        //TODO rename dataset prop
+        
         return ((Long) query.uniqueResult()).intValue();
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2013-12-14 13:17:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2013-12-19 18:12:57 +0000
@@ -42,6 +42,8 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -651,11 +653,37 @@
         executeSql( "ALTER TABLE dataset DROP COLUMN symbol" );
 	executeSql( "ALTER TABLE users ALTER COLUMN password DROP NOT NULL" );
 
+	upgradeDataValuesWithAttributeOptionCombo();
         upgradeMapViewsToAnalyticalObject();
 
         log.info( "Tables updated" );
     }
 
+    private void upgradeDataValuesWithAttributeOptionCombo()
+    {
+        if ( columnExists( "datavalue", "attributeoptioncomboid" ) )
+        {
+            return;
+        }
+        
+        int optionComboId = getDefaultOptionCombo();
+        
+        executeSql( "alter table datavalue_audit drop constraint fk_datavalueaudit_datavalue;" );
+
+        executeSql( "alter table datavalue drop constraint datavalue_pkey;" );
+
+        executeSql( "alter table datavalue add column attributeoptioncomboid integer;" );
+        executeSql( "update datavalue set attributeoptioncomboid = " + optionComboId + " where attributeoptioncomboid is null;" );
+        executeSql( "alter table datavalue alter column attributeoptioncomboid set not null;" );
+        executeSql( "alter table datavalue add constraint fk_datavalue_attributeoptioncomboid foreign key (attributeoptioncomboid) references categoryoptioncombo (categoryoptioncomboid) match simple;" );
+        executeSql( "alter table datavalue add constraint datavalue_pkey primary key(dataelementid, periodid, sourceid, categoryoptioncomboid, attributeoptioncomboid);" );
+        
+        executeSql( "alter table datavalue_audit add constraint fk_datavalueaudit_datavalue foreign key (dataelementid, periodid, sourceid, categoryoptioncomboid, attributeoptioncomboid) " + 
+            "references datavalue (dataelementid, periodid, sourceid, categoryoptioncomboid, attributeoptioncomboid) match simple;" );
+        
+        log.info( "Data value table upgraded with attributeoptioncomboid column" );
+    }
+    
     private void upgradeMapViewsToAnalyticalObject()
     {
         executeSql( "insert into mapview_dataelements ( mapviewid, sort_order, dataelementid ) select mapviewid, 0, dataelementid from mapview where dataelementid is not null" );
@@ -997,6 +1025,8 @@
     {
         try
         {
+            //TODO use jdbcTemplate
+            
             return statementManager.getHolder().executeUpdate( sql );
         }
         catch ( Exception ex )
@@ -1007,6 +1037,40 @@
         }
     }
 
+    private boolean columnExists( String table, String column )
+    {
+        try
+        {
+            ResultSetMetaData metaData = statementManager.getHolder().getStatement().executeQuery( "select * from datavalue limit 1" ).getMetaData();
+            
+            for ( int i = 1; i <= metaData.getColumnCount(); i++ )
+            {
+                if ( column.equalsIgnoreCase( metaData.getColumnName( i ) ) )
+                {
+                    return true;
+                }
+            }
+        }
+        catch ( SQLException ex )
+        {
+            log.error( "Column detection failed: " + ex.getMessage() );
+            log.error( ex );
+        }
+        
+        return false;
+    }
+    
+    private int getDefaultOptionCombo()
+    {
+        String sql = 
+            "select coc.categoryoptioncomboid from categoryoptioncombo coc " +
+            "inner join categorycombos_optioncombos cco on coc.categoryoptioncomboid=cco.categoryoptioncomboid " +
+            "inner join categorycombo cc on cco.categorycomboid=cc.categorycomboid " +
+            "where cc.name='default';";
+        
+        return statementManager.getHolder().queryForInteger( sql );
+    }
+    
     private boolean updateDataSetAssociation()
     {
         StatementHolder holder = statementManager.getHolder();
@@ -1044,7 +1108,6 @@
         {
             holder.close();
         }
-
     }
 
     private boolean updateProgramStageAssociation()

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2013-12-17 11:18:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2013-12-19 18:12:57 +0000
@@ -367,6 +367,7 @@
 
   <bean id="org.hisp.dhis.datavalue.DataValueService" class="org.hisp.dhis.datavalue.DefaultDataValueService">
     <property name="dataValueStore" ref="org.hisp.dhis.datavalue.DataValueStore" />
+    <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
   </bean>
 
   <bean id="org.hisp.dhis.datavalue.DataValueAuditService" class="org.hisp.dhis.datavalue.DefaultDataValueAuditService">

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml	2013-12-19 08:23:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml	2013-12-19 18:12:57 +0000
@@ -10,7 +10,8 @@
       <key-many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement" column="dataelementid" foreign-key="fk_datavalue_dataelementid" />
       <key-many-to-one name="period" class="org.hisp.dhis.period.Period" column="periodid" foreign-key="fk_datavalue_periodid" />      
       <key-many-to-one name="source" class="org.hisp.dhis.organisationunit.OrganisationUnit" column="sourceid" foreign-key="fk_datavalue_organisationunitid" />
-      <key-many-to-one name="categoryOptionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" column="categoryoptioncomboid" foreign-key="fk_datavalue_categoryoptioncomboid" />
+      <key-many-to-one name="categoryOptionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" column="categoryoptioncomboid" foreign-key="fk_datavalue_categoryoptioncomboid" />
+      <key-many-to-one name="attributeOptionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" column="attributeoptioncomboid" foreign-key="fk_datavalue_attributeoptioncomboid" />
     </composite-id>
 
     <property name="value" length="255" />

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml	2013-09-26 12:05:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml	2013-12-19 18:12:57 +0000
@@ -15,6 +15,7 @@
       <column name="periodid" />
       <column name="sourceid" />
       <column name="categoryoptioncomboid" />
+      <column name="attributeoptioncomboid" />
     </many-to-one>
 
     <property name="value" />

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueDimensionTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueDimensionTest.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueDimensionTest.java	2013-12-19 18:12:57 +0000
@@ -68,6 +68,8 @@
     
     private DataElementCategoryCombo genderAndAgeGroup;
     
+    private DataElementCategoryOptionCombo defaultOptionCombo;
+    
     private DataElement dataElementA;
     
     private Period periodA;
@@ -82,6 +84,7 @@
         dataValueService = (DataValueService) getBean( DataValueService.ID );
         periodService = (PeriodService) getBean( PeriodService.ID );
         organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
+        categoryService = (DataElementCategoryService) getBean( DataElementCategoryService.ID );
         
         male = new DataElementCategoryOption( "Male" );
         female = new DataElementCategoryOption( "Female" );
@@ -124,9 +127,11 @@
         
         organisationUnitService.addOrganisationUnit( sourceA );
         
+        defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+        
         for ( DataElementCategoryOptionCombo categoryOptionCombo : genderAndAgeGroup.getOptionCombos() )
         {
-            dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "10", categoryOptionCombo ) );
+            dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "10", categoryOptionCombo, defaultOptionCombo ) );
         }
     }
     
@@ -139,7 +144,7 @@
         
         DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( categoryOptions );
         
-        DataValue dataValue = dataValueService.getDataValue( sourceA, dataElementA, periodA, categoryOptionCombo );
+        DataValue dataValue = dataValueService.getDataValue( dataElementA, periodA, sourceA, categoryOptionCombo );
         
         assertNotNull( dataValue );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueServiceTest.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueServiceTest.java	2013-12-19 18:12:57 +0000
@@ -132,9 +132,7 @@
         organisationUnitService.addOrganisationUnit( sourceC );
         organisationUnitService.addOrganisationUnit( sourceD );
 
-        optionCombo = new DataElementCategoryOptionCombo();
-        
-        categoryService.addDataElementCategoryOptionCombo( optionCombo );
+        optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
     }
 
     // -------------------------------------------------------------------------
@@ -145,13 +143,13 @@
     public void testAddDataValue()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceA, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceA, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueService.addDataValue( dataValueA );
@@ -169,21 +167,21 @@
             // Expected
         }
 
-        dataValueA = dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo );
+        dataValueA = dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo );
         assertNotNull( dataValueA );
         assertEquals( sourceA.getId(), dataValueA.getSource().getId() );
         assertEquals( dataElementA, dataValueA.getDataElement() );
         assertEquals( periodA, dataValueA.getPeriod() );
         assertEquals( "1", dataValueA.getValue() );
 
-        dataValueB = dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo );
+        dataValueB = dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo );
         assertNotNull( dataValueB );
         assertEquals( sourceA.getId(), dataValueB.getSource().getId() );
         assertEquals( dataElementB, dataValueB.getDataElement() );
         assertEquals( periodA, dataValueB.getPeriod() );
         assertEquals( "2", dataValueB.getValue() );
 
-        dataValueC = dataValueService.getDataValue( sourceA, dataElementC, periodC, optionCombo );
+        dataValueC = dataValueService.getDataValue( dataElementC, periodC, sourceA, optionCombo );
         assertNotNull( dataValueC );
         assertEquals( sourceA.getId(), dataValueC.getSource().getId() );
         assertEquals( dataElementC, dataValueC.getDataElement() );
@@ -195,25 +193,25 @@
     public void testUpdataDataValue()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceB, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceB, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
 
         dataValueService.addDataValue( dataValueA );
         dataValueService.addDataValue( dataValueB );
 
-        assertNotNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceB, dataElementB, periodA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementB, periodA, sourceB, optionCombo ) );
 
         dataValueA.setValue( "5" );
         dataValueService.updateDataValue( dataValueA );
 
-        dataValueA = dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo );
+        dataValueA = dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo );
         assertNotNull( dataValueA );
         assertEquals( "5", dataValueA.getValue() );
 
-        dataValueB = dataValueService.getDataValue( sourceB, dataElementB, periodA, optionCombo );
+        dataValueB = dataValueService.getDataValue( dataElementB, periodA, sourceB, optionCombo );
         assertNotNull( dataValueB );
         assertEquals( "2", dataValueB.getValue() );
     }
@@ -222,13 +220,13 @@
     public void testDeleteAndGetDataValue()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueService.addDataValue( dataValueA );
@@ -236,47 +234,47 @@
         dataValueService.addDataValue( dataValueC );
         dataValueService.addDataValue( dataValueD );
 
-        assertNotNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValue( dataValueA );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValue( dataValueB );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValue( dataValueC );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValue( dataValueD );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
     }
 
     @Test
     public void testDeleteDataValuesBySource()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueService.addDataValue( dataValueA );
@@ -284,47 +282,47 @@
         dataValueService.addDataValue( dataValueC );
         dataValueService.addDataValue( dataValueD );
 
-        assertNotNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValuesBySource( sourceA );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValuesBySource( sourceB );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValuesBySource( sourceC );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValuesBySource( sourceD );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
     }
 
     @Test
     public void testDeleteDataValuesByDataElement()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueService.addDataValue( dataValueA );
@@ -332,34 +330,34 @@
         dataValueService.addDataValue( dataValueC );
         dataValueService.addDataValue( dataValueD );
 
-        assertNotNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValuesByDataElement( dataElementA );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValuesByDataElement( dataElementB );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValuesByDataElement( dataElementC );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
 
         dataValueService.deleteDataValuesByDataElement( dataElementD );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNull( dataValueService.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) );
+        assertNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) );
     }
 
     // -------------------------------------------------------------------------
@@ -370,13 +368,13 @@
     public void testGetAllDataValues()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
     
         dataValueService.addDataValue( dataValueA );
@@ -393,13 +391,13 @@
     public void testGetDataValuesSourcePeriod()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueService.addDataValue( dataValueA );
@@ -424,13 +422,13 @@
     public void testGetDataValuesSourceDataElement()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueService.addDataValue( dataValueA );
@@ -455,13 +453,13 @@
     public void testGetDataValuesSourcesDataElement()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementA, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementA, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueService.addDataValue( dataValueA );
@@ -490,13 +488,13 @@
     public void testGetDataValuesSourcePeriodDataElements()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementA, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementA, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueService.addDataValue( dataValueA );
@@ -525,13 +523,13 @@
     public void testGetDataValuesDataElementPeriodsSources()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceB, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceB, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementA, periodB, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementA, periodB, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementA, periodA, sourceC, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementA, periodA, sourceC, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementB, periodB, sourceD, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementB, periodB, sourceD, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
         
         dataValueService.addDataValue( dataValueA );
@@ -558,13 +556,13 @@
     public void testGetDataValuesOptionComboDataElementPeriodsSources()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceB, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceB, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementA, periodB, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementA, periodB, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementA, periodA, sourceC, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementA, periodA, sourceC, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementB, periodB, sourceD, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementB, periodB, sourceD, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
         
         dataValueService.addDataValue( dataValueA );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueStoreTest.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueStoreTest.java	2013-12-19 18:12:57 +0000
@@ -141,9 +141,7 @@
         organisationUnitService.addOrganisationUnit( sourceC );
         organisationUnitService.addOrganisationUnit( sourceD );        
 
-        optionCombo = new DataElementCategoryOptionCombo();
-
-        categoryService.addDataElementCategoryOptionCombo( optionCombo );
+        optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
     }
     
     // -------------------------------------------------------------------------
@@ -154,13 +152,13 @@
     public void testAddDataValue()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceA, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceA, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueStore.addDataValue( dataValueA );
@@ -177,21 +175,21 @@
             // Expected
         }
 
-        dataValueA = dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo );
+        dataValueA = dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         assertNotNull( dataValueA );
         assertEquals( sourceA.getId(), dataValueA.getSource().getId() );
         assertEquals( dataElementA, dataValueA.getDataElement() );
         assertEquals( periodA, dataValueA.getPeriod() );
         assertEquals( "1", dataValueA.getValue() );
 
-        dataValueB = dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo );
+        dataValueB = dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         assertNotNull( dataValueB );
         assertEquals( sourceA.getId(), dataValueB.getSource().getId() );
         assertEquals( dataElementB, dataValueB.getDataElement() );
         assertEquals( periodA, dataValueB.getPeriod() );
         assertEquals( "2", dataValueB.getValue() );
 
-        dataValueC = dataValueStore.getDataValue( sourceA, dataElementC, periodC, optionCombo );
+        dataValueC = dataValueStore.getDataValue( dataElementC, periodC, sourceA, optionCombo, optionCombo );
         assertNotNull( dataValueC );
         assertEquals( sourceA.getId(), dataValueC.getSource().getId() );
         assertEquals( dataElementC, dataValueC.getDataElement() );
@@ -203,25 +201,25 @@
     public void testUpdataDataValue()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceB, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceB, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
 
         dataValueStore.addDataValue( dataValueA );
         dataValueStore.addDataValue( dataValueB );
 
-        assertNotNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceB, dataElementB, periodA, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementB, periodA, sourceB, optionCombo, optionCombo ) );
 
         dataValueA.setValue( "5" );
         dataValueStore.updateDataValue( dataValueA );
 
-        dataValueA = dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo );
+        dataValueA = dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         assertNotNull( dataValueA );
         assertEquals( "5", dataValueA.getValue() );
 
-        dataValueB = dataValueStore.getDataValue( sourceB, dataElementB, periodA, optionCombo );
+        dataValueB = dataValueStore.getDataValue( dataElementB, periodA, sourceB, optionCombo, optionCombo );
         assertNotNull( dataValueB );
         assertEquals( "2", dataValueB.getValue() );
     }
@@ -230,13 +228,13 @@
     public void testDeleteAndGetDataValue()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueStore.addDataValue( dataValueA );
@@ -244,47 +242,47 @@
         dataValueStore.addDataValue( dataValueC );
         dataValueStore.addDataValue( dataValueD );
 
-        assertNotNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValue( dataValueA );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValue( dataValueB );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValue( dataValueC );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValue( dataValueD );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
     }
 
     @Test
     public void testDeleteDataValuesBySource()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueStore.addDataValue( dataValueA );
@@ -292,47 +290,47 @@
         dataValueStore.addDataValue( dataValueC );
         dataValueStore.addDataValue( dataValueD );
 
-        assertNotNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValuesBySource( sourceA );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValuesBySource( sourceB );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValuesBySource( sourceC );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValuesBySource( sourceD );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
     }
 
     @Test
     public void testDeleteDataValuesByDataElement()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueStore.addDataValue( dataValueA );
@@ -340,34 +338,34 @@
         dataValueStore.addDataValue( dataValueC );
         dataValueStore.addDataValue( dataValueD );
 
-        assertNotNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValuesByDataElement( dataElementA );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValuesByDataElement( dataElementB );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValuesByDataElement( dataElementC );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNotNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNotNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
 
         dataValueStore.deleteDataValuesByDataElement( dataElementD );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementA, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceA, dataElementB, periodA, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceD, dataElementC, periodC, optionCombo ) );
-        assertNull( dataValueStore.getDataValue( sourceB, dataElementD, periodC, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ) );
+        assertNull( dataValueStore.getDataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ) );
     }
 
     // -------------------------------------------------------------------------
@@ -378,13 +376,13 @@
     public void testGetAllDataValues()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
     
         dataValueStore.addDataValue( dataValueA );
@@ -401,13 +399,13 @@
     public void testGetDataValuesSourcePeriod()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueStore.addDataValue( dataValueA );
@@ -432,13 +430,13 @@
     public void testGetDataValuesSourceDataElement()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueStore.addDataValue( dataValueA );
@@ -463,13 +461,13 @@
     public void testGetDataValuesSourcesDataElement()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementA, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementA, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueStore.addDataValue( dataValueA );
@@ -498,13 +496,13 @@
     public void testGetDataValuesSourcePeriodDataElements()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementA, periodC, sourceB, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementA, periodC, sourceB, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
 
         dataValueStore.addDataValue( dataValueA );
@@ -533,13 +531,13 @@
     public void testGetDataValuesDataElementPeriodsSources()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceB, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceB, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementA, periodB, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementA, periodB, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementA, periodA, sourceC, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementA, periodA, sourceC, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementB, periodB, sourceD, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementB, periodB, sourceD, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
         
         dataValueStore.addDataValue( dataValueA );
@@ -566,13 +564,13 @@
     public void testGetDataValuesOptionComboDataElementPeriodsSources()
         throws Exception
     {
-        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceB, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, periodA, sourceB, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementA, periodB, sourceA, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementA, periodB, sourceA, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementA, periodA, sourceC, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementA, periodA, sourceC, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementB, periodB, sourceD, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementB, periodB, sourceD, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
         
         dataValueStore.addDataValue( dataValueA );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.java	2013-09-30 11:54:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.java	2013-12-19 18:12:57 +0000
@@ -198,8 +198,8 @@
         dataElements.add( dataElementD );
         dataElements.add( dataElementE );
 
-        dataValueService.addDataValue( createDataValue( dataElementA, period, source, "10", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, period, source, "5", categoryOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, period, source, "10", categoryOptionCombo, categoryOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, period, source, "5", categoryOptionCombo, categoryOptionCombo ) );
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodServiceTest.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodServiceTest.java	2013-12-19 18:12:57 +0000
@@ -500,23 +500,23 @@
         OrganisationUnit sourceB = createOrganisationUnit( 'B' );
         OrganisationUnit sourceC = createOrganisationUnit( 'C' );
         
-        DataValue dataValueA = new DataValue( dataElementA, jan, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, jan, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementA, feb, sourceB, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementA, feb, sourceB, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementA, apr, sourceB, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementA, apr, sourceB, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementA, qu1, sourceA, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementA, qu1, sourceA, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
-        DataValue dataValueE = new DataValue( dataElementB, w01, sourceA, optionCombo );
+        DataValue dataValueE = new DataValue( dataElementB, w01, sourceA, optionCombo, optionCombo );
         dataValueE.setValue( "5" );
-        DataValue dataValueF = new DataValue( dataElementB, w02, sourceB, optionCombo );
+        DataValue dataValueF = new DataValue( dataElementB, w02, sourceB, optionCombo, optionCombo );
         dataValueF.setValue( "6" );
-        DataValue dataValueG = new DataValue( dataElementB, w03, sourceA, optionCombo );
+        DataValue dataValueG = new DataValue( dataElementB, w03, sourceA, optionCombo, optionCombo );
         dataValueG.setValue( "7" );
-        DataValue dataValueH = new DataValue( dataElementB, w04, sourceB, optionCombo );
+        DataValue dataValueH = new DataValue( dataElementB, w04, sourceB, optionCombo, optionCombo );
         dataValueH.setValue( "8" );
-        DataValue dataValueI = new DataValue( dataElementB, w05, sourceA, optionCombo );
+        DataValue dataValueI = new DataValue( dataElementB, w05, sourceA, optionCombo, optionCombo );
         dataValueI.setValue( "9" );
         
         dataElementService.addDataElement( dataElementA );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.java	2013-12-19 18:12:57 +0000
@@ -552,23 +552,23 @@
         OrganisationUnit sourceB = createOrganisationUnit( 'B' );
         OrganisationUnit sourceC = createOrganisationUnit( 'C' );
         
-        DataValue dataValueA = new DataValue( dataElementA, jan, sourceA, optionCombo );
+        DataValue dataValueA = new DataValue( dataElementA, jan, sourceA, optionCombo, optionCombo );
         dataValueA.setValue( "1" );
-        DataValue dataValueB = new DataValue( dataElementA, feb, sourceB, optionCombo );
+        DataValue dataValueB = new DataValue( dataElementA, feb, sourceB, optionCombo, optionCombo );
         dataValueB.setValue( "2" );
-        DataValue dataValueC = new DataValue( dataElementA, apr, sourceB, optionCombo );
+        DataValue dataValueC = new DataValue( dataElementA, apr, sourceB, optionCombo, optionCombo );
         dataValueC.setValue( "3" );
-        DataValue dataValueD = new DataValue( dataElementA, qu1, sourceA, optionCombo );
+        DataValue dataValueD = new DataValue( dataElementA, qu1, sourceA, optionCombo, optionCombo );
         dataValueD.setValue( "4" );
-        DataValue dataValueE = new DataValue( dataElementB, w01, sourceA, optionCombo );
+        DataValue dataValueE = new DataValue( dataElementB, w01, sourceA, optionCombo, optionCombo );
         dataValueE.setValue( "5" );
-        DataValue dataValueF = new DataValue( dataElementB, w02, sourceB, optionCombo );
+        DataValue dataValueF = new DataValue( dataElementB, w02, sourceB, optionCombo, optionCombo );
         dataValueF.setValue( "6" );
-        DataValue dataValueG = new DataValue( dataElementB, w03, sourceA, optionCombo );
+        DataValue dataValueG = new DataValue( dataElementB, w03, sourceA, optionCombo, optionCombo );
         dataValueG.setValue( "7" );
-        DataValue dataValueH = new DataValue( dataElementB, w04, sourceB, optionCombo );
+        DataValue dataValueH = new DataValue( dataElementB, w04, sourceB, optionCombo, optionCombo );
         dataValueH.setValue( "8" );
-        DataValue dataValueI = new DataValue( dataElementB, w05, sourceA, optionCombo );
+        DataValue dataValueI = new DataValue( dataElementB, w05, sourceA, optionCombo, optionCombo );
         dataValueI.setValue( "9" );
         
         dataElementService.addDataElement( dataElementA );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaServiceTest.java	2013-12-16 04:27:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaServiceTest.java	2013-12-19 18:12:57 +0000
@@ -36,7 +36,6 @@
 import java.util.Collection;
 
 import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.patient.Patient;
 import org.junit.Test;
 
 /**

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java	2013-11-10 10:00:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java	2013-12-19 18:12:57 +0000
@@ -48,7 +48,6 @@
 
 import org.hisp.dhis.DhisTest;
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
@@ -96,9 +95,7 @@
 
     private Set<DataElementCategoryOptionCombo> optionCombos;
 
-    private DataElementCategoryCombo categoryCombo;
-
-    private DataElementCategoryOptionCombo categoryOptionCombo;
+    private DataElementCategoryOptionCombo optionCombo;
 
     private Expression expressionA;
 
@@ -260,15 +257,12 @@
         dataElementsD.add( dataElementB );
         dataElementsD.add( dataElementE );
 
-        categoryCombo = categoryService
-            .getDataElementCategoryComboByName( DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME );
-
-        categoryOptionCombo = categoryCombo.getOptionCombos().iterator().next();
-
-        String suffix = SEPARATOR + categoryOptionCombo.getUid();
+        optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+
+        String suffix = SEPARATOR + optionCombo.getUid();
 
         optionCombos = new HashSet<DataElementCategoryOptionCombo>();
-        optionCombos.add( categoryOptionCombo );
+        optionCombos.add( optionCombo );
 
         expressionA = new Expression( "#{" + dataElementA.getUid() + suffix + "} + #{" + dataElementB.getUid() + suffix + "}",
             "descriptionA", dataElementsA, optionCombos );
@@ -456,25 +450,25 @@
     @Test
     public void testValidateDateDateSources()
     {
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "1", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "2", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceA, "3", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceA, "4", categoryOptionCombo ) );
-
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, sourceA, "1", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "2", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementC, periodB, sourceA, "3", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementD, periodB, sourceA, "4", categoryOptionCombo ) );
-
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceB, "1", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceB, "2", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceB, "3", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceB, "4", categoryOptionCombo ) );
-
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, sourceB, "1", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceB, "2", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementC, periodB, sourceB, "3", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementD, periodB, sourceB, "4", categoryOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "1", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "2", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceA, "3", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceA, "4", optionCombo, optionCombo ) );
+
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, sourceA, "1", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "2", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementC, periodB, sourceA, "3", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementD, periodB, sourceA, "4", optionCombo, optionCombo ) );
+
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceB, "1", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceB, "2", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceB, "3", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceB, "4", optionCombo, optionCombo ) );
+
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, sourceB, "1", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceB, "2", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementC, periodB, sourceB, "3", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementD, periodB, sourceB, "4", optionCombo, optionCombo ) );
 
         validationRuleService.saveValidationRule( validationRuleA ); // Invalid
         validationRuleService.saveValidationRule( validationRuleB ); // Invalid
@@ -512,25 +506,25 @@
     @Test
     public void testValidateDateDateSourcesGroup()
     {
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "1", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "2", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceA, "3", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceA, "4", categoryOptionCombo ) );
-
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, sourceA, "1", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "2", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementC, periodB, sourceA, "3", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementD, periodB, sourceA, "4", categoryOptionCombo ) );
-
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceB, "1", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceB, "2", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceB, "3", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceB, "4", categoryOptionCombo ) );
-
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, sourceB, "1", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceB, "2", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementC, periodB, sourceB, "3", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementD, periodB, sourceB, "4", categoryOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "1", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "2", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceA, "3", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceA, "4", optionCombo, optionCombo ) );
+
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, sourceA, "1", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "2", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementC, periodB, sourceA, "3", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementD, periodB, sourceA, "4", optionCombo, optionCombo ) );
+
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceB, "1", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceB, "2", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceB, "3", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceB, "4", optionCombo, optionCombo ) );
+
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, sourceB, "1", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceB, "2", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementC, periodB, sourceB, "3", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementD, periodB, sourceB, "4", optionCombo, optionCombo ) );
 
         validationRuleService.saveValidationRule( validationRuleA ); // Invalid
         validationRuleService.saveValidationRule( validationRuleB ); // Invalid
@@ -565,15 +559,15 @@
     @Test
     public void testValidateDateDateSource()
     {
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "1", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "2", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceA, "3", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceA, "4", categoryOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "1", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "2", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceA, "3", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceA, "4", optionCombo, optionCombo ) );
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, sourceA, "1", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "2", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementC, periodB, sourceA, "3", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementD, periodB, sourceA, "4", categoryOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, sourceA, "1", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "2", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementC, periodB, sourceA, "3", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementD, periodB, sourceA, "4", optionCombo, optionCombo ) );
 
         validationRuleService.saveValidationRule( validationRuleA );
         validationRuleService.saveValidationRule( validationRuleB );
@@ -603,10 +597,10 @@
     @Test
     public void testValidateDataSetPeriodSource()
     {
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "1", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "2", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceA, "3", categoryOptionCombo ) );
-        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceA, "4", categoryOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "1", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "2", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementC, periodA, sourceA, "3", optionCombo, optionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementD, periodA, sourceA, "4", optionCombo, optionCombo ) );
 
         validationRuleService.saveValidationRule( validationRuleA );
         validationRuleService.saveValidationRule( validationRuleB );
@@ -637,23 +631,23 @@
     	// System.out.println("\ntestValidateMonitoring1Sequential");
     	// Note: for some monitoring tests, we enter more data than needed, to be sure the extra data *isn't* used.
     	
-    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", categoryOptionCombo ) ); // Mar 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", categoryOptionCombo ) ); // Apr 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", categoryOptionCombo ) ); // May 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", categoryOptionCombo ) ); // Jun 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", categoryOptionCombo ) ); // Jul 2000
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "30", categoryOptionCombo ) ); // Mar 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "35", categoryOptionCombo ) ); // Apr 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "40", categoryOptionCombo ) ); // May 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "45", categoryOptionCombo ) ); // Jun 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "50", categoryOptionCombo ) ); // Jul 2001
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", categoryOptionCombo ) ); // Mar 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", categoryOptionCombo ) ); // Apr 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", categoryOptionCombo ) ); // May 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", categoryOptionCombo ) ); // Jun 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", categoryOptionCombo ) ); // Jul 2002
+    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", optionCombo, optionCombo ) ); // Mar 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", optionCombo, optionCombo ) ); // Apr 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", optionCombo, optionCombo ) ); // May 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", optionCombo, optionCombo ) ); // Jun 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", optionCombo, optionCombo ) ); // Jul 2000
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "30", optionCombo, optionCombo ) ); // Mar 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "35", optionCombo, optionCombo ) ); // Apr 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "40", optionCombo, optionCombo ) ); // May 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "45", optionCombo, optionCombo ) ); // Jun 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "50", optionCombo, optionCombo ) ); // Jul 2001
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", optionCombo, optionCombo ) ); // Mar 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", optionCombo, optionCombo ) ); // Apr 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", optionCombo, optionCombo ) ); // May 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", optionCombo, optionCombo ) ); // Jun 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", optionCombo, optionCombo ) ); // Jul 2002
     	
         validationRuleService.saveValidationRule( monitoringRuleE );
         
@@ -681,23 +675,23 @@
     {
     	// System.out.println("\ntestValidateMonitoring1Annual");
 
-    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", categoryOptionCombo ) ); // Mar 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", categoryOptionCombo ) ); // Apr 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", categoryOptionCombo ) ); // May 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", categoryOptionCombo ) ); // Jun 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", categoryOptionCombo ) ); // Jul 2000
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", categoryOptionCombo ) ); // Mar 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", categoryOptionCombo ) ); // Apr 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", categoryOptionCombo ) ); // May 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", categoryOptionCombo ) ); // Jun 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", categoryOptionCombo ) ); // Jul 2001
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", categoryOptionCombo ) ); // Mar 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", categoryOptionCombo ) ); // Apr 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", categoryOptionCombo ) ); // May 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", categoryOptionCombo ) ); // Jun 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", categoryOptionCombo ) ); // Jul 2002
+    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", optionCombo, optionCombo ) ); // Mar 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", optionCombo, optionCombo ) ); // Apr 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", optionCombo, optionCombo ) ); // May 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", optionCombo, optionCombo ) ); // Jun 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", optionCombo, optionCombo ) ); // Jul 2000
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", optionCombo, optionCombo ) ); // Mar 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", optionCombo, optionCombo ) ); // Apr 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", optionCombo, optionCombo ) ); // May 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", optionCombo, optionCombo ) ); // Jun 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", optionCombo, optionCombo ) ); // Jul 2001
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", optionCombo, optionCombo ) ); // Mar 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", optionCombo, optionCombo ) ); // Apr 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", optionCombo, optionCombo ) ); // May 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", optionCombo, optionCombo ) ); // Jun 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", optionCombo, optionCombo ) ); // Jul 2002
     	
         validationRuleService.saveValidationRule( monitoringRuleF );
         
@@ -725,23 +719,23 @@
     {
     	// System.out.println("\ntestValidateMonitoring1Sequential2Annual");
 
-    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", categoryOptionCombo ) ); // Mar 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", categoryOptionCombo ) ); // Apr 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", categoryOptionCombo ) ); // May 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", categoryOptionCombo ) ); // Jun 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", categoryOptionCombo ) ); // Jul 2000
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", categoryOptionCombo ) ); // Mar 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", categoryOptionCombo ) ); // Apr 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", categoryOptionCombo ) ); // May 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", categoryOptionCombo ) ); // Jun 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", categoryOptionCombo ) ); // Jul 2001
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", categoryOptionCombo ) ); // Mar 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", categoryOptionCombo ) ); // Apr 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", categoryOptionCombo ) ); // May 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", categoryOptionCombo ) ); // Jun 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", categoryOptionCombo ) ); // Jul 2002
+    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", optionCombo, optionCombo ) ); // Mar 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", optionCombo, optionCombo ) ); // Apr 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", optionCombo, optionCombo ) ); // May 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", optionCombo, optionCombo ) ); // Jun 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", optionCombo, optionCombo ) ); // Jul 2000
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", optionCombo, optionCombo ) ); // Mar 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", optionCombo, optionCombo ) ); // Apr 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", optionCombo, optionCombo ) ); // May 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", optionCombo, optionCombo ) ); // Jun 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", optionCombo, optionCombo ) ); // Jul 2001
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", optionCombo, optionCombo ) ); // Mar 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", optionCombo, optionCombo ) ); // Apr 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", optionCombo, optionCombo ) ); // May 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", optionCombo, optionCombo ) ); // Jun 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", optionCombo, optionCombo ) ); // Jul 2002
     	
         validationRuleService.saveValidationRule( monitoringRuleG ); // 1 sequential and 2 annual periods
         
@@ -771,23 +765,23 @@
     {
     	// System.out.println("\ntestValidateMonitoring2Sequential2Annual");
 
-    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", categoryOptionCombo ) ); // Mar 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", categoryOptionCombo ) ); // Apr 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", categoryOptionCombo ) ); // May 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", categoryOptionCombo ) ); // Jun 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", categoryOptionCombo ) ); // Jul 2000
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", categoryOptionCombo ) ); // Mar 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", categoryOptionCombo ) ); // Apr 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", categoryOptionCombo ) ); // May 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", categoryOptionCombo ) ); // Jun 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", categoryOptionCombo ) ); // Jul 2001
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", categoryOptionCombo ) ); // Mar 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", categoryOptionCombo ) ); // Apr 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", categoryOptionCombo ) ); // May 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", categoryOptionCombo ) ); // Jun 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", categoryOptionCombo ) ); // Jul 2002
+    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", optionCombo, optionCombo ) ); // Mar 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", optionCombo, optionCombo ) ); // Apr 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", optionCombo, optionCombo ) ); // May 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", optionCombo, optionCombo ) ); // Jun 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", optionCombo, optionCombo ) ); // Jul 2000
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", optionCombo, optionCombo ) ); // Mar 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", optionCombo, optionCombo ) ); // Apr 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", optionCombo, optionCombo ) ); // May 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", optionCombo, optionCombo ) ); // Jun 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", optionCombo, optionCombo ) ); // Jul 2001
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", optionCombo, optionCombo ) ); // Mar 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", optionCombo, optionCombo ) ); // Apr 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", optionCombo, optionCombo ) ); // May 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", optionCombo, optionCombo ) ); // Jun 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", optionCombo, optionCombo ) ); // Jul 2002
     	
         validationRuleService.saveValidationRule( monitoringRuleH ); // 2 sequential and 2 annual periods
         
@@ -817,23 +811,23 @@
     {
     	// System.out.println("\ntestValidateMonitoring2HighOutliers");
 
-    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", categoryOptionCombo ) ); // Mar 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", categoryOptionCombo ) ); // Apr 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", categoryOptionCombo ) ); // May 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", categoryOptionCombo ) ); // Jun 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", categoryOptionCombo ) ); // Jul 2000
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", categoryOptionCombo ) ); // Mar 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", categoryOptionCombo ) ); // Apr 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", categoryOptionCombo ) ); // May 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", categoryOptionCombo ) ); // Jun 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", categoryOptionCombo ) ); // Jul 2001
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", categoryOptionCombo ) ); // Mar 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", categoryOptionCombo ) ); // Apr 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", categoryOptionCombo ) ); // May 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", categoryOptionCombo ) ); // Jun 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", categoryOptionCombo ) ); // Jul 2002
+    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", optionCombo, optionCombo ) ); // Mar 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", optionCombo, optionCombo ) ); // Apr 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", optionCombo, optionCombo ) ); // May 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", optionCombo, optionCombo ) ); // Jun 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", optionCombo, optionCombo ) ); // Jul 2000
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", optionCombo, optionCombo ) ); // Mar 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", optionCombo, optionCombo ) ); // Apr 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", optionCombo, optionCombo ) ); // May 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", optionCombo, optionCombo ) ); // Jun 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", optionCombo, optionCombo ) ); // Jul 2001
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", optionCombo, optionCombo ) ); // Mar 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", optionCombo, optionCombo ) ); // Apr 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", optionCombo, optionCombo ) ); // May 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", optionCombo, optionCombo ) ); // Jun 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", optionCombo, optionCombo ) ); // Jul 2002
     	
         validationRuleService.saveValidationRule( monitoringRuleI ); // discard 2 highest outliers
         
@@ -863,23 +857,23 @@
     {
     	// System.out.println("\ntestValidateMonitoring2LowOutliers");
 
-    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", categoryOptionCombo ) ); // Mar 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", categoryOptionCombo ) ); // Apr 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", categoryOptionCombo ) ); // May 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", categoryOptionCombo ) ); // Jun 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", categoryOptionCombo ) ); // Jul 2000
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", categoryOptionCombo ) ); // Mar 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", categoryOptionCombo ) ); // Apr 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", categoryOptionCombo ) ); // May 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", categoryOptionCombo ) ); // Jun 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", categoryOptionCombo ) ); // Jul 2001
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", categoryOptionCombo ) ); // Mar 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", categoryOptionCombo ) ); // Apr 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", categoryOptionCombo ) ); // May 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", categoryOptionCombo ) ); // Jun 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", categoryOptionCombo ) ); // Jul 2002
+    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", optionCombo, optionCombo ) ); // Mar 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", optionCombo, optionCombo ) ); // Apr 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", optionCombo, optionCombo ) ); // May 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", optionCombo, optionCombo ) ); // Jun 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", optionCombo, optionCombo ) ); // Jul 2000
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", optionCombo, optionCombo ) ); // Mar 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", optionCombo, optionCombo ) ); // Apr 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", optionCombo, optionCombo ) ); // May 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", optionCombo, optionCombo ) ); // Jun 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", optionCombo, optionCombo ) ); // Jul 2001
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", optionCombo, optionCombo ) ); // Mar 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", optionCombo, optionCombo ) ); // Apr 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", optionCombo, optionCombo ) ); // May 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", optionCombo, optionCombo ) ); // Jun 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", optionCombo, optionCombo ) ); // Jul 2002
     	
         validationRuleService.saveValidationRule( monitoringRuleJ ); // 2 sequential and 2 annual periods
         
@@ -909,23 +903,23 @@
     {
     	// System.out.println("\ntestValidateMonitoring2High2LowOutliers");
 
-    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", categoryOptionCombo ) ); // Mar 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", categoryOptionCombo ) ); // Apr 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", categoryOptionCombo ) ); // May 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", categoryOptionCombo ) ); // Jun 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", categoryOptionCombo ) ); // Jul 2000
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", categoryOptionCombo ) ); // Mar 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", categoryOptionCombo ) ); // Apr 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", categoryOptionCombo ) ); // May 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", categoryOptionCombo ) ); // Jun 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", categoryOptionCombo ) ); // Jul 2001
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", categoryOptionCombo ) ); // Mar 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", categoryOptionCombo ) ); // Apr 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", categoryOptionCombo ) ); // May 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", categoryOptionCombo ) ); // Jun 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", categoryOptionCombo ) ); // Jul 2002
+    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "11", optionCombo, optionCombo ) ); // Mar 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceA, "12", optionCombo, optionCombo ) ); // Apr 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceA, "13", optionCombo, optionCombo ) ); // May 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceA, "14", optionCombo, optionCombo ) ); // Jun 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceA, "15", optionCombo, optionCombo ) ); // Jul 2000
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceA, "50", optionCombo, optionCombo ) ); // Mar 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceA, "150", optionCombo, optionCombo ) ); // Apr 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceA, "200", optionCombo, optionCombo ) ); // May 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceA, "600", optionCombo, optionCombo ) ); // Jun 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceA, "400", optionCombo, optionCombo ) ); // Jul 2001
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceA, "100", optionCombo, optionCombo ) ); // Mar 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceA, "200", optionCombo, optionCombo ) ); // Apr 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceA, "400", optionCombo, optionCombo ) ); // May 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceA, "700", optionCombo, optionCombo ) ); // Jun 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceA, "800", optionCombo, optionCombo ) ); // Jul 2002
     	
         validationRuleService.saveValidationRule( monitoringRuleK ); // discard 2 highest outliers
         
@@ -955,30 +949,30 @@
     {
     	// System.out.println("\ntestValidateMonitoringWithBaseline");
 
-    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceB, "11", categoryOptionCombo ) ); // Mar 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceB, "12", categoryOptionCombo ) ); // Apr 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceB, "13", categoryOptionCombo ) ); // May 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceB, "14", categoryOptionCombo ) ); // Jun 2000
-        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceB, "15", categoryOptionCombo ) ); // Jul 2000
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceB, "50", categoryOptionCombo ) ); // Mar 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceB, "150", categoryOptionCombo ) ); // Apr 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceB, "200", categoryOptionCombo ) ); // May 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceB, "600", categoryOptionCombo ) ); // Jun 2001
-        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceB, "400", categoryOptionCombo ) ); // Jul 2001
-
-        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceB, "100", categoryOptionCombo ) ); // Mar 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceB, "200", categoryOptionCombo ) ); // Apr 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceB, "400", categoryOptionCombo ) ); // May 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceB, "700", categoryOptionCombo ) ); // Jun 2002
-        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceB, "800", categoryOptionCombo ) ); // Jul 2002
+    	dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceB, "11", optionCombo, optionCombo ) ); // Mar 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodB, sourceB, "12", optionCombo, optionCombo ) ); // Apr 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodC, sourceB, "13", optionCombo, optionCombo ) ); // May 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodD, sourceB, "14", optionCombo, optionCombo ) ); // Jun 2000
+        dataValueService.addDataValue( createDataValue( dataElementB, periodE, sourceB, "15", optionCombo, optionCombo ) ); // Jul 2000
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodF, sourceB, "50", optionCombo, optionCombo ) ); // Mar 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodG, sourceB, "150", optionCombo, optionCombo ) ); // Apr 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodH, sourceB, "200", optionCombo, optionCombo ) ); // May 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodI, sourceB, "600", optionCombo, optionCombo ) ); // Jun 2001
+        dataValueService.addDataValue( createDataValue( dataElementB, periodJ, sourceB, "400", optionCombo, optionCombo ) ); // Jul 2001
+
+        dataValueService.addDataValue( createDataValue( dataElementB, periodK, sourceB, "100", optionCombo, optionCombo ) ); // Mar 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodL, sourceB, "200", optionCombo, optionCombo ) ); // Apr 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodM, sourceB, "400", optionCombo, optionCombo ) ); // May 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodN, sourceB, "700", optionCombo, optionCombo ) ); // Jun 2002
+        dataValueService.addDataValue( createDataValue( dataElementB, periodO, sourceB, "800", optionCombo, optionCombo ) ); // Jul 2002
         
         // This weekly baseline data should be ignored because the period length is less than monthly:
-        dataValueService.addDataValue( createDataValue( dataElementE, periodW, sourceB, "1000", categoryOptionCombo ) ); // Week: 1-7 Apr 2002
+        dataValueService.addDataValue( createDataValue( dataElementE, periodW, sourceB, "1000", optionCombo, optionCombo ) ); // Week: 1-7 Apr 2002
 
-        dataValueService.addDataValue( createDataValue( dataElementE, periodX, sourceB, "40", categoryOptionCombo ) ); // Year: 2000
-        dataValueService.addDataValue( createDataValue( dataElementE, periodY, sourceB, "50", categoryOptionCombo ) ); // Year: 2001
-        dataValueService.addDataValue( createDataValue( dataElementE, periodZ, sourceB, "10", categoryOptionCombo ) ); // Year: 2002
+        dataValueService.addDataValue( createDataValue( dataElementE, periodX, sourceB, "40", optionCombo, optionCombo ) ); // Year: 2000
+        dataValueService.addDataValue( createDataValue( dataElementE, periodY, sourceB, "50", optionCombo, optionCombo ) ); // Year: 2001
+        dataValueService.addDataValue( createDataValue( dataElementE, periodZ, sourceB, "10", optionCombo, optionCombo ) ); // Year: 2002
         
         validationRuleService.saveValidationRule( monitoringRuleL );
         

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/DataMartServiceMultiDimensionTest.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/DataMartServiceMultiDimensionTest.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/DataMartServiceMultiDimensionTest.java	2013-12-19 18:12:57 +0000
@@ -82,6 +82,7 @@
     
     private DataElementCategoryCombo categoryComboA;
     
+    private DataElementCategoryOptionCombo defaultOptionCombo;
     private DataElementCategoryOptionCombo categoryOptionComboA;
     private DataElementCategoryOptionCombo categoryOptionComboB;  
     
@@ -162,7 +163,7 @@
 
         Iterator<DataElementCategoryOptionCombo> categoryOptionCombos = categoryService.getAllDataElementCategoryOptionCombos().iterator();
         
-        categoryOptionCombos.next(); // Omit default
+        defaultOptionCombo = categoryOptionCombos.next();
         categoryOptionComboA = categoryOptionCombos.next();
         categoryOptionComboB = categoryOptionCombos.next();     
         
@@ -245,19 +246,19 @@
         // Setup DataValues
         // ---------------------------------------------------------------------
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, "40", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, "20", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "90", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "10", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "25", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "20", categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, "40", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, "20", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "90", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "10", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "25", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "20", categoryOptionComboB, defaultOptionCombo ) );
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, "40", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, "80", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "70", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "30", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "65", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "40", categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, "40", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, "80", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "70", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "30", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "65", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "40", categoryOptionComboB, defaultOptionCombo ) );
         
         // ---------------------------------------------------------------------
         // Test
@@ -299,19 +300,19 @@
         // Setup DataValues
         // ---------------------------------------------------------------------
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, "40", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, "20", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "90", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "10", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "25", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "20", categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, "40", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, "20", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "90", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "10", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "25", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "20", categoryOptionComboB, defaultOptionCombo ) );
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, "40", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, "80", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "70", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "30", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "65", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "40", categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, "40", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, "80", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "70", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "30", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "65", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "40", categoryOptionComboB, defaultOptionCombo ) );
         
         // ---------------------------------------------------------------------
         // Test
@@ -353,19 +354,19 @@
         // Setup DataValues
         // ---------------------------------------------------------------------
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, T, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, F, categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, T, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, F, categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, F, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, T, categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, T, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, F, categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, T, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, F, categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, F, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, T, categoryOptionComboB, defaultOptionCombo ) );
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, T, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, T, categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, F, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, T, categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, F, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, F, categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, T, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, T, categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, F, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, T, categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, F, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, F, categoryOptionComboB, defaultOptionCombo ) );
         
         // ---------------------------------------------------------------------
         // Test
@@ -407,19 +408,19 @@
         // Setup DataValues
         // ---------------------------------------------------------------------
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, T, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, F, categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, T, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, F, categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, F, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, T, categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, T, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitA, F, categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, T, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, F, categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, F, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, T, categoryOptionComboB, defaultOptionCombo ) );
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, T, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, T, categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, F, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, T, categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, F, categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, F, categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, T, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitA, T, categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, F, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, T, categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, F, categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, F, categoryOptionComboB, defaultOptionCombo ) );
         
         // ---------------------------------------------------------------------
         // Test
@@ -461,15 +462,15 @@
         // Setup DataValues
         // ---------------------------------------------------------------------
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "9", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "3", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "1", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "5", categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "9", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "3", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "1", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "5", categoryOptionComboB, defaultOptionCombo ) );
         
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "3", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "2", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "7", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "9", categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "3", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "2", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "7", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "9", categoryOptionComboB, defaultOptionCombo ) );
         
         // ---------------------------------------------------------------------
         // Setup Indicators
@@ -521,15 +522,15 @@
         // Setup DataValues
         // ---------------------------------------------------------------------
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "9", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "3", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "1", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "5", categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "9", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "3", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "1", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "5", categoryOptionComboB, defaultOptionCombo ) );
         
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "3", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "2", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "7", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "9", categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "3", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "2", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "7", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "9", categoryOptionComboB, defaultOptionCombo ) );
         
         // ---------------------------------------------------------------------
         // Setup Indicators
@@ -600,15 +601,15 @@
         // Setup DataValues
         // ---------------------------------------------------------------------
 
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "9", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "3", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "1", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "5", categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "9", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitB, "3", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "1", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "5", categoryOptionComboB, defaultOptionCombo ) );
         
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "3", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "2", categoryOptionComboB ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "7", categoryOptionComboA ) );
-        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "9", categoryOptionComboB ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "3", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitB, "2", categoryOptionComboB, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "7", categoryOptionComboA, defaultOptionCombo ) );
+        dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "9", categoryOptionComboB, defaultOptionCombo ) );
         
         // ---------------------------------------------------------------------
         // Setup Indicators

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.java	2013-12-19 18:12:57 +0000
@@ -78,6 +78,8 @@
     private List<DataElementOperand> operands;
     private Collection<Integer> periodIds;
     private Collection<Integer> organisationUnitIds;
+    
+    private DataElementCategoryOptionCombo defaultOptionCombo;
 
     // -------------------------------------------------------------------------
     // Fixture
@@ -166,6 +168,8 @@
             organisationUnitIds.add( organisationUnitService.addOrganisationUnit( organisationUnit ) );
         }
         
+        defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+        
         operands = new ArrayList<DataElementOperand>( categoryService.getOperands( dataElements ) );
         
         for ( DataElement dataElement : dataElements )
@@ -176,7 +180,7 @@
                 {
                     for ( OrganisationUnit organisationUnit : organisationUnits )
                     {
-                        dataValueService.addDataValue( createDataValue( dataElement, period, organisationUnit, "10", categoryOptionCombo ) );
+                        dataValueService.addDataValue( createDataValue( dataElement, period, organisationUnit, "10", categoryOptionCombo, defaultOptionCombo ) );
                     }
                 }
             }

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2013-12-19 08:23:37 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2013-12-19 18:12:57 +0000
@@ -395,6 +395,7 @@
             internalValue.setPeriod( period );
             internalValue.setSource( orgUnit );
             internalValue.setCategoryOptionCombo( categoryOptionCombo );
+            internalValue.setAttributeOptionCombo( fallbackCategoryOptionCombo ); // TODO
             internalValue.setValue( dataValue.getValue() );
 
             if ( dataValue.getStoredBy() == null || dataValue.getStoredBy().trim().isEmpty() )

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java	2013-12-11 12:28:53 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java	2013-12-19 18:12:57 +0000
@@ -153,9 +153,9 @@
         
         assertNotNull( dataValues );
         assertEquals( 3, dataValues.size() );
-        assertTrue( dataValues.contains( new DataValue( deA, peA, ouA, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deB, peA, ouA, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deC, peA, ouA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deA, peA, ouA, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deB, peA, ouA, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deC, peA, ouA, optionComboA, optionComboA ) ) );
         
         CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dsA, peA, ouA );
         
@@ -204,18 +204,18 @@
 
         assertNotNull( dataValues );
         assertEquals( 12, dataValues.size() );
-        assertTrue( dataValues.contains( new DataValue( deA, peA, ouA, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deA, peA, ouB, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deA, peB, ouA, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deA, peB, ouB, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deB, peA, ouA, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deB, peA, ouB, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deB, peB, ouA, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deB, peB, ouB, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deC, peA, ouA, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deC, peA, ouB, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deC, peB, ouA, optionComboA ) ) );
-        assertTrue( dataValues.contains( new DataValue( deC, peB, ouB, optionComboA ) ) );        
+        assertTrue( dataValues.contains( new DataValue( deA, peA, ouA, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deA, peA, ouB, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deA, peB, ouA, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deA, peB, ouB, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deB, peA, ouA, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deB, peA, ouB, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deB, peB, ouA, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deB, peB, ouB, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deC, peA, ouA, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deC, peA, ouB, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deC, peB, ouA, optionComboA, optionComboA ) ) );
+        assertTrue( dataValues.contains( new DataValue( deC, peB, ouB, optionComboA, optionComboA ) ) );        
     }
     
     @Test

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataValueImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataValueImporter.java	2013-12-19 08:23:37 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataValueImporter.java	2013-12-19 18:12:57 +0000
@@ -93,8 +93,8 @@
             return null;
         }
         
-        return dataValueService.getDataValue( object.getDataElement().getId(), object.getCategoryOptionCombo().getId(), 
-            object.getPeriod().getId(), object.getSource().getId() );
+        return dataValueService.getDataValue( object.getDataElement().getId(), 
+            object.getPeriod().getId(), object.getSource().getId(), object.getCategoryOptionCombo().getId() );
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectService.java	2013-12-19 08:23:37 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectService.java	2013-12-19 18:12:57 +0000
@@ -613,8 +613,8 @@
         {
             DataValue dataValue = (DataValue) object;
 
-            dataValue = updateDataValue( dataValue, dataValueService.getDataValue( dataValue.getSource(), dataValue
-                .getDataElement(), dataValue.getPeriod(), dataValue.getCategoryOptionCombo() ) );
+            dataValue = updateDataValue( dataValue, dataValueService.getDataValue( dataValue.getDataElement(), 
+                dataValue.getPeriod(), dataValue.getSource(), dataValue.getCategoryOptionCombo() ) );
         }
 
         // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java	2013-12-19 09:06:41 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java	2013-12-19 18:12:57 +0000
@@ -411,15 +411,15 @@
     {
         String value = dv.getValue().trim();
 
-        DataElementCategoryOptionCombo cateOptCombo = categoryService.getDataElementCategoryOptionCombo( dv
+        DataElementCategoryOptionCombo catOptCombo = categoryService.getDataElementCategoryOptionCombo( dv
             .getCategoryOptComboID() );
 
-        org.hisp.dhis.datavalue.DataValue dataValue = dataValueService.getDataValue( unit, dataElement, period,
-            cateOptCombo );
+        org.hisp.dhis.datavalue.DataValue dataValue = dataValueService.getDataValue( dataElement, period,
+            unit, catOptCombo );
 
         if ( dataValue == null )
         {
-            dataValue = new org.hisp.dhis.datavalue.DataValue( dataElement, period, unit, cateOptCombo, value, "", new Date(), "" );
+            dataValue = new org.hisp.dhis.datavalue.DataValue( dataElement, period, unit, catOptCombo, catOptCombo, value, "", new Date(), "" );
             dataValueService.addDataValue( dataValue );
         }
         else

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2013-12-16 10:07:07 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2013-12-19 18:12:57 +0000
@@ -317,7 +317,7 @@
 
             period.setName( format.formatPeriod( period ) );
 
-            DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period,
+            DataValue dataValue = dataValueService.getDataValue( dataElement, period, organisationUnit,
                 categoryOptionCombo );
 
             double value = 0;

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java	2013-09-16 17:07:25 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java	2013-12-19 18:12:57 +0000
@@ -208,7 +208,7 @@
 
                     if ( selectedUnitOnly )
                     {
-                        DataValue dataValue = dataValueService.getDataValue( unit, dataElement, period, optionCombo );
+                        DataValue dataValue = dataValueService.getDataValue( dataElement, period, unit, optionCombo );
                         value = dataValue != null && dataValue.getValue() != null ? Double.parseDouble( dataValue
                             .getValue() ) : null;
                     }

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc-test/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandlerTest.java'
--- dhis-2/dhis-support/dhis-support-jdbc-test/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandlerTest.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc-test/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandlerTest.java	2013-12-19 18:12:57 +0000
@@ -121,10 +121,10 @@
         organisationUnitService.addOrganisationUnit( unitA );
         organisationUnitService.addOrganisationUnit( unitB );        
         
-        dataValueA = createDataValue( dataElementA, periodA, unitA, "10", categoryOptionComboA );
-        dataValueB = createDataValue( dataElementA, periodA, unitB, "10", categoryOptionComboA );
-        dataValueC = createDataValue( dataElementA, periodB, unitA, "10", categoryOptionComboA );
-        dataValueD = createDataValue( dataElementA, periodB, unitB, "10", categoryOptionComboA );     
+        dataValueA = createDataValue( dataElementA, periodA, unitA, "10", categoryOptionComboA, categoryOptionComboA );
+        dataValueB = createDataValue( dataElementA, periodA, unitB, "10", categoryOptionComboA, categoryOptionComboA );
+        dataValueC = createDataValue( dataElementA, periodB, unitA, "10", categoryOptionComboA, categoryOptionComboA );
+        dataValueD = createDataValue( dataElementA, periodB, unitB, "10", categoryOptionComboA, categoryOptionComboA );     
         
         batchHandler.init();
     }
@@ -174,10 +174,10 @@
         batchHandler.insertObject( dataValueC, false );
         batchHandler.insertObject( dataValueD, false );
         
-        assertNotNull( dataValueService.getDataValue( unitA, dataElementA, periodA, categoryOptionComboA ) );
-        assertNotNull( dataValueService.getDataValue( unitB, dataElementA, periodA, categoryOptionComboA ) );
-        assertNotNull( dataValueService.getDataValue( unitA, dataElementA, periodB, categoryOptionComboA ) );
-        assertNotNull( dataValueService.getDataValue( unitB, dataElementA, periodB, categoryOptionComboA ) );
+        assertNotNull( dataValueService.getDataValue( dataElementA, periodA, unitA, categoryOptionComboA ) );
+        assertNotNull( dataValueService.getDataValue( dataElementA, periodA, unitB, categoryOptionComboA ) );
+        assertNotNull( dataValueService.getDataValue( dataElementA, periodB, unitA, categoryOptionComboA ) );
+        assertNotNull( dataValueService.getDataValue( dataElementA, periodB, unitB, categoryOptionComboA ) );
     }
 
     @Test
@@ -189,7 +189,7 @@
         
         batchHandler.updateObject( dataValueA );
         
-        dataValueA = dataValueService.getDataValue( unitA, dataElementA, periodA, categoryOptionComboA );
+        dataValueA = dataValueService.getDataValue( dataElementA, periodA, unitA, categoryOptionComboA );
         
         assertEquals( "20", dataValueA.getValue() );
     }

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandler.java	2013-12-19 08:23:37 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandler.java	2013-12-19 18:12:57 +0000
@@ -66,6 +66,7 @@
         statementBuilder.setIdentifierColumn( "periodid" );
         statementBuilder.setIdentifierColumn( "sourceid" );
         statementBuilder.setIdentifierColumn( "categoryoptioncomboid" );
+        statementBuilder.setIdentifierColumn( "attributeoptioncomboid" );
     }
 
     @Override
@@ -75,6 +76,7 @@
         statementBuilder.setIdentifierValue( value.getPeriod().getId() );
         statementBuilder.setIdentifierValue( value.getSource().getId() );
         statementBuilder.setIdentifierValue( value.getCategoryOptionCombo().getId() );
+        statementBuilder.setIdentifierValue( value.getAttributeOptionCombo().getId() );
     }
     
     protected void setUniqueColumns()
@@ -83,6 +85,7 @@
         statementBuilder.setUniqueColumn( "periodid" );
         statementBuilder.setUniqueColumn( "sourceid" );
         statementBuilder.setUniqueColumn( "categoryoptioncomboid" );
+        statementBuilder.setUniqueColumn( "attributeoptioncomboid" );
     }
     
     protected void setUniqueValues( DataValue value )
@@ -91,6 +94,7 @@
         statementBuilder.setUniqueValue( value.getPeriod().getId() );
         statementBuilder.setUniqueValue( value.getSource().getId() );
         statementBuilder.setUniqueValue( value.getCategoryOptionCombo().getId() );
+        statementBuilder.setUniqueValue( value.getAttributeOptionCombo().getId() );
     }
     
     protected void setColumns()
@@ -98,11 +102,12 @@
         statementBuilder.setColumn( "dataelementid" );
         statementBuilder.setColumn( "periodid" );
         statementBuilder.setColumn( "sourceid" );
+        statementBuilder.setColumn( "categoryoptioncomboid" );
+        statementBuilder.setColumn( "attributeoptioncomboid" );
         statementBuilder.setColumn( "value" );
         statementBuilder.setColumn( "storedby" );
         statementBuilder.setColumn( "lastupdated" );
         statementBuilder.setColumn( "comment" );
-        statementBuilder.setColumn( "categoryoptioncomboid" );
         statementBuilder.setColumn( "followup" );
     }
     
@@ -111,11 +116,12 @@
         statementBuilder.setValue( value.getDataElement().getId() );
         statementBuilder.setValue( value.getPeriod().getId() );
         statementBuilder.setValue( value.getSource().getId() );
+        statementBuilder.setValue( value.getCategoryOptionCombo().getId() );
+        statementBuilder.setValue( value.getAttributeOptionCombo().getId() );
         statementBuilder.setValue( value.getValue() );
         statementBuilder.setValue( value.getStoredBy() );
         statementBuilder.setValue( getLongDateString( value.getTimestamp() ) );
         statementBuilder.setValue( value.getComment() );
-        statementBuilder.setValue( value.getCategoryOptionCombo().getId() );
         statementBuilder.setValue( value.isFollowup() );
     }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2013-12-19 08:23:37 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2013-12-19 18:12:57 +0000
@@ -726,11 +726,14 @@
     }
 
     /**
+     * Uses the given category option combo also as attribute option combo.
+     * 
      * @param dataElement The data element.
      * @param period The period.
      * @param source The source.
      * @param value The value.
-     * @param categoryOptionCombo The data element category option combo.
+     * @param categoryOptionCombo The category option combo.
+     * @param attributeOptionCombo The attribute option combo.
      */
     public static DataValue createDataValue( DataElement dataElement, Period period, OrganisationUnit source,
         String value, DataElementCategoryOptionCombo categoryOptionCombo )
@@ -740,36 +743,65 @@
         dataValue.setDataElement( dataElement );
         dataValue.setPeriod( period );
         dataValue.setSource( source );
-        dataValue.setValue( value );
-        dataValue.setComment( "Comment" );
-        dataValue.setStoredBy( "StoredBy" );
-        dataValue.setTimestamp( date );
-        dataValue.setCategoryOptionCombo( categoryOptionCombo );
-
-        return dataValue;
-    }
-
-    /**
-     * @param dataElement The data element.
-     * @param period The period.
-     * @param source The source.
-     * @param value The value.
-     * @param lastupdated The date.
-     * @param categoryOptionCombo The data element category option combo.
-     */
-    public static DataValue createDataValue( DataElement dataElement, Period period, OrganisationUnit source,
-        String value, Date lastupdated, DataElementCategoryOptionCombo categoryOptionCombo )
-    {
-        DataValue dataValue = new DataValue();
-
-        dataValue.setDataElement( dataElement );
-        dataValue.setPeriod( period );
-        dataValue.setSource( source );
+        dataValue.setCategoryOptionCombo( categoryOptionCombo );
+        dataValue.setAttributeOptionCombo( categoryOptionCombo );
+        dataValue.setValue( value );
+        dataValue.setComment( "Comment" );
+        dataValue.setStoredBy( "StoredBy" );
+        dataValue.setTimestamp( date );
+
+        return dataValue;
+    }
+
+    /**
+     * @param dataElement The data element.
+     * @param period The period.
+     * @param source The source.
+     * @param value The value.
+     * @param categoryOptionCombo The category option combo.
+     * @param attributeOptionCombo The attribute option combo.
+     */
+    public static DataValue createDataValue( DataElement dataElement, Period period, OrganisationUnit source,
+        String value, DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo )
+    {
+        DataValue dataValue = new DataValue();
+
+        dataValue.setDataElement( dataElement );
+        dataValue.setPeriod( period );
+        dataValue.setSource( source );
+        dataValue.setCategoryOptionCombo( categoryOptionCombo );
+        dataValue.setAttributeOptionCombo( attributeOptionCombo );
+        dataValue.setValue( value );
+        dataValue.setComment( "Comment" );
+        dataValue.setStoredBy( "StoredBy" );
+        dataValue.setTimestamp( date );
+
+        return dataValue;
+    }
+
+    /**
+     * @param dataElement The data element.
+     * @param period The period.
+     * @param source The source.
+     * @param value The value.
+     * @param lastupdated The date.value.
+     * @param categoryOptionCombo The category option combo.
+     * @param attributeOptionCombo The attribute option combo.
+     */
+    public static DataValue createDataValue( DataElement dataElement, Period period, OrganisationUnit source,
+        String value, Date lastupdated, DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo )
+    {
+        DataValue dataValue = new DataValue();
+
+        dataValue.setDataElement( dataElement );
+        dataValue.setPeriod( period );
+        dataValue.setSource( source );
+        dataValue.setCategoryOptionCombo( categoryOptionCombo );
+        dataValue.setAttributeOptionCombo( attributeOptionCombo );
         dataValue.setValue( value );
         dataValue.setComment( "Comment" );
         dataValue.setStoredBy( "StoredBy" );
         dataValue.setTimestamp( lastupdated );
-        dataValue.setCategoryOptionCombo( categoryOptionCombo );
 
         return dataValue;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java	2013-12-19 09:06:41 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java	2013-12-19 18:12:57 +0000
@@ -155,11 +155,11 @@
 
         Date now = new Date();
 
-        DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period, categoryOptionCombo );
+        DataValue dataValue = dataValueService.getDataValue( dataElement, period, organisationUnit, categoryOptionCombo );
         
         if ( dataValue == null )
         {
-            dataValue = new DataValue( dataElement, period, organisationUnit, categoryOptionCombo, null, storedBy, now, null );
+            dataValue = new DataValue( dataElement, period, organisationUnit, categoryOptionCombo, null, null, storedBy, now, null );
             
             if ( value != null )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/SaveAggregateDataValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/SaveAggregateDataValueAction.java	2013-12-19 09:06:41 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/SaveAggregateDataValueAction.java	2013-12-19 18:12:57 +0000
@@ -141,7 +141,7 @@
 
             OrganisationUnit orgunit = organisationUnitService.getOrganisationUnit( orgunitId );
 
-            DataValue dataValue = dataValueService.getDataValue( orgunit, dataElement, period, optionCombo );
+            DataValue dataValue = dataValueService.getDataValue( dataElement, period, orgunit, optionCombo );
             
             // -----------------------------------------------------------------
             // Save/Update/Delete data-values
@@ -151,7 +151,7 @@
             {
                 if ( dataValue == null )
                 {
-                    dataValue = new DataValue( dataElement, period, orgunit, optionCombo, "" + resultValue, "", new Date(), null );
+                    dataValue = new DataValue( dataElement, period, orgunit, optionCombo, null, "" + resultValue, "", new Date(), null );
 
                     dataValueService.addDataValue( dataValue );
                 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRepresentativeAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRepresentativeAction.java	2013-12-16 04:27:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRepresentativeAction.java	2013-12-19 18:12:57 +0000
@@ -35,7 +35,6 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.patient.Patient;

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2013-12-16 04:27:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2013-12-19 18:12:57 +0000
@@ -44,7 +44,6 @@
 import org.hisp.dhis.patient.PatientIdentifierService;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java	2013-12-19 04:00:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java	2013-12-19 18:12:57 +0000
@@ -52,7 +52,6 @@
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
-import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.user.UserService;
 
 import com.opensymphony.xwork2.Action;

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java	2013-12-14 14:50:17 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java	2013-12-19 18:12:57 +0000
@@ -235,7 +235,7 @@
 
         OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
 
-        dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period, optionCombo );
+        dataValue = dataValueService.getDataValue( dataElement, period, organisationUnit, optionCombo );
 
         if ( dataValue != null )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/history/DefaultHistoryRetriever.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/history/DefaultHistoryRetriever.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/history/DefaultHistoryRetriever.java	2013-12-19 18:12:57 +0000
@@ -227,7 +227,7 @@
     private Double getValue( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
         OrganisationUnit organisationUnit, Period period )
     {
-        DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period, optionCombo );
+        DataValue dataValue = dataValueService.getDataValue( dataElement, period, organisationUnit, optionCombo );
 
         if ( dataValue != null )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java	2013-12-19 09:06:41 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java	2013-12-19 18:12:57 +0000
@@ -309,11 +309,11 @@
                 String value = parameterMap.get( key );
 
                 DataElement dataElement = dataElementService.getDataElement( dataElementId );
-                DataElementCategoryOptionCombo optionCombo = categoryService
+                DataElementCategoryOptionCombo categoryOptionCombo = categoryService
                     .getDataElementCategoryOptionCombo( optionComboId );
 
                 DataValue dataValue = dataValueService
-                    .getDataValue( organisationUnit, dataElement, period, optionCombo );
+                    .getDataValue( dataElement, period, organisationUnit, categoryOptionCombo );
 
                 value = value.trim();
                 Boolean valueIsEmpty = (value == null || value.length() == 0);
@@ -406,7 +406,7 @@
                     {
                         needsValidation = true;
 
-                        dataValue = new DataValue( dataElement, period, organisationUnit, optionCombo, value, storedBy, new Date(), null );
+                        dataValue = new DataValue( dataElement, period, organisationUnit, categoryOptionCombo, null, value, storedBy, new Date(), null );
                         dataValueService.addDataValue( dataValue );
                     }
                     else

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationResultDetailsAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationResultDetailsAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationResultDetailsAction.java	2013-12-19 18:12:57 +0000
@@ -179,7 +179,7 @@
             DataElementCategoryOptionCombo categoryOptionCombo = categoryService
                 .getDataElementCategoryOptionCombo( operand.getOptionComboId() );
 
-            DataValue dataValue = dataValueService.getDataValue( source, dataElement, period, categoryOptionCombo );
+            DataValue dataValue = dataValueService.getDataValue( dataElement, period, source, categoryOptionCombo );
             
             String value = dataValue != null ? dataValue.getValue() : NULL_REPLACEMENT;
             
@@ -192,7 +192,7 @@
             DataElementCategoryOptionCombo categoryOptionCombo = categoryService
                 .getDataElementCategoryOptionCombo( operand.getOptionComboId() );
 
-            DataValue dataValue = dataValueService.getDataValue( source, dataElement, period, categoryOptionCombo );
+            DataValue dataValue = dataValueService.getDataValue( dataElement, period, source, categoryOptionCombo );
 
             String value = dataValue != null ? dataValue.getValue() : NULL_REPLACEMENT;
             

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/EditDataValueAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/EditDataValueAction.java	2013-12-19 08:23:37 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/EditDataValueAction.java	2013-12-19 18:12:57 +0000
@@ -166,7 +166,7 @@
         OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitId );
         DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( categoryOptionComboId );
         
-        DataValue dataValue = dataValueService.getDataValue( unit, dataElement, period, categoryOptionCombo );
+        DataValue dataValue = dataValueService.getDataValue( dataElement, period, unit, categoryOptionCombo );
 
         String storedBy = currentUserService.getCurrentUsername();
 

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/MarkForFollowupAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/MarkForFollowupAction.java	2013-12-19 17:45:25 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/MarkForFollowupAction.java	2013-12-19 18:12:57 +0000
@@ -144,7 +144,7 @@
         OrganisationUnit source = organisationUnitService.getOrganisationUnit( sourceId );
         DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( categoryOptionComboId );
         
-        DataValue dataValue = dataValueService.getDataValue( source, dataElement, period, categoryOptionCombo ); 
+        DataValue dataValue = dataValueService.getDataValue( dataElement, period, source, categoryOptionCombo ); 
 
         if ( dataValue != null )
         {