From 2677db2ab355fd674f996a1f0263a7e419342044 Mon Sep 17 00:00:00 2001 From: Gary Bagnall Date: Thu, 9 Jun 2022 14:56:09 +1000 Subject: [PATCH] Added new feature server extensions And tests and to default to constraints["default"] if none and null is allowed --- agsconfig/editing/edit_prop.py | 5 + .../services/feature_server_extension.py | 120 ++++++++++++++++++ tests/feature_server_extension_mixin.py | 16 +++ 3 files changed, 141 insertions(+) diff --git a/agsconfig/editing/edit_prop.py b/agsconfig/editing/edit_prop.py index 5549dcf..35fb5f3 100644 --- a/agsconfig/editing/edit_prop.py +++ b/agsconfig/editing/edit_prop.py @@ -38,6 +38,11 @@ def __get__(self, obj, type=None): value = obj._editor.get_value(self.name_of(obj), self.meta, obj) + if not value and "constraints" in self.meta: + constraints = self.meta["constraints"] + + if "default" in constraints and value is None: + value = constraints["default"] return value def __set__(self, obj, value): diff --git a/agsconfig/services/feature_server_extension.py b/agsconfig/services/feature_server_extension.py index 3db9258..c9a4055 100644 --- a/agsconfig/services/feature_server_extension.py +++ b/agsconfig/services/feature_server_extension.py @@ -61,6 +61,126 @@ def __init__(self, editor): } ) + allow_others_to_delete = EditorProperty( + { + "formats": { + "agsJson": { + "conversions": [{ + "id": "boolToString" + }], + "paths": [ + { + "document": "main", + "path": "$.extensions[?(@.typeName = 'FeatureServer')].properties.allowOthersToDelete" + } + ] + }, + "sddraft": { + "conversions": [{ + "id": "boolToString" + }], + "paths": [ + { + "path": lambda extension_name: + "./Configurations/SVCConfiguration/Definition/Extensions/SVCExtension[TypeName='{0}']/Props/PropertyArray/PropertySetProperty[Key='allowOthersToDelete']/Value" + .format(extension_name) + } + ] + } + } + } + ) + + allow_others_to_query = EditorProperty( + { + "formats": { + "agsJson": { + "conversions": [{ + "id": "boolToString" + }], + "paths": [ + { + "document": "main", + "path": "$.extensions[?(@.typeName = 'FeatureServer')].properties.allowOthersToQuery" + } + ] + }, + "sddraft": { + "conversions": [{ + "id": "boolToString" + }], + "paths": [ + { + "path": lambda extension_name: + "./Configurations/SVCConfiguration/Definition/Extensions/SVCExtension[TypeName='{0}']/Props/PropertyArray/PropertySetProperty[Key='allowOthersToQuery']/Value" + .format(extension_name) + } + ] + } + } + } + ) + + allow_others_to_update = EditorProperty( + { + "formats": { + "agsJson": { + "conversions": [{ + "id": "boolToString" + }], + "paths": [ + { + "document": "main", + "path": "$.extensions[?(@.typeName = 'FeatureServer')].properties.allowOthersToUpdate" + } + ] + }, + "sddraft": { + "conversions": [{ + "id": "boolToString" + }], + "paths": [ + { + "path": lambda extension_name: + "./Configurations/SVCConfiguration/Definition/Extensions/SVCExtension[TypeName='{0}']/Props/PropertyArray/PropertySetProperty[Key='allowOthersToUpdate']/Value" + .format(extension_name) + } + ] + } + } + } + ) + + set_defaults_to_null_for_not_null_fields_in_templates = EditorProperty( + { + "constraints": { + "default": False + }, + "formats": { + "agsJson": { + "conversions": [{ + "id": "boolToString", + "allowNone": False, + "noneAsFalse": True + }], + "paths": [ + { + "document": "main", + "path": lambda extension_name: + "$.extensions[?(@.typeName = '{}')].properties.setDefaultsToNullForNotNullFieldsInTemplates" + .format(extension_name), + "parent": { + "children": [{ + "key": "setDefaultsToNullForNotNullFieldsInTemplates" + }] + } + } + ] + } + } + } + ) + allow_geometry_updates_without_m_values = EditorProperty( { "formats": { diff --git a/tests/feature_server_extension_mixin.py b/tests/feature_server_extension_mixin.py index 8f87f4a..4a290d5 100644 --- a/tests/feature_server_extension_mixin.py +++ b/tests/feature_server_extension_mixin.py @@ -25,6 +25,10 @@ BASE_GETTER_TEST_CASES + [ ('allow_geometry_updates', True, None), + ('allow_others_to_delete', False, None), + ('allow_others_to_query', True, None), + ('allow_others_to_update', False, None), + ('set_defaults_to_null_for_not_null_fields_in_templates', False, None), ('allow_true_curves_updates', False, None), ('enable_ownership_based_access_control', False, None), ('enable_z_defaults', False, None), @@ -52,6 +56,18 @@ def test_feature_server_getters(service_config, attribute, expected_value, excep ] + [ ("allow_geometry_updates", trueish_value, trueish_expected, None) for (trueish_value, trueish_expected) in TRUEISH_TEST_PARAMS + ] + [ + ("allow_others_to_delete", trueish_value, trueish_expected, None) + for (trueish_value, trueish_expected) in TRUEISH_TEST_PARAMS + ] + [ + ("allow_others_to_query", trueish_value, trueish_expected, None) + for (trueish_value, trueish_expected) in TRUEISH_TEST_PARAMS + ] + [ + ("allow_others_to_update", trueish_value, trueish_expected, None) + for (trueish_value, trueish_expected) in TRUEISH_TEST_PARAMS + ] + [ + ("set_defaults_to_null_for_not_null_fields_in_templates", trueish_value, trueish_expected, None) + for (trueish_value, trueish_expected) in TRUEISH_TEST_PARAMS ] + [ ("allow_true_curves_updates", trueish_value, trueish_expected, None) for (trueish_value, trueish_expected) in TRUEISH_TEST_PARAMS