← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12842: in detailed meta-data export, support all flag that simply exports all of one type

 

------------------------------------------------------------
revno: 12842
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-10-31 10:19:04 +0100
message:
  in detailed meta-data export, support all flag that simply exports all of one type
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaDataDependencyService.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filteredMetaDataExport.js


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java	2013-10-30 12:51:03 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java	2013-10-31 09:19:04 +0000
@@ -189,7 +189,7 @@
         }
 
 
-        Map<String, List<String>> identifiableObjectUidMap = new ObjectMapper().readValue( json, new TypeReference<HashMap<String, List<String>>>()
+        Map<String, Object> identifiableObjectUidMap = new ObjectMapper().readValue( json, new TypeReference<HashMap<String, Object>>()
         {
         } );
 

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.java	2013-10-30 12:51:03 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.java	2013-10-31 09:19:04 +0000
@@ -90,19 +90,31 @@
     // Get MetaData dependency Map
     //--------------------------------------------------------------------------
 
-    public Map<String, List<IdentifiableObject>> getIdentifiableObjectMap( Map<String, List<String>> identifiableObjectUidMap )
+    public Map<String, List<IdentifiableObject>> getIdentifiableObjectMap( Map<String, Object> identifiableObjectUidMap )
     {
         Map<String, List<IdentifiableObject>> identifiableObjectMap = new HashMap<String, List<IdentifiableObject>>();
 
-        for ( Map.Entry<String, List<String>> identifiableObjectUidEntry : identifiableObjectUidMap.entrySet() )
+        for ( Map.Entry<String, Object> identifiableObjectUidEntry : identifiableObjectUidMap.entrySet() )
         {
             String className = identifiableObjectUidEntry.getKey();
+
             for ( Map.Entry<Class<? extends IdentifiableObject>, String> entry : ExchangeClasses.getExportMap().entrySet() )
             {
-                if ( entry.getValue().equals( className ) )
+                if ( className.equals( (entry.getValue() + "_all") ) )
+                {
+                    Boolean o = (Boolean) identifiableObjectUidMap.get( className );
+
+                    if ( o != null && o )
+                    {
+                        Class<? extends IdentifiableObject> identifiableObjectClass = entry.getKey();
+                        Collection<? extends IdentifiableObject> identifiableObjects = manager.getAll( identifiableObjectClass );
+                        identifiableObjectMap.put( entry.getValue(), new ArrayList<IdentifiableObject>( identifiableObjects ) );
+                    }
+                }
+                else if ( entry.getValue().equals( className ) )
                 {
                     Class<? extends IdentifiableObject> identifiableObjectClass = entry.getKey();
-                    Collection<? extends IdentifiableObject> identifiableObjects = manager.getByUid( identifiableObjectClass, identifiableObjectUidEntry.getValue() );
+                    Collection<? extends IdentifiableObject> identifiableObjects = manager.getByUid( identifiableObjectClass, (Collection<String>) identifiableObjectUidEntry.getValue() );
 
                     identifiableObjectMap.put( entry.getValue(), new ArrayList<IdentifiableObject>( identifiableObjects ) );
                 }
@@ -112,7 +124,7 @@
         return identifiableObjectMap;
     }
 
-    public Map<String, List<IdentifiableObject>> getIdentifiableObjectWithDependencyMap( Map<String, List<String>> identifiableObjectUidMap )
+    public Map<String, List<IdentifiableObject>> getIdentifiableObjectWithDependencyMap( Map<String, Object> identifiableObjectUidMap )
     {
         Map<String, List<IdentifiableObject>> identifiableObjectMap = getIdentifiableObjectMap( identifiableObjectUidMap );
         Collection<IdentifiableObject> identifiableObjects = new HashSet<IdentifiableObject>();

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaDataDependencyService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaDataDependencyService.java	2013-08-27 06:44:31 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaDataDependencyService.java	2013-10-31 09:19:04 +0000
@@ -39,9 +39,9 @@
  */
 public interface MetaDataDependencyService
 {
-    Map<String, List<IdentifiableObject>> getIdentifiableObjectMap( Map<String, List<String>> identifiableObjectUidMap );
+    Map<String, List<IdentifiableObject>> getIdentifiableObjectMap( Map<String, Object> identifiableObjectUidMap );
 
-    Map<String, List<IdentifiableObject>> getIdentifiableObjectWithDependencyMap( Map<String, List<String>> identifiableObjectUidMap );
+    Map<String, List<IdentifiableObject>> getIdentifiableObjectWithDependencyMap( Map<String, Object> identifiableObjectUidMap );
 
     Set<IdentifiableObject> getDependencySet( IdentifiableObject identifiableObject );
 

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filteredMetaDataExport.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filteredMetaDataExport.js	2013-10-30 12:51:03 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filteredMetaDataExport.js	2013-10-31 09:19:04 +0000
@@ -27,6 +27,7 @@
     if ( $( "#jsonFilter" ).attr( "value" ) != "" )
     {
         selectAllMetaDataCategories();
+
         $( "body" ).ajaxComplete( function ()
         {
             applyFilter();
@@ -44,15 +45,15 @@
 
         $( "#checkboxSelectAll" + metaDataArray[i] ).change( function ()
         {
-            var metaDataCategoryName = $( this ).attr( "name" );
+            var metaDataCategoryName = $(this).attr("name");
 
-            if ( $( this ).is( ":checked" ) )
-            {
-                $( this ).attr( 'checked', true );
-                selectAllValuesByCategory( metaDataCategoryName );
-            } else
-            {
-                deselectValuesByCategory( metaDataCategoryName );
+            if( $(this).is(":checked") ) {
+                $(this).attr('checked', true);
+                $( "#heading" + metaDataCategoryName ).css( "background", "#CFFFB3 50% 50% repeat-x" );
+                // selectAllValuesByCategory(metaDataCategoryName);
+            } else {
+                // deselectValuesByCategory(metaDataCategoryName);
+                $( "#heading" + metaDataCategoryName ).css( "background", "" );
             }
         } );
     }
@@ -68,13 +69,11 @@
 // Insert MetaData HTML & CSS for a Category
 function insertMetaDataCategoryDesign( metaDataCategoryName )
 {
-    if ( $( "#mainDiv" + metaDataCategoryName ).is( ":empty" ) )
-    {
+    if ( $( "#mainDiv" + metaDataCategoryName ).is( ":empty" ) ) {
         var design = generateMetaDataCategoryDesign( metaDataCategoryName );
         $( "#mainDiv" + metaDataCategoryName ).append( design );
         loadMetaData( metaDataCategoryName );
-    } else
-    {
+    } else {
         deselectAllValues();
     }
 }
@@ -141,6 +140,7 @@
 function moveSelected( metaDataCategoryName )
 {
     dhisAjaxSelect_moveAllSelected( "available" + metaDataCategoryName );
+
     if ( $( "#selected" + metaDataCategoryName + " option" ).length > 0 )
     {
         $( "#heading" + metaDataCategoryName ).css( "background", "#CFFFB3 50% 50% repeat-x" );
@@ -203,21 +203,20 @@
 // Load MetaData by Category
 function loadMetaData( metaDataCategoryName )
 {
-    $( "#available" + metaDataCategoryName ).dhisAjaxSelect(
+    $( "#available" + metaDataCategoryName ).dhisAjaxSelect( {
+        source: "../api/" + lowercaseFirstLetter( metaDataCategoryName ) + ".json?links=false&paging=false",
+        iterator: lowercaseFirstLetter( metaDataCategoryName ),
+        connectedTo: "selected" + metaDataCategoryName,
+        handler: function ( item )
         {
-            source: "../api/" + lowercaseFirstLetter( metaDataCategoryName ) + ".json?links=false&paging=false",
-            iterator: lowercaseFirstLetter( metaDataCategoryName ),
-            connectedTo: "selected" + metaDataCategoryName,
-            handler: function ( item )
-            {
-                var option = jQuery( "<option/>" );
-                option.text( item.name );
-                option.attr( "name", item.name );
-                option.attr( "value", item.id );
+            var option = jQuery( "<option/>" );
+            option.text( item.name );
+            option.attr( "name", item.name );
+            option.attr( "value", item.id );
 
-                return option;
-            }
-        } );
+            return option;
+        }
+    } );
 }
 
 // -----------------------------------------------------------------------------
@@ -250,19 +249,24 @@
 
     for ( var i = 0; i < metaDataArray.length; i++ )
     {
-        var metaDataCategoryValues = [];
-
-        var values = $( "#selected" + metaDataArray[i] ).val();
-
-        if ( values != undefined )
-        {
-            metaDataCategoryValues = values;
-        }
-
-        if ( metaDataCategoryValues.length != 0 )
-        {
-            var metaDataCategory = lowercaseFirstLetter( metaDataArray[i] );
-            jsonFilter[metaDataCategory] = metaDataCategoryValues;
+        var metaDataCategory = lowercaseFirstLetter( metaDataArray[i] );
+
+        if( $("#checkboxSelectAll" + metaDataArray[i]).is(':checked') ) {
+            jsonFilter[metaDataCategory + "_all"] = true;
+        } else {
+            var metaDataCategoryValues = [];
+
+            var values = $( "#selected" + metaDataArray[i] ).val();
+
+            if ( values != undefined )
+            {
+                metaDataCategoryValues = values;
+            }
+
+            if ( metaDataCategoryValues.length != 0 )
+            {
+                jsonFilter[metaDataCategory] = metaDataCategoryValues;
+            }
         }
     }
 
@@ -350,7 +354,11 @@
     {
         category = lowercaseFirstLetter( metaDataArray[i] );
 
-        if ( jsonFilter.hasOwnProperty( category ) )
+        if( jsonFilter[category + "_all"] && jsonFilter[category + "_all"] == true ) {
+            $("#checkboxSelectAll" + metaDataArray[i]).attr('checked', true);
+            $("#heading" + metaDataArray[i]).css("background", "#CFFFB3 50% 50% repeat-x");
+        }
+        else if ( jsonFilter.hasOwnProperty( category ) )
         {
             var uidValues = jsonFilter[category];