← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10760: Indexeddb updates for offline anonymous, now works correctly in firefox. Offline is not supported...

 

------------------------------------------------------------
revno: 10760
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-05-03 23:27:51 +0700
message:
  Indexeddb updates for offline anonymous, now works correctly in firefox. Offline is not supported at all in chrome at the moment.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.idb.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.ls.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.ss.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-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-05-03 05:18:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-05-03 16:27:51 +0000
@@ -1,43 +1,34 @@
 var DAO = DAO || {};
 
-DAO.metaData = new dhis2.storage.Store( {
+DAO.store = new dhis2.storage.Store( {
     name: 'dhis2',
-    adapters: [ dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter ],
+    adapters: [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter ],
     objectStores: [ 'programs', 'programStages', 'optionSets', 'usernames', {
-        name: 'values',
-        adapters: [ dhis2.storage.DomSessionStorageAdapter ]
+        name: 'dataValues',
+        adapters: [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomLocalStorageAdapter, dhis2.storage.InMemoryAdapter ]
     } ]
 } );
 
-DAO.offlineData = new dhis2.storage.Store( {
-    name: 'dhis2',
-    adapters: [ dhis2.storage.DomLocalStorageAdapter, dhis2.storage.InMemoryAdapter ],
-    objectStores: [ 'dataValues' ]
-} );
-
-DAO.metaData.open();
-DAO.offlineData.open();
-
 function loadPrograms() {
     var def = $.Deferred();
 
-    $.ajax({
+    $.ajax( {
         url: 'getProgramMetaData.action',
         dataType: 'json'
-    } ).done(function(data) {
+    } ).done(function ( data ) {
         var programs = _.values( data.metaData.programs );
-        DAO.metaData.setAll('programs', programs ).then(function() {
-            def.resolve(data.metaData);
-        });
-    } ).always(function() {
+        DAO.store.setAll( 'programs', programs ).then( function () {
+            def.resolve( data.metaData );
+        } );
+    } ).fail( function () {
         def.resolve();
-    });
+    } );
 
     return def.promise();
 }
 
 function loadProgramStages( metaData ) {
-    if(!metaData) {
+    if ( !metaData ) {
         return;
     }
 
@@ -45,35 +36,35 @@
     var deferred2 = $.Deferred();
     var promise = deferred2.promise();
 
-    _.each( _.values(metaData.programs), function(el, idx) {
+    _.each( _.values( metaData.programs ), function ( el, idx ) {
         var psid = el.programStages[0].id;
-        var data = createProgramStage(psid);
+        var data = createProgramStage( psid );
 
-        promise = promise.then(function() {
+        promise = promise.then( function () {
             return $.ajax( {
                 url: 'dataentryform.action',
                 data: data,
                 dataType: 'html'
-            } ).done(function(data) {
-                var obj = {};
-                obj.id = psid;
-                obj.form = data;
-                DAO.metaData.set('programStages', obj);
-            });
-        });
-    });
+            } ).done( function ( data ) {
+                    var obj = {};
+                    obj.id = psid;
+                    obj.form = data;
+                    DAO.store.set( 'programStages', obj );
+                } );
+        } );
+    } );
 
-    promise = promise.then(function() {
+    promise = promise.then( function () {
         deferred1.resolve( metaData );
-    });
+    } );
 
     deferred2.resolve();
 
     return deferred1.promise();
 }
 
-function loadOptionSets(metaData) {
-    if(!metaData) {
+function loadOptionSets( metaData ) {
+    if ( !metaData ) {
         return;
     }
 
@@ -90,28 +81,28 @@
                 var obj = {};
                 obj.id = item;
                 obj.optionSet = data.optionSet;
-                DAO.metaData.set('optionSets', obj);
+                DAO.store.set( 'optionSets', obj );
             } );
         } );
     } );
 
     if ( metaData.usernames ) {
-        promise = promise.then( function() {
+        promise = promise.then( function () {
             return $.ajax( {
                 url: 'getUsernames.action',
                 dataType: 'json'
-            } ).done( function (data) {
-                var obj = {};
-                obj.id = 'usernames';
-                obj.usernames = data.usernames;
-                DAO.metaData.set('usernames', obj);
-            } )
+            } ).done( function ( data ) {
+                    var obj = {};
+                    obj.id = 'usernames';
+                    obj.usernames = data.usernames;
+                    DAO.store.set( 'usernames', obj );
+                } )
         } );
     }
 
-    promise = promise.then(function() {
+    promise = promise.then( function () {
         deferred1.resolve( metaData );
-    });
+    } );
 
     deferred2.resolve();
 
@@ -125,9 +116,9 @@
     var offline_template = $( '#offline-event-template' );
     var offline_template_compiled = _.template( offline_template.html() );
 
-    return DAO.offlineData.getAll( 'dataValues' ).done( function ( arr ) {
+    return DAO.store.getAll( 'dataValues' ).done( function ( arr ) {
         var orgUnitId = selection.getSelected();
-        var programId = $('#programId').val();
+        var programId = $( '#programId' ).val();
 
         var target = $( '#offlineEventList' );
         target.children().remove();
@@ -165,32 +156,32 @@
 
 var haveLocalData = false;
 
-function checkOfflineData(callback) {
-    return DAO.offlineData.getAll( 'dataValues' ).done( function ( arr ) {
+function checkOfflineData( callback ) {
+    return DAO.store.getAll( 'dataValues' ).done( function ( arr ) {
         haveLocalData = arr.length > 0;
-        if(callback && typeof callback == 'function') callback(haveLocalData);
-    });
+        if ( callback && typeof callback == 'function' ) callback( haveLocalData );
+    } );
 }
 
 function uploadOfflineData( item ) {
-    $.ajax({
+    $.ajax( {
         url: 'uploadAnonymousEvent.action',
         contentType: 'application/json',
         data: JSON.stringify( item )
-    } ).done(function(json) {
+    } ).done( function ( json ) {
         if ( json.response == 'success' ) {
-            DAO.offlineData.delete( 'dataValues', item.id ).done( function () {
+            DAO.store.delete( 'dataValues', item.id ).done( function () {
                 updateOfflineEvents();
                 searchEvents( eval( getFieldValue( 'listAll' ) ) );
             } );
         }
-    });
+    } );
 }
 
 function uploadLocalData() {
     setHeaderWaitMessage( i18n_uploading_data_notification );
 
-    DAO.offlineData.getAll( 'dataValues' ).done( function ( arr ) {
+    DAO.store.getAll( 'dataValues' ).done( function ( arr ) {
         if(arr.length == 0) {
             setHeaderDelayMessage( i18n_sync_success );
             return;
@@ -231,17 +222,18 @@
     $( "#orgUnitTree" ).one( "ouwtLoaded", function () {
         var def = $.Deferred();
         var promise = def.promise();
-        promise = promise.then(loadPrograms);
-        promise = promise.then(loadProgramStages);
-        promise = promise.then(loadOptionSets);
-        promise = promise.then(updateOfflineEvents);
-        promise = promise.then(checkOfflineData);
-        promise = promise.then(function() {
+        promise = promise.then( DAO.store.open );
+        promise = promise.then( loadPrograms );
+        promise = promise.then( loadProgramStages );
+        promise = promise.then( loadOptionSets );
+        promise = promise.then( updateOfflineEvents );
+        promise = promise.then( checkOfflineData );
+        promise = promise.then( function () {
             selection.setListenerFunction( organisationUnitSelected );
 
             dhis2.availability.startAvailabilityCheck();
             selection.responseReceived();
-        });
+        } );
 
         def.resolve();
     } );
@@ -356,7 +348,7 @@
     hideById( 'listDiv' );
     hideById( 'dataEntryInfor' );
 
-    DAO.metaData.getAll( 'programs' ).done( function (arr) {
+    DAO.store.getAll( 'programs' ).done( function (arr) {
         var programs = [];
 
         $.each( arr, function ( idx, item ) {
@@ -811,7 +803,7 @@
 
     if( s.indexOf("local") != -1) {
         if ( confirm( i18n_comfirm_delete_event ) ) {
-            DAO.offlineData.delete( 'dataValues', programStageId ).always( function () {
+            DAO.store.delete( 'dataValues', programStageId ).always( function () {
                 updateOfflineEvents();
             } );
         }
@@ -973,7 +965,7 @@
                 }
             } ).fail( function () {
                 if(programStageInstanceId == 0) {
-                    DAO.offlineData.getKeys( 'dataValues' ).done( function ( keys ) {
+                    DAO.store.getKeys( 'dataValues' ).done( function ( keys ) {
                         var i = 100;
 
                         for(; i<10000; i++) {
@@ -1085,7 +1077,7 @@
 function loadProgramStage( programStageId, programStageInstanceId, organisationUnitId, success, fail ) {
     var data = createProgramStage( programStageId, programStageInstanceId, organisationUnitId );
 
-    DAO.metaData.get('programStages', programStageId ).done(function(obj) {
+    DAO.store.get('programStages', programStageId ).done(function(obj) {
         if(success) success(obj.form);
     } ).fail(function() {
         $.ajax( {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-05-03 04:18:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-05-03 16:27:51 +0000
@@ -288,7 +288,7 @@
  
     function handleHttpError( errorCode )
     {
-        if( getProgramType() == 3 && DAO.offlineData ) {
+        if( getProgramType() == 3 && DAO.store ) {
             var data = {
                 providedElsewhere: byId( providedElsewhereId ) != null ? byId( providedElsewhereId ).checked : false,
                 value: value != '' ? htmlEncode( value ) : value
@@ -297,7 +297,7 @@
             var dataValueKey = $( '#programStageInstanceId' ).val();
             var key = dataElementUid;
 
-            DAO.offlineData.get( 'dataValues', dataValueKey ).done( function ( obj ) {
+            DAO.store.get( 'dataValues', dataValueKey ).done( function ( obj ) {
                 if ( !obj ) {
                     markValue( ERROR );
                     window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
@@ -593,17 +593,17 @@
                 if ( getProgramType() == 3 ) {
                     var programStageInstanceId = getFieldValue( 'programStageInstanceId' );
 
-                    if ( window.DAO && window.DAO.offlineData ) {
+                    if ( window.DAO && window.DAO.store ) {
                         jQuery(".stage-object-selected").css('border-color', COLOR_GREEN);
                         jQuery(".stage-object-selected").css('background-color', COLOR_LIGHT_GREEN);
 
-                        DAO.offlineData.get( 'dataValues', programStageInstanceId ).done( function ( obj ) {
+                        DAO.store.get( 'dataValues', programStageInstanceId ).done( function ( obj ) {
                             if ( !obj ) {
                                 return;
                             }
 
                             obj.executionDate.completed = true;
-                            DAO.offlineData.set('dataValues', obj);
+                            DAO.store.set('dataValues', obj);
                         } );
 
                         var blocked = jQuery('#entryFormContainer [id=blockEntryForm]').val();
@@ -644,14 +644,14 @@
             if ( getProgramType() == 3 ) {
                 var programStageInstanceId = getFieldValue( 'programStageInstanceId' );
 
-                if ( window.DAO && window.DAO.offlineData ) {
-                    DAO.offlineData.get( 'dataValues', programStageInstanceId ).done( function ( obj ) {
+                if ( window.DAO && window.DAO.store ) {
+                    DAO.store.get( 'dataValues', programStageInstanceId ).done( function ( obj ) {
                         if(!obj) {
                             return;
                         }
 
                         obj.executionDate.completed = false;
-                        DAO.offlineData.set( 'dataValues', obj );
+                        DAO.store.set( 'dataValues', obj );
                     } );
                 }
 
@@ -724,7 +724,7 @@
         $( "#programStageInstanceId" ).val( programStageInstanceId );
         $( "#entryFormContainer input[id='programStageInstanceId']" ).val( programStageInstanceId );
 
-        DAO.offlineData.get( 'dataValues', programStageInstanceId ).done( function ( obj ) {
+        DAO.store.get( 'dataValues', programStageInstanceId ).done( function ( obj ) {
             if(obj && obj.values !== undefined ) {
                 _.each( _.keys(obj.values), function(key, idx) {
                     var fieldId = getProgramStageUid() + '-' + key + '-val';
@@ -904,8 +904,8 @@
 }
 
 function searchOptionSet( uid, query, success ) {
-    if(window.DAO !== undefined && window.DAO.metaData !== undefined ) {
-        DAO.metaData.get( 'optionSets', uid ).done( function ( obj ) {
+    if(window.DAO !== undefined && window.DAO.store !== undefined ) {
+        DAO.store.get( 'optionSets', uid ).done( function ( obj ) {
             if(obj) {
                 var options = [];
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.idb.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.idb.js	2013-05-02 13:55:39 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.idb.js	2013-05-03 16:27:51 +0000
@@ -73,24 +73,26 @@
         'open': {
             value: function () {
                 var self = this;
-                var request = window.indexedDB.open( this.name, self.version );
+                var deferred = $.Deferred();
+
+                var request = window.indexedDB.open( self.name, self.version );
 
                 request.onupgradeneeded = function ( e ) {
                     self._db = e.target.result;
 
                     $.each( self.objectStoreNames, function ( idx, item ) {
                         if ( self._db.objectStoreNames.contains( item ) ) {
+                            console.log( 'delete' );
                             self._db.deleteObjectStore( item );
                         }
                     } );
 
                     $.each( self.objectStoreNames, function ( idx, item ) {
+                        console.log( 'create' );
                         self._db.createObjectStore( item );
                     } );
                 };
 
-                var deferred = $.Deferred();
-
                 request.onsuccess = function ( e ) {
                     self._db = e.target.result;
                     deferred.resolveWith( self );
@@ -113,6 +115,7 @@
         'set': {
             value: function ( store, object ) {
                 var self = this;
+                var deferred = $.Deferred();
 
                 if ( typeof self._db === 'undefined' ) {
                     throw new Error( 'Database is not open.' );
@@ -131,8 +134,6 @@
                 var objectStore = tx.objectStore( store );
                 var request = objectStore.put( object, key );
 
-                var deferred = $.Deferred();
-
                 request.onsuccess = function () {
                     deferred.resolveWith( self, [ object ] );
                 };
@@ -154,8 +155,9 @@
         'setAll': {
             value: function ( store, arr ) {
                 var self = this;
-                var deferred = $.Deferred();
-                var chained = deferred.then();
+                var deferred1 = $.Deferred();
+                var deferred2 = $.Deferred();
+                var chained = deferred2.promise();
 
                 $.each( arr, function ( idx, item ) {
                     chained = chained.then( function () {
@@ -163,9 +165,13 @@
                     } );
                 } );
 
-                deferred.resolveWith( this );
-
-                return chained;
+                chained = chained.then( function () {
+                    deferred1.resolveWith( this );
+                } );
+
+                deferred2.resolve();
+
+                return deferred1.promise();
             },
             enumerable: true
         },
@@ -481,6 +487,10 @@
     } );
 
     Object.defineProperties( dhis2.storage.IndexedDBAdapter, {
+        'adapterName': {
+            value: 'IndexedDBAdapter',
+            enumerable: true
+        },
         'isSupported': {
             value: function () {
                 return !!(window.indexedDB && window.IDBTransaction && window.IDBKeyRange);

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.js	2013-05-03 05:18:24 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.js	2013-05-03 16:27:51 +0000
@@ -45,73 +45,109 @@
     }
 
     options.keyPath = options.keyPath || 'id';
-    options.version = options.version || '1';
+    options.version = options.version || 1;
 
     if ( !JSON ) throw 'JSON unavailable! Include http://www.json.org/json2.js to fix.';
 
-    var DefaultAdapter;
+    var objectStores = {};
+    var ObjectStoreAdapters = {};
+    var defaultAdapterName;
 
     for ( var i = 0, len = options.adapters.length; i < len; i++ ) {
         if ( dhis2.storage.Store.verifyAdapter( options.adapters[i] ) && options.adapters[i].isSupported() ) {
-            DefaultAdapter = options.adapters[i];
+            ObjectStoreAdapters[options.adapters[i].adapterName] = options.adapters[i];
+            defaultAdapterName = options.adapters[i].adapterName;
+            objectStores[defaultAdapterName] = [];
             break;
         }
     }
 
-    var ObjectStoreAdapters = {};
-    var objectStores = [];
-
     $.each( options.objectStores, function ( idx, item ) {
         if ( typeof item === 'object' ) {
             if ( typeof item.adapters !== 'undefined' && typeof item.name !== 'undefined' ) {
                 for ( var i = 0, len = item.adapters.length; i < len; i++ ) {
                     if ( dhis2.storage.Store.verifyAdapter( item.adapters[i] ) && item.adapters[i].isSupported() ) {
-                        ObjectStoreAdapters[item.name] = item.adapters[i];
-                        objectStores.push( item.name );
+                        ObjectStoreAdapters[item.adapters[i].adapterName] = item.adapters[i];
+
+                        if ( defaultAdapterName === item.adapters[i].adapterName ) {
+                            objectStores[defaultAdapterName].push( item.name );
+                        } else {
+                            if ( typeof objectStores[item.adapters[i].adapterName] === 'undefined' ) {
+                                objectStores[item.adapters[i].adapterName] = [];
+                            }
+
+                            objectStores[item.adapters[i].adapterName].push( item.name );
+                        }
                         break;
                     }
                 }
             }
-        } else if ( typeof item === 'string' ) {
-            objectStores.push( item );
+        } else {
+            objectStores[defaultAdapterName].push( item );
         }
     } );
 
-    options.objectStores = objectStores;
-
-    if ( !DefaultAdapter && Object.keys( ObjectStoreAdapters ).length == 0 ) throw 'No valid adapter.';
-
-    var defaultAdapter = new DefaultAdapter( options );
+    if ( Object.keys( ObjectStoreAdapters ).length == 0 ) throw 'Could not find a valid adapter.';
+
     var objectStoreAdapters = {};
 
+    // simple map from objectStoreName => adapter
+    var objectStoreCache = {};
+
     $.each( Object.keys( ObjectStoreAdapters ), function ( idx, item ) {
+        options.objectStores = objectStores[item];
+
         objectStoreAdapters[item] = new ObjectStoreAdapters[item]( options );
-    } );
 
-    Object.defineProperty( self, 'defaultAdapter', {
-        value: defaultAdapter
+        $.each( options.objectStores, function ( idx, objectStore ) {
+            objectStoreCache[objectStore] = objectStoreAdapters[item];
+        } );
     } );
 
     Object.defineProperty( self, 'objectStoreAdapters', {
-        value: objectStoreAdapters
+        value: objectStoreAdapters,
+        enumerable: true
     } );
 
     var adapterMethods = "open set setAll get getAll getKeys count contains clear close delete destroy".split( ' ' );
 
     $.each( adapterMethods, function ( idx, item ) {
-        console.log( 'adding method: ' + item );
-
-        Object.defineProperty(self, item, {
-            value: function() {
-                console.log( 'calling ' + item + " with args: ", arguments );
-                return self.defaultAdapter[item].apply( self.defaultAdapter, arguments );
-            }
-        });
+        Object.defineProperty( self, item, {
+            value: function () {
+                // if arguments is empty, apply to all objectStore adapters also
+                if ( arguments.length == 0 ) {
+                    // TODO add deferred chain
+
+                    var deferred1 = $.Deferred();
+                    var deferred2 = $.Deferred();
+                    var promise = deferred2.promise();
+
+                    $.each( self.objectStoreAdapters, function ( idx, adapter ) {
+                        promise = promise.then( function () {
+                            return adapter[item].apply( adapter, arguments );
+                        } );
+                    } );
+
+                    promise = promise.then( function () {
+                        deferred1.resolveWith( self );
+                    } );
+
+                    deferred2.resolve();
+
+                    return deferred1.promise();
+                } else if ( typeof arguments[0] === 'string' && typeof objectStoreCache[arguments[0]] !== 'undefined' ) {
+                    var adapter = objectStoreCache[arguments[0]];
+                    return adapter[item].apply( adapter, arguments );
+                }
+
+                return self.objectStoreAdapters[defaultAdapterName][item].apply( self.objectStoreAdapters[defaultAdapterName], arguments );
+            },
+            enumerable: true
+        } );
     } );
 };
 
 dhis2.storage.Store.adapterMethods = "open set setAll get getAll getKeys count contains clear close delete destroy".split( ' ' );
-dhis2.storage.Store.adapterProperties = "name version objectStoreNames keyPath".split( ' ' );
 
 dhis2.storage.Store.verifyAdapter = function ( Adapter ) {
     var failed = [];

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.ls.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.ls.js	2013-05-02 13:55:39 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.ls.js	2013-05-03 16:27:51 +0000
@@ -56,8 +56,6 @@
             }
         } );
 
-        this.customApi = 'Indexer storage'.split( ' ' );
-
         this.Indexer = function ( name, objectStore, storage ) {
             return {
                 key: name + '.' + objectStore + '.**index**',
@@ -328,6 +326,10 @@
     } );
 
     Object.defineProperties( dhis2.storage.DomLocalStorageAdapter, {
+        'adapterName': {
+            value: 'DomLocalStorageAdapter',
+            enumerable: true
+        },
         'isSupported': {
             value: function () {
                 return !!window.localStorage;

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js	2013-05-02 13:55:39 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js	2013-05-03 16:27:51 +0000
@@ -56,8 +56,6 @@
             }
         } );
 
-        this.customApi = 'Indexer storage'.split( ' ' );
-
         this.Indexer = function ( name, objectStore, storage ) {
             return {
                 key: name + '.' + objectStore + '.**index**',
@@ -328,6 +326,10 @@
     } );
 
     Object.defineProperties( dhis2.storage.InMemoryAdapter, {
+        'adapterName': {
+            value: 'InMemoryAdapter',
+            enumerable: true
+        },
         'isSupported': {
             value: function () {
                 return true;

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.ss.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.ss.js	2013-05-02 13:55:39 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.ss.js	2013-05-03 16:27:51 +0000
@@ -328,6 +328,10 @@
     } );
 
     Object.defineProperties( dhis2.storage.DomSessionStorageAdapter, {
+        'adapterName': {
+            value: 'DomSessionStorageAdapter',
+            enumerable: true
+        },
         'isSupported': {
             value: function () {
                 return !!window.sessionStorage;