diff options
Diffstat (limited to 'bandwagon/content/scripts/factory/collectionFactory.js')
-rw-r--r-- | bandwagon/content/scripts/factory/collectionFactory.js | 86 |
1 files changed, 10 insertions, 76 deletions
diff --git a/bandwagon/content/scripts/factory/collectionFactory.js b/bandwagon/content/scripts/factory/collectionFactory.js index 0c32dc4..6adfee8 100644 --- a/bandwagon/content/scripts/factory/collectionFactory.js +++ b/bandwagon/content/scripts/factory/collectionFactory.js @@ -38,8 +38,6 @@ Bandwagon.Factory.CollectionFactory = function(connection) { this.Bandwagon = Bandwagon; this.connection = connection; - - this.connection.executeSimpleSQL("PRAGMA locking_mode = EXCLUSIVE"); } Bandwagon.Factory.CollectionFactory.prototype.openServiceDocument = function() @@ -53,6 +51,8 @@ Bandwagon.Factory.CollectionFactory.prototype.openServiceDocument = function() try { + statement.execute(); + while (statement.executeStep()) { serviceDocument = new this.Bandwagon.Model.ServiceDocument(); @@ -71,9 +71,7 @@ Bandwagon.Factory.CollectionFactory.prototype.openServiceDocument = function() Bandwagon.Factory.CollectionFactory.prototype.commitServiceDocument = function(serviceDocument) { if (!this.connection) - return; - - this.connection.beginTransaction(); + return null; var statement1 = this.connection.createStatement("DELETE FROM serviceDocument"); @@ -81,11 +79,6 @@ Bandwagon.Factory.CollectionFactory.prototype.commitServiceDocument = function(s { statement1.execute(); } - catch (e) - { - this.connection.rollbackTransaction(); - throw e; - } finally { statement1.reset(); @@ -99,17 +92,10 @@ Bandwagon.Factory.CollectionFactory.prototype.commitServiceDocument = function(s statement2.bindUTF8StringParameter(1, serviceDocument.collectionListResourceURL); statement2.execute(); } - catch (e) - { - this.connection.rollbackTransaction(); - throw e; - } finally { statement2.reset(); } - - this.connection.commitTransaction(); } Bandwagon.Factory.CollectionFactory.prototype.newCollection = function() @@ -186,8 +172,6 @@ Bandwagon.Factory.CollectionFactory.prototype.commitCollection = function(collec if (!this.connection) return; - this.connection.beginTransaction(); - var statement = this.connection.createStatement("REPLACE INTO collections VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18)"); try @@ -213,11 +197,6 @@ Bandwagon.Factory.CollectionFactory.prototype.commitCollection = function(collec statement.execute(); } - catch (e) - { - this.connection.rollbackTransaction(); - throw e; - } finally { statement.reset(); @@ -228,34 +207,9 @@ Bandwagon.Factory.CollectionFactory.prototype.commitCollection = function(collec collection.storageID = this.connection.lastInsertRowID; } - var statement3 = this.connection.createStatement("DELETE FROM collectionsAddons where collection = ?1"); - - try - { - statement3.bindInt32Parameter(0, collection.storageID); - statement3.execute(); - } - catch (e) - { - this.connection.rollbackTransaction(); - throw e; - } - finally - { - statement3.reset(); - } - for (var id in collection.addons) { - try - { - this._commitAddon(collection, collection.addons[id]); - } - catch (e) - { - this.connection.rollbackTransaction(); - throw e; - } + this._commitAddon(collection, collection.addons[id]); } var statement2 = this.connection.createStatement("DELETE FROM collectionsLinks WHERE collection = ?1"); @@ -265,11 +219,6 @@ Bandwagon.Factory.CollectionFactory.prototype.commitCollection = function(collec statement2.bindInt32Parameter(0, collection.storageID); statement2.execute(); } - catch (e) - { - this.connection.rollbackTransaction(); - throw e; - } finally { statement2.reset(); @@ -277,19 +226,9 @@ Bandwagon.Factory.CollectionFactory.prototype.commitCollection = function(collec for (var id in collection.links) { - try - { - this._commitCollectionLink(collection, id); - } - catch (e) - { - this.connection.rollbackTransaction(); - throw e; - } + this._commitCollectionLink(collection, id); } - this.connection.commitTransaction(); - return true; } @@ -304,34 +243,27 @@ Bandwagon.Factory.CollectionFactory.prototype.commitCollections = function(colle Bandwagon.Factory.CollectionFactory.prototype.deleteCollection = function(collection) { if (!this.connection) - return; - - this.connection.beginTransaction(); + return null; var statement1 = this.connection.createStatement("DELETE FROM collections where id = ?1"); var statement2 = this.connection.createStatement("DELETE FROM collectionsAddons where collection = ?1"); try { + // TODO transaction here? + statement1.bindInt32Parameter(0, collection.storageID); statement1.execute(); statement2.bindInt32Parameter(0, collection.storageID); statement2.execute(); } - catch (e) - { - this.connection.rollbackTransaction(); - throw e; - } finally { statement1.reset(); statement2.reset(); } - this.connection.commitTransaction(); - return (statement2.lastError>0?false:true); } @@ -602,6 +534,8 @@ Bandwagon.Factory.CollectionFactory.prototype._commitCollectionLink = function(c { statement.reset(); } + + } Bandwagon.Factory.CollectionFactory.prototype._commitAddon = function(collection, addon) |