Skip to content

Commit

Permalink
Added new feature server extensions
Browse files Browse the repository at this point in the history
And tests and to default to constraints["default"] if none and null is allowed
  • Loading branch information
Gary Bagnall committed Jun 9, 2022
1 parent cdafce7 commit 2677db2
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 0 deletions.
5 changes: 5 additions & 0 deletions agsconfig/editing/edit_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
120 changes: 120 additions & 0 deletions agsconfig/services/feature_server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
16 changes: 16 additions & 0 deletions tests/feature_server_extension_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2677db2

Please sign in to comment.