minor doc adjustments and a bit more test coverage
This commit is contained in:
@@ -9,10 +9,7 @@
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Protocol.CSW
|
||||
* Used to create a versioned CSW protocol. Default version is 2.0.2.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Protocol>
|
||||
* Used to create a versioned CSW protocol. Default version is 2.0.2.
|
||||
*/
|
||||
OpenLayers.Protocol.CSW = function(options) {
|
||||
options = OpenLayers.Util.applyDefaults(
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Protocol/CSW.js
|
||||
* @requires OpenLayers/Format/CSWGetRecords/v2_0_2.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Protocol.CSW.v2_0_2
|
||||
* Abstract class for for v2_0_2 protocol.
|
||||
* CS-W (Catalogue services for the Web) version 2.0.2 protocol.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Protocol>
|
||||
@@ -24,8 +25,8 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
formatOptions: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Protocol.CSW
|
||||
* A class for CSW protocol management.
|
||||
* Constructor: OpenLayers.Protocol.CSW.v2_0_2
|
||||
* A class for CSW version 2.0.2 protocol management.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} Optional object whose properties will be set on the
|
||||
@@ -34,7 +35,6 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
initialize: function(options) {
|
||||
OpenLayers.Protocol.prototype.initialize.apply(this, [options]);
|
||||
if(!options.format) {
|
||||
/* not tested */
|
||||
this.format = new OpenLayers.Format.CSWGetRecords.v2_0_2(OpenLayers.Util.extend({
|
||||
}, this.formatOptions));
|
||||
}
|
||||
@@ -71,11 +71,7 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
|
||||
/**
|
||||
* Method: read
|
||||
* Construct a request for reading new features. Since WFS splits the
|
||||
* basic CRUD operations into GetFeature requests (for read) and
|
||||
* Transactions (for all others), this method does not make use of the
|
||||
* format's read method (that is only about reading transaction
|
||||
* responses).
|
||||
* Construct a request for reading new records from the Catalogue.
|
||||
*/
|
||||
read: function(options) {
|
||||
options = OpenLayers.Util.extend({}, options);
|
||||
@@ -102,7 +98,7 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
* Parameters:
|
||||
* response - {<OpenLayers.Protocol.Response>} The response object to pass
|
||||
* to the user callback.
|
||||
* This response is given a code property, and optionally a records one.
|
||||
* This response is given a code property, and optionally a data property.
|
||||
* The latter represents the CSW records as returned by the call to
|
||||
* the CSW format read method.
|
||||
* options - {Object} The user options passed to the read call.
|
||||
@@ -118,7 +114,6 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
// failure
|
||||
response.code = OpenLayers.Protocol.Response.FAILURE;
|
||||
}
|
||||
|
||||
options.callback.call(options.scope, response);
|
||||
}
|
||||
},
|
||||
@@ -141,7 +136,6 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
if(!doc || doc.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.format.read(doc);
|
||||
},
|
||||
|
||||
|
||||
@@ -4,11 +4,15 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_initialize(t) {
|
||||
t.plan(1);
|
||||
t.plan(3);
|
||||
|
||||
var protocol = new OpenLayers.Protocol.CSW({});
|
||||
var protocol = new OpenLayers.Protocol.CSW({formatOptions: {foo: "bar"},});
|
||||
t.ok(protocol instanceof OpenLayers.Protocol.CSW.v2_0_2,
|
||||
"initialize returns instance of default versioned protocol");
|
||||
var format = protocol.format;
|
||||
t.ok(format instanceof OpenLayers.Format.CSWGetRecords.v2_0_2, "Default format created");
|
||||
t.ok(format.foo, "bar", "formatOptions set correctly");
|
||||
protocol.destroy();
|
||||
}
|
||||
|
||||
function test_read(t) {
|
||||
|
||||
Reference in New Issue
Block a user