Skip to content

Commit 84c7af8

Browse files
committed
Replace configuration option for specifying allowed pool names with option for specifying pool names to be used for data transfer
1 parent 2c42476 commit 84c7af8

4 files changed

Lines changed: 31 additions & 32 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ make
5151
* *Name of field in fylr object*: The source field that contains the data to be transferred
5252
* *JavaScript function for reading the value from the fylr object*: Alternatively to specifying a field name, a custom JavaScript function body for reading the value from the fylr object can be entered. The object data can be accessed via the variable "object" (e. g. "return object._id;")
5353
* *WFS target field for pool name* The field of the WFS where the name of the pool that the fylr object belongs to should be stored
54-
* *Allowed pool names for data transfer*: Data is only transferred if the fylr object belongs to a pool with one of the specified pool names
54+
* *Pool names for data transfer*: This field can be used to define the level of the pool hierarchy that should be used for writing the pool name into the WFS target field. If the pool that the fylr object belongs to is a child of one of these pools, the pool (of the higher hierarchy level) specified here is used. Otherwise, the actual pool is used.
5555

5656
### Data model configuration
5757

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields
5050
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)
5151
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)
5252
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
53-
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.allowed_pool_names.label,Erlaubte Poolbezeichnungen für Datenübertragung,Allowed pool names for data transfer
53+
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.pool_names.label,Poolbezeichnungen für Datenübertragung,Pool names for data transfer
5454
base.error.realm.multipleGeometryLinking,Mehrfachverknüpfung von Geometrien nicht erlaubt,Multiple linking of geometries not permitted

manifest.master.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ base_config:
110110
- name: wfs_pool_field
111111
type: text
112112
position: 12
113-
- name: allowed_pool_names
113+
- name: pool_names
114114
type: table
115115
fields:
116-
- name: allowed_pool_name
116+
- name: pool_name
117117
type: text
118118
position: 0
119119
position: 13

src/server/sendDataToGeoserver.js

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,8 @@ function getGeometryFieldPaths(configuration) {
183183
}
184184

185185
async function editGeometries(object, fieldConfiguration, geometryIds, authorizationString) {
186-
const poolName = getPoolName(object, fieldConfiguration);
187-
if (isSendingDataToGeoserverActivated(fieldConfiguration, geometryIds, poolName)) {
188-
const changeMap = getChangeMap(object, fieldConfiguration, poolName);
186+
if (isSendingDataToGeoserverActivated(fieldConfiguration, geometryIds)) {
187+
const changeMap = getChangeMap(object, fieldConfiguration);
189188
if (Object.keys(changeMap).length) {
190189
await performEditTransaction(geometryIds, changeMap, fieldConfiguration, authorizationString);
191190
}
@@ -203,34 +202,15 @@ function getDeletedGeometryIds(geometryIds, currentObject, fieldConfiguration) {
203202
return currentGeometryIds.filter(geometryId => !geometryIds.includes(geometryId));
204203
}
205204

206-
function isSendingDataToGeoserverActivated(fieldConfiguration, geometryIds, poolName) {
205+
function isSendingDataToGeoserverActivated(fieldConfiguration, geometryIds) {
207206
return fieldConfiguration.send_data_to_geoserver?.ValueBool
208207
&& fieldConfiguration.edit_wfs_url?.ValueText
209-
&& geometryIds?.length
210-
&& poolName !== undefined;
211-
}
212-
213-
function getPoolName(object, fieldConfiguration) {
214-
if (!object._pool) return undefined;
215-
216-
const allowedPoolNames = getAllowedPoolNames(fieldConfiguration);
217-
for (let entry of object._pool._path) {
218-
const poolName = entry.pool.name?.['de-DE'];
219-
if (allowedPoolNames.includes(poolName)) return poolName;
220-
}
221-
222-
return undefined;
223-
}
224-
225-
function getAllowedPoolNames(fieldConfiguration) {
226-
return fieldConfiguration.allowed_pool_names?.ValueTable?.map(entry => {
227-
return entry.allowed_pool_name.ValueText;
228-
}) ?? [];
208+
&& geometryIds?.length;
229209
}
230210

231-
function getChangeMap(object, fieldConfiguration, poolName) {
211+
function getChangeMap(object, fieldConfiguration) {
232212
const changeMap = {};
233-
addPoolFieldToChangeMap(fieldConfiguration, poolName, changeMap);
213+
addPoolFieldToChangeMap(object, fieldConfiguration, changeMap);
234214

235215
const fields = fieldConfiguration.fields?.ValueTable ?? [];
236216
return fields.reduce((result, field) => {
@@ -269,11 +249,30 @@ function getValueFromCustomFunction(object, functionDefinition) {
269249
return customFunction(object);
270250
}
271251

272-
function addPoolFieldToChangeMap(fieldConfiguration, poolName, changeMap) {
252+
function addPoolFieldToChangeMap(object, fieldConfiguration, changeMap) {
273253
const targetFieldName = fieldConfiguration.wfs_pool_field.ValueText;
274254
if (!targetFieldName) return;
275255

276-
changeMap[targetFieldName] = poolName;
256+
const poolName = getPoolName(object, fieldConfiguration);
257+
if (poolName) changeMap[targetFieldName] = poolName;
258+
}
259+
260+
function getPoolName(object, fieldConfiguration) {
261+
if (!object._pool) return undefined;
262+
263+
const poolNames = getPoolNamesForDataTransfer(fieldConfiguration);
264+
for (let entry of object._pool._path) {
265+
const poolName = entry.pool.name?.['de-DE'];
266+
if (poolNames.includes(poolName)) return poolName;
267+
}
268+
269+
return object._pool.pool?.name?.['de-DE'];
270+
}
271+
272+
function getPoolNamesForDataTransfer(fieldConfiguration) {
273+
return fieldConfiguration.pool_names?.ValueTable?.map(entry => {
274+
return entry.pool_name.ValueText;
275+
}) ?? [];
277276
}
278277

279278
function addToChangeMap(wfsFieldName, fieldValue, changeMap) {

0 commit comments

Comments
 (0)