OpenLayers OpenLayers

Changeset 7103

Show
Ignore:
Timestamp:
05/08/08 10:27:29 (3 months ago)
Author:
fredj
Message:

save feature state into the database

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/camptocamp/unhcr/lib/OpenLayers/Protocol/SQL/GoogleGears.js

    r7096 r7103  
    3535        this.db.open(this.databaseName); 
    3636        this.db.execute("CREATE TABLE IF NOT EXISTS " + this.tableName + 
    37                         " (fid TEXT UNIQUE, geometry TEXT, properties TEXT)"); 
     37                        " (fid TEXT UNIQUE, geometry TEXT, properties TEXT," + 
     38                        "  state TEXT)"); 
    3839 
    3940        this.db.execute("CREATE INDEX IF NOT EXISTS fid_idx ON " +  
     
    7576        return [feature.fid, 
    7677                feature.geometry.toString(), 
    77                 this.jsonFormat.write(feature.attributes)]; 
     78                this.jsonFormat.write(feature.attributes), 
     79                feature.state]; 
    7880    }, 
    7981 
     
    9193        feature.attributes = this.jsonFormat.read(row.fieldByName('properties')); 
    9294        feature.fid = row.fieldByName('fid'); 
     95        feature.state = row.fieldByName('state'); 
    9396 
    9497        return feature; 
     
    135138        for (var i = 0; i < toCreate.length; i++) { 
    136139            var feature = toCreate[i]; 
    137             this.db.execute("REPLACE INTO " + this.tableName + " (fid, geometry, properties) VALUES (?, ?, ?)", 
     140            this.db.execute("REPLACE INTO " + this.tableName +  
     141                            " (fid, geometry, properties, state) " +  
     142                            "VALUES (?, ?, ?, ?)", 
    138143                            this.freezeFeature(feature)); 
    139144            createdFeatures.push(feature.clone()); 
     
    168173        for (var i = 0; i < toUpdate.length; i++) { 
    169174            var feature = toUpdate[i]; 
    170             this.db.execute("REPLACE INTO " + this.tableName + " (fid, geometry, properties) VALUES (?, ?, ?)", 
     175            this.db.execute("REPLACE INTO " + this.tableName +  
     176                            " (fid, geometry, properties, state) " +  
     177                            "VALUES (?, ?, ?, ?)", 
    171178                            this.freezeFeature(feature)); 
    172179            updatedFeatures.push(feature.clone());