/**
 *  Copyright (c) 2015, CoNWeT Lab., Universidad Politécnica de Madrid
 *  Code licensed under BSD 3-Clause (https://github.com/conwetlab/WMarket/blob/master/LICENSE)
 */


var StoreManager = (function () {

    "use strict";

    var StoreManager = function StoreManager() {
        this.storeList = {};
    };

    StoreManager.prototype.addStore = function addStore(data) {
        var store;

        store = new Store(data);
        this.storeList[store.name] = store;

        return store;
    };

    StoreManager.prototype.getStoreByName = function getStoreByName(name) {
        var store, storeException;

        if (!(store=this.storeList[name])) {
            storeException = new Exception("The store '%(name)s' is not saved.".replace("%(name)s", name));
            storeException.name = "Store Not Found";

            throw storeException;
        }

        return store;
    };

    if (WMarket && WMarket.resources) {
        WMarket.resources.stores = new StoreManager();
    }

    return StoreManager;

})();

/**
 *  Copyright (c) 2015, CoNWeT Lab., Universidad Politécnica de Madrid
 *  Code licensed under BSD 3-Clause (https://github.com/conwetlab/WMarket/blob/master/LICENSE)
 */


var StoreManager = (function () {

	"use strict";

    var StoreManager = function StoreManager() {
        this.storeList = [];
    };

    StoreManager.prototype.addStore = function addStore(data) {
        var newStore;

        newStore = new Store(data);
        this.storeList.push(newStore);

        return newStore;
    };

    StoreManager.prototype.getStoreByName = function getStoreByName(name) {
        var found, i, storeFound;

        for (found = false, i = 0; !found && i < this.storeList.length; i++) {
            if (this.storeList[i].name == name) {
                found = true;
                storeFound = this.storeList[i];
            }
        }

        return storeFound;
    };

    if (typeof WMarket !== 'undefined' && 'resources' in WMarket) {
        WMarket.resources.stores = new StoreManager();
    }

    return StoreManager;

})();

--- 
+++ 
@@ -6,35 +6,35 @@
 
 var StoreManager = (function () {
 
-    "use strict";
+	"use strict";
 
     var StoreManager = function StoreManager() {
-        this.storeList = {};
+        this.storeList = [];
     };
 
     StoreManager.prototype.addStore = function addStore(data) {
-        var store;
+        var newStore;
 
-        store = new Store(data);
-        this.storeList[store.name] = store;
+        newStore = new Store(data);
+        this.storeList.push(newStore);
 
-        return store;
+        return newStore;
     };
 
     StoreManager.prototype.getStoreByName = function getStoreByName(name) {
-        var store, storeException;
+        var found, i, storeFound;
 
-        if (!(store=this.storeList[name])) {
-            storeException = new Exception("The store '%(name)s' is not saved.".replace("%(name)s", name));
-            storeException.name = "Store Not Found";
-
-            throw storeException;
+        for (found = false, i = 0; !found && i < this.storeList.length; i++) {
+            if (this.storeList[i].name == name) {
+                found = true;
+                storeFound = this.storeList[i];
+            }
         }
 
-        return store;
+        return storeFound;
     };
 
-    if (WMarket && WMarket.resources) {
+    if (typeof WMarket !== 'undefined' && 'resources' in WMarket) {
         WMarket.resources.stores = new StoreManager();
     }
 
Change the way to find a store saved

Signed-off-by: Aitor Magán <a93a7d273b830b2e8a26461c1a80328a1d7ad27a@conwet.com>
