Просмотр исходного кода

updated p5Wfs/GetFeature.js - added POST ogc:Filter

Piotr Labudda 8 лет назад
Родитель
Сommit
c69e246312
2 измененных файлов с 53 добавлено и 14 удалено
  1. 32 4
      SE/static/p5WFS/GetFeature.js
  2. 21 10
      SE/static/procesEditor.js

+ 32 - 4
SE/static/p5WFS/GetFeature.js

@@ -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', {
 		'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
+	var postData = null
 	var link = WFS_URL + '?SERVICE=WFS&VERSION=1.0.0' +
 		'&REQUEST=GetFeature' +
 		'&TYPENAME=' + typeName +
@@ -59,13 +79,21 @@ function p5WFS_GetFeature(typeName, query) { // @returns Promise
 		;
 		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']
-	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,
 		credentials: 'same-origin',
-	}).then(function (response) {
+	}, ('POST' === method)
+		? {
+			body: postData
+		}
+		: {}
+	)).then(function (response) {
 		return response.text()
 	}).then(function (responseText) {
 		return (new DOMParser()).parseFromString(responseText, "text/xml");

+ 21 - 10
SE/static/procesEditor.js

@@ -1338,16 +1338,16 @@ $(document).ready(function() {
                 $.each(data, function(i, e) {
                     if (e["ID"] != 0) {
                         var type = 0;
-                        $(target).append("<div class='dragStyle drag dragStyle hov' data-id=" 
-						+ e["ID"] 
-						+ " data-type=" 
-						+ type + " data-desc='" 
-						+ e["DESC"] 
-						+ "' data-opis='" 
-						+ e["OPIS"] 
-						+ "'>" 
-						+ e["DESC"] 
-						+ " [" 
+                        $(target).append("<div class='dragStyle drag dragStyle hov' data-id="
+						+ e["ID"]
+						+ " data-type="
+						+ type + " data-desc='"
+						+ e["DESC"]
+						+ "' data-opis='"
+						+ e["OPIS"]
+						+ "'>"
+						+ e["DESC"]
+						+ " ["
 						+ e["ID"] + "]</div>");
                         for (var i = 3; i > 0; i--) {
                             if (e["p" + i + "_ID"] != null) {
@@ -2532,6 +2532,17 @@ $(document).ready(function() {
 		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) {
 			var feature = null
 			for (var i = 0, total = features.length; i < total; i++) {