Skip to content

Commit d226c28

Browse files
committed
Allow setting boolean fields in WFS based on tags in fylr objects
1 parent fb8f77a commit d226c28

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

l10n/custom-data-type-nfis-geometry.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields
6464
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.fields.wfs_field_name.label,Name des WFS-Zielfeldes,Name of WFS target field
6565
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.fields.fylr_field_name.label,Name des Feldes im fylr-Objekt (inkl. Pfad),Name of field in fylr object (including path)
6666
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.fields.fylr_function.label,JavaScript-Funktion zum Auslesen des Wertes aus dem fylr-Objekt (Alternative zur Angabe des Feldnamens),JavaScript function for reading the value from the fylr object (Alternative to specifying the field name)
67+
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.tags.label,Zu übertragende Tags,Tags to be transferred
68+
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.tags.wfs_field_name.label,Name des WFS-Zielfeldes,Name of WFS target field
69+
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.tags.fylr_tags_path.label,Pfad zu den Tags im fylr-Objekt,Path to tags in fylr object
70+
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.tags.fylr_tag_id.label,Tag-ID,Tag ID
6771
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.wfs_pool_field.label,WFS-Zielfeld für die Poolbezeichnung,WFS target field for pool name
6872
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.pool_names.label,Poolbezeichnungen für Datenübertragung,Pool names for data transfer
6973
server.config.parameter.system.nfisGeoservices.linked_objects.label,Verknüpfte Objekte,Linked objects

manifest.master.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ base_config:
137137
type: text
138138
position: 2
139139
position: 12
140+
- name: tags
141+
type: table
142+
fields:
143+
- name: wfs_field_name
144+
type: text
145+
position: 0
146+
- name: fylr_tags_path
147+
type: text
148+
position: 1
149+
- name: fylr_tag_id
150+
type: int
151+
position: 2
140152
- name: wfs_pool_field
141153
type: text
142154
position: 13

src/server/sendDataToGeoserver.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function getObjectData(object) {
3939
const objectData = JSON.parse(JSON.stringify(object[object._objecttype]));
4040
objectData._uuid = object._uuid;
4141
objectData._objecttype = object._objecttype;
42+
objectData._tags = object._tags;
4243
return objectData;
4344
}
4445

@@ -190,23 +191,42 @@ function hasLinkedObjectData(fieldContent) {
190191

191192
async function getChangeMap(object, fieldConfiguration) {
192193
const changeMap = {};
194+
193195
addPoolFieldToChangeMap(object, fieldConfiguration, changeMap);
196+
await addFieldsToChangeMap(object, fieldConfiguration, changeMap);
197+
await addTagsToChangeMap(object, fieldConfiguration, changeMap)
194198

195-
if (!fieldConfiguration.fields) return changeMap;
199+
return changeMap;
200+
}
201+
202+
async function addFieldsToChangeMap(object, fieldConfiguration, changeMap) {
203+
if (!fieldConfiguration.fields) return;
196204

197205
for (let field of fieldConfiguration.fields) {
198206
const wfsFieldName = field.wfs_field_name;
199207
const fylrFieldName = field.fylr_field_name;
200208
const fylrFunction = field.fylr_function;
201-
if (fylrFieldName || fylrFunction) {
209+
if (wfsFieldName && (fylrFieldName || fylrFunction)) {
202210
const fieldValue = fylrFieldName
203211
? (await getFieldValues(object, fylrFieldName.split('.')))?.[0]
204212
: getValueFromCustomFunction(object, fylrFunction);
205213
addToChangeMap(wfsFieldName, fieldValue, changeMap);
206214
}
207215
}
216+
}
208217

209-
return changeMap;
218+
async function addTagsToChangeMap(object, fieldConfiguration, changeMap) {
219+
if (!fieldConfiguration.tags) return;
220+
221+
for (let tag of fieldConfiguration.tags) {
222+
const wfsFieldName = tag.wfs_field_name;
223+
const tagsPath = tag.fylr_tags_path ?? '_tags';
224+
const tagId = tag.fylr_tag_id;
225+
if (wfsFieldName && tagId) {
226+
const tags = (await getFieldValues(object, tagsPath.split('.')))[0];
227+
changeMap[wfsFieldName] = tags.find(entry => entry._id === tagId) !== undefined;
228+
}
229+
}
210230
}
211231

212232
async function getFieldValues(object, pathSegments) {

0 commit comments

Comments
 (0)