[Commits] r1304 - in sandbox/camptocamp/geobretagne: lib lib/GeoExt/data tests tests/lib/GeoExt/data

commits at geoext.org commits at geoext.org
Wed Aug 5 13:43:20 CEST 2009


Author: elemoine
Date: 2009-08-05 13:43:20 +0200 (Wed, 05 Aug 2009)
New Revision: 1304

Removed:
   sandbox/camptocamp/geobretagne/lib/GeoExt/data/AttributesReader.js
   sandbox/camptocamp/geobretagne/lib/GeoExt/data/AttributesStore.js
   sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/AttributesReader.html
Modified:
   sandbox/camptocamp/geobretagne/lib/GeoExt.js
   sandbox/camptocamp/geobretagne/tests/list-tests.html
Log:
AttributesStore and AttributesReader are replaced by AttributeStore and AttributeReader


Deleted: sandbox/camptocamp/geobretagne/lib/GeoExt/data/AttributesReader.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/AttributesReader.js	2009-08-05 11:24:10 UTC (rev 1303)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/AttributesReader.js	2009-08-05 11:43:20 UTC (rev 1304)
@@ -1,135 +0,0 @@
-/**
- * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
- * 
- * Published under the BSD license.
- * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
- * of the license.
- */
-
-/** api: (define)
- *  module = GeoExt.data
- *  class = AttributesReader
- *  base_link = `Ext.data.DataReader <http://extjs.com/deploy/dev/docs/?class=Ext.data.DataReader>`_
- */
-Ext.namespace("GeoExt.data");
-
-/**
- * Class: GeoExt.data.AttributesReader
- * Data reader class to provide an array of {Ext.data.Record} objects given
- *     a WFS DescribeFeatureType response for use by an {Ext.data.Store}
- *     object.
- *
- * Extends: Ext.data.DataReader
- */
-
-/**
- * Constructor: GeoExt.data.AttributesReader
- * Create a new attributes reader object.
- *
- * Parameters:
- * meta - {Object} Reader configuration.
- * recordType - {Array | Ext.data.Record} An array of field configuration
- *     objects or a record object.
- *
- * Configuration options (meta properties):
- * format - {OpenLayers.Format} A parser for transforming the XHR response
- *     into an array of objects representing attributes.  Defaults to
- *     an {OpenLayers.Format.WFSDescribeFeatureType} parser.
- * ignore - {Object} Properties of the ignore object should be field names.
- *     Values are either arrays or regular expressions.
- */
-GeoExt.data.AttributesReader = function(meta, recordType) {
-    meta = meta || {};
-    if(!meta.format) {
-        meta.format = new OpenLayers.Format.WFSDescribeFeatureType();
-    }
-    GeoExt.data.AttributesReader.superclass.constructor.call(
-        this, meta, recordType || meta.fields
-    );
-};
-
-Ext.extend(GeoExt.data.AttributesReader, Ext.data.DataReader, {
-
-    /**
-     * Method: read
-     * This method is only used by a DataProxy which has retrieved data from a
-     *     remote server.
-     *
-     * Parameters:
-     * request - {Object} The XHR object which contains the parsed XML
-     *     document.
-     * 
-     * Returns:
-     * {Object} A data block which is used by an {Ext.data.Store} as a cache
-     *     of Ext.data.Records.
-     */
-    read: function(request) {
-        var data = request.responseXML;
-        if(!data || !data.documentElement) {
-            data = request.responseText;
-        }
-        return this.readRecords(data);
-    },
-    
-    /**
-     * Method: readRecords
-     * Create a data block containing Ext.data.Records from an XML document.
-     *
-     * Parameters:
-     * data - {DOMElement | String | Array} A document element or XHR response
-     *     string.  As an alternative to fetching attributes data from a remote
-     *     source, an array of attribute objects can be provided given that
-     *     the properties of each attribute object map to a provided field name.
-     *
-     * Returns:
-     * {Object} A data block which is used by an {Ext.data.Store} as a cache of
-     *     Ext.data.Records.
-     */
-    readRecords: function(data) {
-        var attributes;
-        if(data instanceof Array) {
-            attributes = data;
-        } else {
-            // only works with one featureType in the doc
-            attributes = this.meta.format.read(data).featureTypes[0].properties;
-        }
-    	var recordType = this.recordType;
-        var fields = recordType.prototype.fields;
-        var numFields = fields.length;
-        var attr, values, name, record, ignore, matches, value, records = [];
-        for(var i=0, len=attributes.length; i<len; ++i) {
-            ignore = false;
-            attr = attributes[i];
-            values = {};
-            for(var j=0; j<numFields; ++j) {
-                name = fields.items[j].name;
-                value = attr[name];
-                if(this.meta.ignore && this.meta.ignore[name]) {
-                    matches = this.meta.ignore[name];
-                    if(typeof matches == "string") {
-                        ignore = (matches === value);
-                    } else if(matches instanceof Array) {
-                        ignore = (matches.indexOf(value) > -1);
-                    } else if (matches instanceof RegExp) {
-                        ignore = (matches.test(value));
-                    }
-                    if(ignore) {
-                        break;
-                    }
-                }
-                values[name] = attr[name];
-            }
-            if(!ignore) {
-                records[records.length] = new recordType(values);
-            }
-        }
-        
-        return {
-            success: true,
-            records: records,
-            totalRecords: records.length
-        };
-        
-    }
-
-});

Deleted: sandbox/camptocamp/geobretagne/lib/GeoExt/data/AttributesStore.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/AttributesStore.js	2009-08-05 11:24:10 UTC (rev 1303)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/AttributesStore.js	2009-08-05 11:43:20 UTC (rev 1304)
@@ -1,62 +0,0 @@
-/**
- * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
- * 
- * Published under the BSD license.
- * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
- * of the license.
- */
-
-/**
- * @include GeoExt/data/AttributesReader.js
- */
-
-/** api: (define)
- *  module = GeoExt.data
- *  class = WMSCapabilitiesStore
- *  base_link = `Ext.data.DataStore <http://extjs.com/deploy/dev/docs/?class=Ext.data.DataStore>`_
- */
-Ext.namespace("GeoExt.data");
-
-/**
- * Class: GeoExt.data.AttributesStore
- * Small helper class to make creating stores for remotely-loaded attributes
- *     data easier. AttributesStore is pre-configured with a built-in
- *     {Ext.data.HttpProxy} and {GeoExt.data.AttributesReader}.  The HttpProxy
- *     is configured to allow caching (disableCaching: false) and uses GET.
- *     If you require some other proxy/reader combination then you'll have to
- *     configure this with your own proxy or create a basic Ext.data.Store
- *     and configure as needed.
- *
- * Extends: Ext.data.Store
- */
-
-/**
- * Constructor: GeoExt.data.AttributesStore
- * Create a new attributes store object.
- *
- * Parameters:
- * config - {Object} Store configuration.
- *
- * Configuration options:
- * format - {OpenLayers.Format} A parser for transforming the XHR response into
- *     an array of objects representing attributes.  Defaults to an
- *     {OpenLayers.Format.WFSDescribeFeatureType} parser.
- * fields - {Array | Function} Either an Array of field definition objects as
- *     passed to Ext.data.Record.create, or a Record constructor created using
- *     Ext.data.Record.create.  Defaults to ["name", "type"]. 
- */
-GeoExt.data.AttributesStore = function(c) {
-    GeoExt.data.AttributesStore.superclass.constructor.call(
-        this,
-        Ext.apply(c, {
-            proxy: c.proxy || (!c.data ?
-                new Ext.data.HttpProxy({url: c.url, disableCaching: false, method: "GET"}) :
-                undefined
-            ),
-            reader: new GeoExt.data.AttributesReader(
-                c, c.fields || ["name", "type"]
-            )
-        })
-    );
-};
-Ext.extend(GeoExt.data.AttributesStore, Ext.data.Store);
\ No newline at end of file

Modified: sandbox/camptocamp/geobretagne/lib/GeoExt.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt.js	2009-08-05 11:24:10 UTC (rev 1303)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt.js	2009-08-05 11:43:20 UTC (rev 1304)
@@ -64,8 +64,6 @@
      */
     if(!singleFile) {
         var jsfiles = new Array(
-            "GeoExt/data/AttributesReader.js",
-            "GeoExt/data/AttributesStore.js",
             "GeoExt/data/AttributeReader.js",
             "GeoExt/data/AttributeStore.js",
             "GeoExt/data/FeatureRecord.js",

Deleted: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/AttributesReader.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/AttributesReader.html	2009-08-05 11:24:10 UTC (rev 1303)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/AttributesReader.html	2009-08-05 11:43:20 UTC (rev 1304)
@@ -1,89 +0,0 @@
-<!DOCTYPE html>
-<html debug="true">
-  <head>
-    <script type="text/javascript" src="../../../../../ext/adapter/ext/ext-base.js"></script>
-    <script type="text/javascript" src="../../../../../ext/ext-all-debug.js"></script>
-
-    <script type="text/javascript" src="../../../../../openlayers/lib/OpenLayers.js"></script>
-    <script type="text/javascript" src="../../../../lib/GeoExt.js"></script>
-    <script type="text/javascript" src="AttributesReader.js"></script>
-
-    <script type="text/javascript">
-    
-    function test_read(t) {
-        t.plan(3);
-
-        var reader = new GeoExt.data.AttributesReader({}, [
-            "name",
-            "type"                                                   
-        ]);
-
-        var records = reader.read({responseXML : doc});
-
-        //1 test
-        t.eq(records.totalRecords, 23, 'readRecords returns correct number of records');
-
-        var record = records.records[2];
-
-        //2 tests -- testing the fields of a record
-        t.eq(record.get("name"), "STATE_FIPS", "[2] correct attribute name");
-        t.eq(record.get("type"), "xsd:string", "[2] correct attribute type name");
-       
-    }
-
-    function test_ignoreString(t) {
-   	    t.plan(1);
-
-   	    var reader = new GeoExt.data.AttributesReader({
-       	     ignore: {type: "xsd:string"}
-       	     }, [
-                "name",
-                "type"      
-             ]                                             
-        );
-
-   	    var records = reader.read({responseXML : doc});
-
-   	    //1 test
-        t.eq(records.totalRecords, 19, 'right number of records are ignored (ignores String)');
-    }
-
-    function test_ignoreArray(t) {
-    	 t.plan(1);
-
-    	 var reader = new GeoExt.data.AttributesReader({
-        	     ignore: {type: ["xsd:double", "gml:MultiSurfacePropertyType"]}
-        	 }, [
-                 "name",
-                 "type"      
-             ]                                             
-         );
-
-    	 var records = reader.read({responseXML : doc});
-
-    	 //1 test
-         t.eq(records.totalRecords, 4, 'right number of records are ignored (ignores Array)');
-    }
-
-    function test_ignoreRegexp(t) {
-   	    t.plan(1);
-
-   	    var reader = new GeoExt.data.AttributesReader({
-       	     ignore: {name: new RegExp('^S')}
-       	     }, [
-                "name",
-                "type"      
-             ]                                             
-        );
-
-   	    var records = reader.read({responseXML : doc});
-
-   	    //1 test
-        t.eq(records.totalRecords, 17, 'right number of records are ignored (ignores RegExp)');
-   	}
-    
-    </script>
-  <body>
-    <div id="map"></div>
-  </body>
-</html>

Modified: sandbox/camptocamp/geobretagne/tests/list-tests.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/list-tests.html	2009-08-05 11:24:10 UTC (rev 1303)
+++ sandbox/camptocamp/geobretagne/tests/list-tests.html	2009-08-05 11:43:20 UTC (rev 1304)
@@ -12,7 +12,6 @@
   <li>lib/GeoExt/data/WMSCapabilitiesReader.html</li>
   <li>lib/GeoExt/data/WMSDescribeLayerReader.html</li>
   <li>lib/GeoExt/data/CSWRecordsReader.html</li>
-  <li>lib/GeoExt/data/AttributesReader.html</li>
   <li>lib/GeoExt/widgets/Action.html</li>
   <li>lib/GeoExt/widgets/LayerOpacitySlider.html</li>
   <li>lib/GeoExt/widgets/MapPanel.html</li>



More information about the Commits mailing list