← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21137: minor additions, methods for getting default category / categoryOption

 

------------------------------------------------------------
revno: 21137
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-11-20 11:02:48 +0700
message:
  minor additions, methods for getting default category / categoryOption
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.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/dataelement/DataElementCategoryService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java	2015-10-12 10:12:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java	2015-11-20 04:02:48 +0000
@@ -28,14 +28,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.common.IdentifiableProperty;
+import org.hisp.dhis.hierarchy.HierarchyViolationException;
+
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.hisp.dhis.common.IdentifiableProperty;
-import org.hisp.dhis.hierarchy.HierarchyViolationException;
-
 /**
  * @author Abyot Asalefew
  */
@@ -49,7 +49,7 @@
 
     /**
      * Adds a DataElementCategory.
-     * 
+     *
      * @param dataElementCategory the DataElementCategory to add.
      * @return a generated unique id of the added Category.
      */
@@ -57,7 +57,7 @@
 
     /**
      * Updates a DataElementCategory.
-     * 
+     *
      * @param dataElementCategory the DataElementCategory to update.
      */
     void updateDataElementCategory( DataElementCategory dataElementCategory );
@@ -66,16 +66,16 @@
      * Deletes a DataElementCategory. The DataElementCategory is also removed
      * from any DataElementCategoryCombos if it is a member of. It is not
      * possible to delete a DataElementCategory with options.
-     * 
+     *
      * @param dataElementCategory the DataElementCategory to delete.
      * @throws HierarchyViolationException if the DataElementCategory has
-     *         children.
+     *                                     children.
      */
     void deleteDataElementCategory( DataElementCategory dataElementCategory );
 
     /**
      * Returns a DataElementCategory.
-     * 
+     *
      * @param id the id of the DataElementCategory to return.
      * @return the DataElementCategory with the given id, or null if no match.
      */
@@ -83,8 +83,8 @@
 
     /**
      * Returns a DataElementCategory.
-     * 
-     * @param id the id of the DataElementCategory to return.
+     *
+     * @param id                  the id of the DataElementCategory to return.
      * @param i18nCategoryOptions whether to translate category options.
      * @return the DataElementCategory with the given id, or null if no match.
      */
@@ -92,7 +92,7 @@
 
     /**
      * Returns a DataElementCategory.
-     * 
+     *
      * @param uid the uid of the DataElementCategory to return.
      * @return the DataElementCategory with the given uid, or null if no match.
      */
@@ -100,7 +100,7 @@
 
     /**
      * Retrieves the DataElementCategories with the given uids.
-     * 
+     *
      * @param uids the uids of the DataElementCategories to retrieve.
      * @return a list of DataElementCategories.
      */
@@ -108,7 +108,7 @@
 
     /**
      * Retrieves the DataElementCategory with the given name.
-     * 
+     *
      * @param name the name of the DataElementCategory to retrieve.
      * @return the DataElementCategory.
      */
@@ -116,7 +116,7 @@
 
     /**
      * Retrieves the DataElementCategory with the given code.
-     * 
+     *
      * @param code the name of the DataElementCategory to retrieve.
      * @return the DataElementCategory.
      */
@@ -124,14 +124,14 @@
 
     /**
      * Returns all DataElementCategories.
-     * 
+     *
      * @return a list of all DataElementCategories.
      */
     List<DataElementCategory> getAllDataElementCategories();
 
     /**
      * Retrieves all DataElementCategories of dimension type disaggregation.
-     * 
+     *
      * @return a list of DataElementCategoryCombos.
      */
     List<DataElementCategory> getDisaggregationCategories();
@@ -139,14 +139,14 @@
     /**
      * Retrieves all DataElementCategories of dimension type disaggregation and
      * data dimensional. Ignores ACL / sharing.
-     * 
+     *
      * @return a list of DataElementCategoryCombos.
      */
     List<DataElementCategory> getDisaggregationDataDimensionCategoriesNoAcl();
 
     /**
      * Retrieves all DataElementCategories of dimension type attribute.
-     * 
+     *
      * @return a list of DataElementCategoryCombos.
      */
     List<DataElementCategory> getAttributeCategories();
@@ -154,7 +154,7 @@
     /**
      * Retrieves all DataElementCategories of dimension type attribute and data
      * dimensional. Ignores ACL / sharing.
-     * 
+     *
      * @return a list of DataElementCategoryCombos.
      */
     List<DataElementCategory> getAttributeDataDimensionCategoriesNoAcl();
@@ -165,7 +165,7 @@
 
     /**
      * Adds a DataElementCategoryOption.
-     * 
+     *
      * @param dataElementCategoryOption the DataElementCategoryOption to add.
      * @return a generated unique id of the added DataElementCategoryOption.
      */
@@ -173,39 +173,39 @@
 
     /**
      * Updates a DataElementCategoryOption.
-     * 
+     *
      * @param dataElementCategoryOption the DataElementCategoryOption to update.
      */
     void updateDataElementCategoryOption( DataElementCategoryOption dataElementCategoryOption );
 
     /**
      * Deletes a DataElementCategoryOption.
-     * 
+     *
      * @param dataElementCategoryOption
      */
     void deleteDataElementCategoryOption( DataElementCategoryOption dataElementCategoryOption );
 
     /**
      * Returns a DataElementCategoryOption.
-     * 
+     *
      * @param id the id of the DataElementCategoryOption to return.
      * @return the DataElementCategoryOption with the given id, or null if no
-     *         match.
+     * match.
      */
     DataElementCategoryOption getDataElementCategoryOption( int id );
 
     /**
      * Returns a DataElementCategoryOption.
-     * 
+     *
      * @param uid the id of the DataElementCategoryOption to return.
      * @return the DataElementCategoryOption with the given uid, or null if no
-     *         match.
+     * match.
      */
     DataElementCategoryOption getDataElementCategoryOption( String uid );
 
     /**
      * Retrieves the DataElementCategoryOptions with the given uids.
-     * 
+     *
      * @param uids the uids of the DataElementCategoryOption to retrieve.
      * @return a list of DataElementCategoryOptions.
      */
@@ -213,7 +213,7 @@
 
     /**
      * Retrieves the DataElementCategoryOption with the given name.
-     * 
+     *
      * @param name the name.
      * @return the DataElementCategoryOption with the given name.
      */
@@ -221,7 +221,7 @@
 
     /**
      * Retrieves the DataElementCategoryOption with the given short name.
-     * 
+     *
      * @param shortName the short name.
      * @return the DataElementCategoryOption with the given short name.
      */
@@ -229,7 +229,7 @@
 
     /**
      * Retrieves the DataElementCategoryOption with the given code.
-     * 
+     *
      * @param code the code.
      * @return the DataElementCategoryOption with the given code.
      */
@@ -237,28 +237,28 @@
 
     /**
      * Returns all DataElementCategoryOptions.
-     * 
+     *
      * @return a list of all DataElementCategoryOptions, or an empty
-     *         collection if there are no DataElementCategoryOptions.
+     * collection if there are no DataElementCategoryOptions.
      */
     List<DataElementCategoryOption> getAllDataElementCategoryOptions();
 
     /**
      * Returns all DataElementCategoryOptions for the given DataElementCategory.
-     * 
+     *
      * @param category the DataElementCategory.
      * @return a list of all DataElementCategoryOptions, or an empty
-     *         collection if there are no DataElementCategoryOptions.
+     * collection if there are no DataElementCategoryOptions.
      */
     List<DataElementCategoryOption> getDataElementCategoryOptions( DataElementCategory category );
-    
+
     // -------------------------------------------------------------------------
     // CategoryCombo
     // -------------------------------------------------------------------------
 
     /**
      * Adds a DataElementCategoryCombo.
-     * 
+     *
      * @param dataElementCategoryCombo the DataElementCategoryCombo to add.
      * @return the generated identifier.
      */
@@ -266,21 +266,21 @@
 
     /**
      * Updates a DataElementCategoryCombo.
-     * 
+     *
      * @param dataElementCategoryCombo the DataElementCategoryCombo to update.
      */
     void updateDataElementCategoryCombo( DataElementCategoryCombo dataElementCategoryCombo );
 
     /**
      * Deletes a DataElementCategoryCombo.
-     * 
+     *
      * @param dataElementCategoryCombo the DataElementCategoryCombo to delete.
      */
     void deleteDataElementCategoryCombo( DataElementCategoryCombo dataElementCategoryCombo );
 
     /**
      * Retrieves a DataElementCategoryCombo with the given identifier.
-     * 
+     *
      * @param id the identifier of the DataElementCategoryCombo to retrieve.
      * @return the DataElementCategoryCombo.
      */
@@ -288,7 +288,7 @@
 
     /**
      * Retrieves a DataElementCategoryCombo with the given uid.
-     * 
+     *
      * @param uid the identifier of the DataElementCategoryCombo to retrieve.
      * @return the DataElementCategoryCombo.
      */
@@ -296,7 +296,7 @@
 
     /**
      * Retrieves the DataElementCategoryCombo with the given name.
-     * 
+     *
      * @param name the name of the DataElementCategoryCombo to retrieve.
      * @return the DataElementCategoryCombo.
      */
@@ -309,28 +309,28 @@
 
     /**
      * Retrieves all DataElementCategoryCombos.
-     * 
+     *
      * @return a list of DataElementCategoryCombos.
      */
     List<DataElementCategoryCombo> getAllDataElementCategoryCombos();
 
     /**
      * Retrieves all DataElementCategoryCombos of dimension type disaggregation.
-     * 
+     *
      * @return a list of DataElementCategoryCombos.
      */
     List<DataElementCategoryCombo> getDisaggregationCategoryCombos();
 
     /**
      * Retrieves all DataElementCategoryCombos of dimension type attribute.
-     * 
+     *
      * @return a list of DataElementCategoryCombos.
      */
     List<DataElementCategoryCombo> getAttributeCategoryCombos();
-    
+
     /**
      * Validates the category combo. Possible return values are:
-     * 
+     * <p>
      * <ul>
      * <li>category_combo_is_null</li>
      * <li>category_combo_must_have_at_least_one_category</li>
@@ -338,7 +338,7 @@
      * <li>categories_must_have_at_least_one_category_option</li>
      * <li>categories_cannot_share_category_options</li>
      * </ul>
-     * 
+     *
      * @param categoryCombo the category combo to validate.
      * @return null if valid, non-empty string if invalid.
      */
@@ -350,32 +350,32 @@
 
     /**
      * Adds a DataElementCategoryOptionCombo.
-     * 
+     *
      * @param dataElementCategoryOptionCombo the DataElementCategoryOptionCombo
-     *        to add.
+     *                                       to add.
      * @return the generated identifier.
      */
     int addDataElementCategoryOptionCombo( DataElementCategoryOptionCombo dataElementCategoryOptionCombo );
 
     /**
      * Updates a DataElementCategoryOptionCombo.
-     * 
+     *
      * @param dataElementCategoryOptionCombo the DataElementCategoryOptionCombo
-     *        to update.
+     *                                       to update.
      */
     void updateDataElementCategoryOptionCombo( DataElementCategoryOptionCombo dataElementCategoryOptionCombo );
 
     /**
      * Deletes a DataElementCategoryOptionCombo.
-     * 
+     *
      * @param dataElementCategoryOptionCombo the DataElementCategoryOptionCombo
-     *        to delete.
+     *                                       to delete.
      */
     void deleteDataElementCategoryOptionCombo( DataElementCategoryOptionCombo dataElementCategoryOptionCombo );
 
     /**
      * Retrieves the DataElementCategoryOptionCombo with the given identifier.
-     * 
+     *
      * @param id the identifier of the DataElementCategoryOptionCombo.
      * @return the DataElementCategoryOptionCombo.
      */
@@ -383,7 +383,7 @@
 
     /**
      * Retrieves the DataElementCategoryOptionCombo with the given uid.
-     * 
+     *
      * @param uid the uid of the DataElementCategoryOptionCombo.
      * @return the DataElementCategoryOptionCombo.
      */
@@ -391,7 +391,7 @@
 
     /**
      * Retrieves the DataElementCategoryOptionCombo with the given uid.
-     * 
+     *
      * @param code the code of the DataElementCategoryOptionCombo.
      * @return the DataElementCategoryOptionCombo.
      */
@@ -399,9 +399,9 @@
 
     /**
      * Retrieves the DataElementCategoryOptionCombos with the given uids.
-     * 
+     *
      * @param uids the uids of the
-     *        DataElementCategoryOptionCombos.
+     *             DataElementCategoryOptionCombos.
      * @return a List of DataElementCategoryOptionCombos.
      */
     List<DataElementCategoryOptionCombo> getDataElementCategoryOptionCombosByUid( Collection<String> uids );
@@ -409,7 +409,7 @@
     /**
      * Retrieves the DataElementCategoryOptionCombo with the given Collection of
      * DataElementCategoryOptions.
-     * 
+     *
      * @param categoryOptions
      */
     DataElementCategoryOptionCombo getDataElementCategoryOptionCombo(
@@ -417,17 +417,17 @@
 
     /**
      * Retrieves a DataElementCategoryOptionCombo.
-     * 
+     *
      * @param categoryOptionCombo the DataElementCategoryOptionCombo to
-     *        retrieve.
+     *                            retrieve.
      * @return a DataElementCategoryOptionCombo.
      */
     DataElementCategoryOptionCombo getDataElementCategoryOptionCombo( DataElementCategoryOptionCombo categoryOptionCombo );
 
     /**
      * Retrieves a DataElementCategoryOptionCombo.
-     * 
-     * @param categoryCombo the DataElementCategoryOptionCombo.
+     *
+     * @param categoryCombo   the DataElementCategoryOptionCombo.
      * @param categoryOptions the set of DataElementCategoryOptions.
      */
     DataElementCategoryOptionCombo getDataElementCategoryOptionCombo( DataElementCategoryCombo categoryCombo,
@@ -435,26 +435,25 @@
 
     /**
      * Retrieves all DataElementCategoryOptionCombos.
-     * 
+     *
      * @return a list of DataElementCategoryOptionCombos.
      */
     List<DataElementCategoryOptionCombo> getAllDataElementCategoryOptionCombos();
-    
+
     /**
      * Returns {@link DataElementCategoryOptionCombo} list with paging
      *
-     * @param min  First result
-     * @param max  Maximum results
-     * 
+     * @param min First result
+     * @param max Maximum results
      * @return a list of all category-option-combo
      */
     List<DataElementCategoryOptionCombo> getOptionCombosBetween( int min, int max );
-    
+
     /**
      * Returns The number of all DataElementCategoryOptionCombo available
      */
     Integer getOptionComboCount();
-    
+
     /**
      * Generates and persists a default DataElementCategory,
      * DataElementCategoryOption, DataElementCategoryCombo and
@@ -464,7 +463,7 @@
 
     /**
      * Retrieves the default DataElementCategoryOptionCombo.
-     * 
+     *
      * @return the DataElementCategoryOptionCombo.
      */
     DataElementCategoryOptionCombo getDefaultDataElementCategoryOptionCombo();
@@ -472,7 +471,7 @@
     /**
      * Generates and persists DataElementCategoryOptionCombos for the given
      * DataElementCategoryCombo.
-     * 
+     *
      * @param categoryCombo the DataElementCategoryCombo.
      */
     void generateOptionCombos( DataElementCategoryCombo categoryCombo );
@@ -480,7 +479,7 @@
     /**
      * Invokes updateOptionCombos( DataElementCategoryCombo ) for all category
      * combos which the given category is a part of.
-     * 
+     *
      * @param category the DataElementCategory.
      */
     void updateOptionCombos( DataElementCategory category );
@@ -489,7 +488,7 @@
      * Generates the complete set of category option combos for the given
      * category combo and compares it to the set of persisted category option
      * combos. Those which are not matched are persisted.
-     * 
+     *
      * @param categoryCombo the DataElementCategoryCombo.
      */
     void updateOptionCombos( DataElementCategoryCombo categoryCombo );
@@ -499,17 +498,17 @@
      * combos.
      */
     void updateAllOptionCombos();
-    
+
     /**
      * Returns the category option combo with the given uid. Respects access control
      * by only returning objects which all category options are accessible.
-     * 
+     *
      * @param property the property.
-     * @param id the id.
+     * @param id       the id.
      * @return a category option combo.
      */
     DataElementCategoryOptionCombo getDataElementCategoryOptionComboAcl( IdentifiableProperty property, String id );
-    
+
     List<DataElementCategory> getDataElementCategoriesBetween( int first, int max );
 
     List<DataElementCategory> getDataElementCategoriesBetweenByName( String name, int first, int max );
@@ -551,7 +550,7 @@
     /**
      * Populates all transient properties on each Operand in the given
      * collection.
-     * 
+     *
      * @param operands the collection of Operands.
      * @return a set of Operands.
      */
@@ -559,7 +558,7 @@
 
     /**
      * Gets the Operands for the given Collection of DataElements.
-     * 
+     *
      * @param dataElements the Collection of DataElements.
      * @return the Operands for the given Collection of DataElements.
      */
@@ -567,10 +566,10 @@
 
     /**
      * Gets the Operands for the given Collection of DataElements.
-     * 
-     * @param dataElements the Collection of DataElements.
+     *
+     * @param dataElements  the Collection of DataElements.
      * @param includeTotals whether to include DataElement totals in the
-     *        Collection of Operands.
+     *                      Collection of Operands.
      * @return the Operands for the given Collection of DataElements.
      */
     List<DataElementOperand> getOperands( Collection<DataElement> dataElements, boolean includeTotals );
@@ -586,7 +585,7 @@
     CategoryOptionGroup getCategoryOptionGroup( int id );
 
     CategoryOptionGroup getCategoryOptionGroup( String uid );
-    
+
     List<CategoryOptionGroup> getCategoryOptionGroupsByUid( Collection<String> uids );
 
     void deleteCategoryOptionGroup( CategoryOptionGroup group );
@@ -596,7 +595,7 @@
     List<CategoryOptionGroup> getCategoryOptionGroupsBetweenByName( int first, int max, String name );
 
     List<CategoryOptionGroup> getAllCategoryOptionGroups();
-    
+
     List<CategoryOptionGroup> getCategoryOptionGroups( CategoryOptionGroupSet groupSet );
 
     CategoryOptionGroup getCategoryOptionGroupByName( String name );
@@ -620,7 +619,7 @@
     CategoryOptionGroupSet getCategoryOptionGroupSet( int id );
 
     CategoryOptionGroupSet getCategoryOptionGroupSet( String uid );
-    
+
     List<CategoryOptionGroupSet> getCategoryOptionGroupSetsByUid( Collection<String> uids );
 
     void deleteCategoryOptionGroupSet( CategoryOptionGroupSet group );
@@ -630,14 +629,18 @@
     List<CategoryOptionGroupSet> getCategoryOptionGroupSetsBetweenByName( int first, int max, String name );
 
     List<CategoryOptionGroupSet> getAllCategoryOptionGroupSets();
-    
+
     List<CategoryOptionGroupSet> getDisaggregationCategoryOptionGroupSetsNoAcl();
-    
+
     List<CategoryOptionGroupSet> getAttributeCategoryOptionGroupSetsNoAcl();
-    
+
     CategoryOptionGroupSet getCategoryOptionGroupSetByName( String name );
 
     int getCategoryOptionGroupSetCount();
 
     int getCategoryOptionGroupSetCountByName( String name );
+
+    DataElementCategoryOption getDefaultDataElementCategoryOption();
+
+    DataElementCategory getDefaultDataElementCategory();
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2015-10-22 07:27:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2015-11-20 04:02:48 +0000
@@ -28,16 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.common.collect.Sets;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -48,7 +39,15 @@
 import org.hisp.dhis.i18n.I18nService;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.google.common.collect.Sets;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
 
 /**
  * @author Abyot Asalefew
@@ -111,7 +110,7 @@
     {
         this.dataElementService = dataElementService;
     }
-    
+
     private IdentifiableObjectManager idObjectManager;
 
     public void setIdObjectManager( IdentifiableObjectManager idObjectManager )
@@ -164,7 +163,7 @@
     public DataElementCategory getDataElementCategory( int id, boolean i18nCategoryOptions )
     {
         DataElementCategory category = getDataElementCategory( id );
-        
+
         if ( category != null )
         {
             if ( i18nCategoryOptions )
@@ -172,7 +171,7 @@
                 i18n( i18nService, category.getCategoryOptions() );
             }
         }
-        
+
         return category;
     }
 
@@ -203,6 +202,12 @@
     }
 
     @Override
+    public DataElementCategory getDefaultDataElementCategory()
+    {
+        return getDataElementCategoryByName( DataElementCategory.DEFAULT_NAME );
+    }
+
+    @Override
     public DataElementCategory getDataElementCategoryByCode( String code )
     {
         return categoryStore.getByCode( code );
@@ -309,11 +314,17 @@
     }
 
     @Override
+    public DataElementCategoryOption getDefaultDataElementCategoryOption()
+    {
+        return getDataElementCategoryOptionByName( DataElementCategoryOption.DEFAULT_NAME );
+    }
+
+    @Override
     public DataElementCategoryOption getDataElementCategoryOptionByShortName( String shortName )
     {
         return i18n( i18nService, categoryOptionStore.getByShortName( shortName ) );
     }
-    
+
     @Override
     public DataElementCategoryOption getDataElementCategoryOptionByCode( String code )
     {
@@ -458,35 +469,35 @@
         {
             return "category_combo_is_null";
         }
-        
+
         if ( categoryCombo.getCategories() == null || categoryCombo.getCategories().isEmpty() )
         {
             return "category_combo_must_have_at_least_one_category";
         }
-        
+
         if ( Sets.newHashSet( categoryCombo.getCategories() ).size() < categoryCombo.getCategories().size() )
         {
             return "category_combo_cannot_have_duplicate_categories";
         }
-        
+
         Set<DataElementCategoryOption> categoryOptions = new HashSet<DataElementCategoryOption>();
-        
-        for ( DataElementCategory category: categoryCombo.getCategories() )
+
+        for ( DataElementCategory category : categoryCombo.getCategories() )
         {
             if ( category == null || category.getCategoryOptions().isEmpty() )
             {
                 return "categories_must_have_at_least_one_category_option";
             }
-            
+
             if ( !Sets.intersection( categoryOptions, Sets.newHashSet( category.getCategoryOptions() ) ).isEmpty() )
             {
                 return "categories_cannot_share_category_options";
             }
         }
-        
+
         return null;
     }
-    
+
     // -------------------------------------------------------------------------
     // CategoryOptionCombo
     // -------------------------------------------------------------------------
@@ -520,7 +531,7 @@
     {
         return categoryOptionComboStore.getByUid( uid );
     }
-    
+
     @Override
     public DataElementCategoryOptionCombo getDataElementCategoryOptionComboByCode( String code )
     {
@@ -585,13 +596,13 @@
     {
         return categoryOptionComboStore.getAllOrderedLastUpdated( min, max );
     }
-    
+
     @Override
     public Integer getOptionComboCount()
     {
         return categoryOptionComboStore.getCount();
     }
-    
+
     @Override
     public void generateDefaultDimension()
     {
@@ -743,20 +754,20 @@
     public DataElementCategoryOptionCombo getDataElementCategoryOptionComboAcl( IdentifiableProperty property, String id )
     {
         DataElementCategoryOptionCombo coc = idObjectManager.getObject( DataElementCategoryOptionCombo.class, property, id );
-        
+
         return canReadDataElementCategoryOptionCombo( coc ) ? coc : null;
     }
-        
+
     private boolean canReadDataElementCategoryOptionCombo( DataElementCategoryOptionCombo categoryOptionCombo )
     {
         if ( categoryOptionCombo == null )
         {
             return false;
         }
-        
-        List<DataElementCategoryOption> options = categoryOptionStore.getByUid( 
+
+        List<DataElementCategoryOption> options = categoryOptionStore.getByUid(
             IdentifiableObjectUtils.getUids( categoryOptionCombo.getCategoryOptions() ) );
-        
+
         return options.size() == categoryOptionCombo.getCategoryOptions().size();
     }
 
@@ -798,15 +809,15 @@
                 {
                     DataElementOperand operand = new DataElementOperand( dataElement );
                     operand.updateProperties( dataElement );
-    
+
                     operands.add( operand );
                 }
-    
+
                 for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getSortedOptionCombos() )
                 {
                     DataElementOperand operand = new DataElementOperand( dataElement, categoryOptionCombo );
                     operand.updateProperties( dataElement, categoryOptionCombo );
-    
+
                     operands.add( operand );
                 }
             }
@@ -848,7 +859,7 @@
     {
         return categoryOptionGroupStore.getByUid( uids );
     }
-    
+
     @Override
     public void deleteCategoryOptionGroup( CategoryOptionGroup group )
     {
@@ -878,7 +889,7 @@
     {
         return categoryOptionGroupStore.getCategoryOptionGroups( groupSet );
     }
-    
+
     @Override
     public CategoryOptionGroup getCategoryOptionGroupByName( String name )
     {
@@ -944,7 +955,7 @@
     {
         return categoryOptionGroupSetStore.getByUid( uid );
     }
-    
+
     @Override
     public List<CategoryOptionGroupSet> getCategoryOptionGroupSetsByUid( Collection<String> uids )
     {
@@ -974,7 +985,7 @@
     {
         return categoryOptionGroupSetStore.getAll();
     }
-    
+
     @Override
     public List<CategoryOptionGroupSet> getDisaggregationCategoryOptionGroupSetsNoAcl()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java	2015-11-20 03:36:20 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java	2015-11-20 04:02:48 +0000
@@ -463,13 +463,13 @@
 
         if ( DataElementCategoryOption.class.isInstance( object ) && ((DataElementCategoryOption) object).isDefault() )
         {
-            objects.add( (T) dataElementCategoryService.getDataElementCategoryOptionByName( DataElementCategoryOption.DEFAULT_NAME ) );
+            objects.add( (T) dataElementCategoryService.getDefaultDataElementCategoryOption() );
             return objects;
         }
 
         if ( DataElementCategory.class.isInstance( object ) && ((DataElementCategory) object).isDefault() )
         {
-            objects.add( (T) dataElementCategoryService.getDataElementCategoryByName( DataElementCategory.DEFAULT_NAME ) );
+            objects.add( (T) dataElementCategoryService.getDefaultDataElementCategory() );
             return objects;
         }