]> dev.renevier.net Git - syp.git/blob - openlayers/lib/OpenLayers/Format/WFST/v1_0_0.js
fixes notices
[syp.git] / openlayers / lib / OpenLayers / Format / WFST / v1_0_0.js
1 /**
2  * @requires OpenLayers/Format/WFST/v1.js
3  * @requires OpenLayers/Format/Filter/v1_0_0.js
4  */
5
6 /**
7  * Class: OpenLayers.Format.WFST.v1_0_0
8  * A format for creating WFS v1.0.0 transactions.  Create a new instance with the
9  *     <OpenLayers.Format.WFST.v1_0_0> constructor.
10  *
11  * Inherits from:
12  *  - <OpenLayers.Format.Filter.v1_0_0>
13  *  - <OpenLayers.Format.WFST.v1>
14  */
15 OpenLayers.Format.WFST.v1_0_0 = OpenLayers.Class(
16     OpenLayers.Format.Filter.v1_0_0, OpenLayers.Format.WFST.v1, {
17     
18     /**
19      * Property: version
20      * {String} WFS version number.
21      */
22     version: "1.0.0",
23     
24     /**
25      * Property: schemaLocations
26      * {Object} Properties are namespace aliases, values are schema locations.
27      */
28     schemaLocations: {
29         "wfs": "http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd"
30     },
31
32     /**
33      * Constructor: OpenLayers.Format.WFST.v1_0_0
34      * A class for parsing and generating WFS v1.0.0 transactions.
35      *
36      * Parameters:
37      * options - {Object} Optional object whose properties will be set on the
38      *     instance.
39      *
40      * Valid options properties:
41      * featureType - {String} Local (without prefix) feature typeName (required).
42      * featureNS - {String} Feature namespace (optional).
43      * featurePrefix - {String} Feature namespace alias (optional - only used
44      *     if featureNS is provided).  Default is 'feature'.
45      * geometryName - {String} Name of geometry attribute.  Default is 'the_geom'.
46      */
47     initialize: function(options) {
48         OpenLayers.Format.Filter.v1_0_0.prototype.initialize.apply(this, [options]);
49         OpenLayers.Format.WFST.v1.prototype.initialize.apply(this, [options]);
50     },
51     
52     /**
53      * Property: readers
54      * Contains public functions, grouped by namespace prefix, that will
55      *     be applied when a namespaced node is found matching the function
56      *     name.  The function will be applied in the scope of this parser
57      *     with two arguments: the node being read and a context object passed
58      *     from the parent.
59      */
60     readers: {
61         "wfs": OpenLayers.Util.applyDefaults({
62             "WFS_TransactionResponse": function(node, obj) {
63                 obj.insertIds = [];
64                 obj.success = false;
65                 this.readChildNodes(node, obj);
66             },
67             "InsertResult": function(node, container) {
68                 var obj = {fids: []};
69                 this.readChildNodes(node, obj);
70                 container.insertIds.push(obj.fids[0]);
71             },
72             "TransactionResult": function(node, obj) {
73                 this.readChildNodes(node, obj);
74             },
75             "Status": function(node, obj) {
76                 this.readChildNodes(node, obj);
77             },
78             "SUCCESS": function(node, obj) {
79                 obj.success = true;
80             }
81         }, OpenLayers.Format.WFST.v1.prototype.readers["wfs"]),
82         "gml": OpenLayers.Format.GML.v2.prototype.readers["gml"],
83         "feature": OpenLayers.Format.GML.v2.prototype.readers["feature"],
84         "ogc": OpenLayers.Format.Filter.v1_0_0.prototype.readers["ogc"]
85     },
86
87     /**
88      * Property: writers
89      * As a compliment to the readers property, this structure contains public
90      *     writing functions grouped by namespace alias and named like the
91      *     node names they produce.
92      */
93     writers: {
94         "wfs": OpenLayers.Util.applyDefaults({
95             "Query": function(options) {
96                 options = OpenLayers.Util.extend({
97                     featureNS: this.featureNS,
98                     featurePrefix: this.featurePrefix,
99                     featureType: this.featureType,
100                     srsName: this.srsName
101                 }, options);
102                 var node = this.createElementNSPlus("wfs:Query", {
103                     attributes: {
104                         typeName: (options.featureNS ? options.featurePrefix + ":" : "") +
105                             options.featureType
106                     }
107                 });
108                 if(options.featureNS) {
109                     node.setAttribute("xmlns:" + options.featurePrefix, options.featureNS);
110                 }
111                 if(options.propertyNames) {
112                     for(var i=0,len = options.propertyNames.length; i<len; i++) {
113                         this.writeNode(
114                             "ogc:PropertyName", 
115                             {property: options.propertyNames[i]},
116                             node
117                         );
118                     }
119                 }
120                 if(options.filter) {
121                     this.setFilterProperty(options.filter);
122                     this.writeNode("ogc:Filter", options.filter, node);
123                 }
124                 return node;
125             }
126         }, OpenLayers.Format.WFST.v1.prototype.writers["wfs"]),
127         "gml": OpenLayers.Format.GML.v2.prototype.writers["gml"],
128         "feature": OpenLayers.Format.GML.v2.prototype.writers["feature"],
129         "ogc": OpenLayers.Format.Filter.v1_0_0.prototype.writers["ogc"]
130     },
131    
132     CLASS_NAME: "OpenLayers.Format.WFST.v1_0_0" 
133 });