|
@@ -27,7 +27,7 @@ function p5WFS_ParseFeatureMember(featureMember) { // @returns object from xml e
|
|
|
// ...
|
|
// ...
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- * @usage
|
|
|
|
|
|
|
+ * @usage - expected one feature
|
|
|
|
|
|
|
|
p5WFS_GetFeature('p5_default_db:CRM_PROCES', {
|
|
p5WFS_GetFeature('p5_default_db:CRM_PROCES', {
|
|
|
'featureID': 'CRM_PROCES.' + id,
|
|
'featureID': 'CRM_PROCES.' + id,
|
|
@@ -43,8 +43,28 @@ function p5WFS_ParseFeatureMember(featureMember) { // @returns object from xml e
|
|
|
// ...
|
|
// ...
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ * @usage - POST
|
|
|
|
|
+
|
|
|
|
|
+ p5WFS_GetFeature('p5_default_db:CRM_PROCES', {
|
|
|
|
|
+ // 'Filter': '<ogc:PropertyIsEqualTo><ogc:PropertyName>' + "PARENT_ID" + '</ogc:PropertyName><ogc:Literal>' + parent_id + '</ogc:Literal></ogc:PropertyIsEqualTo>',
|
|
|
|
|
+ 'sortBy': 'SORT_PRIO+A,ID',
|
|
|
|
|
+ 'ogc:Filter': '<GetFeature xmlns="http://www.opengis.net/wfs/2.0"'+
|
|
|
|
|
+ ' xmlns:p5_default_db="' + BASE_WFS_URL + '/default_db"' +
|
|
|
|
|
+ ' xmlns:ogc="http://www.opengis.net/ogc"' +
|
|
|
|
|
+ ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
|
|
|
|
|
+ ' service="WFS"' +
|
|
|
|
|
+ ' version="2.0.2"' +
|
|
|
|
|
+ ' xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">' +
|
|
|
|
|
+ '<ogc:Filter>' +
|
|
|
|
|
+ '<ogc:PropertyIsEqualTo><ogc:PropertyName>' + "PARENT_ID" + '</ogc:PropertyName><ogc:Literal>' + parent_id + '</ogc:Literal></ogc:PropertyIsEqualTo>' +
|
|
|
|
|
+ '</ogc:Filter>' +
|
|
|
|
|
+ '</GetFeature>'
|
|
|
|
|
+ }).then(function (features) {
|
|
|
|
|
+ ...
|
|
|
|
|
+
|
|
|
*/
|
|
*/
|
|
|
function p5WFS_GetFeature(typeName, query) { // @returns Promise
|
|
function p5WFS_GetFeature(typeName, query) { // @returns Promise
|
|
|
|
|
+ var postData = null
|
|
|
var link = WFS_URL + '?SERVICE=WFS&VERSION=1.0.0' +
|
|
var link = WFS_URL + '?SERVICE=WFS&VERSION=1.0.0' +
|
|
|
'&REQUEST=GetFeature' +
|
|
'&REQUEST=GetFeature' +
|
|
|
'&TYPENAME=' + typeName +
|
|
'&TYPENAME=' + typeName +
|
|
@@ -59,13 +79,21 @@ function p5WFS_GetFeature(typeName, query) { // @returns Promise
|
|
|
;
|
|
;
|
|
|
link += '&Filter=' + ogcFilter
|
|
link += '&Filter=' + ogcFilter
|
|
|
}
|
|
}
|
|
|
|
|
+ if ('ogc:Filter' in query && 'string' === typeof query['ogc:Filter']) {
|
|
|
|
|
+ postData = query['ogc:Filter']
|
|
|
|
|
+ }
|
|
|
if ('sortBy' in query) link += '&sortBy=' + query['sortBy']
|
|
if ('sortBy' in query) link += '&sortBy=' + query['sortBy']
|
|
|
- var method = 'GET' // TODO: if long 'ogc:Filter' then POST
|
|
|
|
|
|
|
+ var method = (postData) ? 'POST' : 'GET' // TODO: if long 'ogc:Filter' then POST
|
|
|
|
|
|
|
|
- return window.fetch(link, {
|
|
|
|
|
|
|
+ return window.fetch(link, Object.assign({
|
|
|
method: method,
|
|
method: method,
|
|
|
credentials: 'same-origin',
|
|
credentials: 'same-origin',
|
|
|
- }).then(function (response) {
|
|
|
|
|
|
|
+ }, ('POST' === method)
|
|
|
|
|
+ ? {
|
|
|
|
|
+ body: postData
|
|
|
|
|
+ }
|
|
|
|
|
+ : {}
|
|
|
|
|
+ )).then(function (response) {
|
|
|
return response.text()
|
|
return response.text()
|
|
|
}).then(function (responseText) {
|
|
}).then(function (responseText) {
|
|
|
return (new DOMParser()).parseFromString(responseText, "text/xml");
|
|
return (new DOMParser()).parseFromString(responseText, "text/xml");
|