← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13244: include separate list of deletable types in ExchangeClasses

 

------------------------------------------------------------
revno: 13244
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-12-16 10:18:24 +0100
message:
  include separate list of deletable types in ExchangeClasses
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2013-12-16 08:58:27 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2013-12-16 09:18:24 +0000
@@ -129,7 +129,7 @@
 
         if ( importOptions.getImportStrategy().isDelete() )
         {
-            types = Lists.reverse( Lists.newArrayList( ExchangeClasses.getImportMap().values() ) );
+            types = Lists.reverse( Lists.newArrayList( ExchangeClasses.getDeletableMap().values() ) );
         }
         else
         {

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java	2013-10-31 10:29:22 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java	2013-12-16 09:18:24 +0000
@@ -98,6 +98,9 @@
     // these are the ones that are available for dxf2 import
     private final static Map<Class<? extends IdentifiableObject>, String> importClasses;
 
+    // these are the ones that are available for dxf2 delete
+    private final static Map<Class<? extends IdentifiableObject>, String> deletableClasses;
+
     static
     {
         allExportClasses = new LinkedHashMap<Class<? extends IdentifiableObject>, String>();
@@ -202,6 +205,11 @@
         allExportClasses.put( MetaDataFilter.class, "metaDataFilters" );
         exportClasses.remove( MetaDataFilter.class );
         importClasses.remove( MetaDataFilter.class );
+
+        deletableClasses = new LinkedHashMap<Class<? extends IdentifiableObject>, String>( importClasses );
+        deletableClasses.remove( User.class );
+        deletableClasses.remove( UserGroup.class );
+        deletableClasses.remove( UserAuthorityGroup.class );
     }
 
     public static Map<Class<? extends IdentifiableObject>, String> getAllExportMap()
@@ -223,4 +231,14 @@
     {
         return new ArrayList<Class<? extends IdentifiableObject>>( importClasses.keySet() );
     }
+
+    public static Map<Class<? extends IdentifiableObject>, String> getDeletableMap()
+    {
+        return Collections.unmodifiableMap( deletableClasses );
+    }
+
+    public static List<Class<? extends IdentifiableObject>> getDeletableClasses()
+    {
+        return new ArrayList<Class<? extends IdentifiableObject>>( deletableClasses.keySet() );
+    }
 }