Commit efedd14c authored by Willem ter Berg's avatar Willem ter Berg

Merge branch 'public.version' into data.overheid.nl

# Conflicts:
#	ckanext/dcatdonl/schema/dcat_ap_donl_schema.py
#	ckanext/dcatdonl/validator/validator_factory.py
parents 9c1151d3 670df7cd
......@@ -45,6 +45,7 @@ def create_schema(schema):
contact_point_validation = tk.get_validator('contact_point_validation')
hash_validation = tk.get_validator('hash_validation')
legal_foundation_validation = tk.get_validator('legal_foundation_validation')
to_curly_string_if_list = tk.get_converter('convert_to_curly_string_if_list')
schema.update({
'identifier': [mandatory, is_string, to_extras],
......@@ -65,7 +66,7 @@ def create_schema(schema):
'contact_point_title': [recommended, is_string, to_extras],
'authority': [mandatory, donl_organization, to_extras],
'publisher': [mandatory, donl_organization, to_extras],
'license': [recommended, overheid_license],
'license': [mandatory, overheid_license],
'access_rights': [recommended, overheid_openbaarheidsniveau, to_extras],
'url': [recommended, is_uri],
'spatial_scheme': [recommended, overheid_spatial_scheme, to_extras],
......@@ -98,20 +99,20 @@ def create_schema(schema):
'name': [mandatory, is_string],
'description': [mandatory, is_string],
'metadata_language': [mandatory, donl_language],
'language': [mandatory, donl_language],
'language': [mandatory, donl_languages, to_curly_string_if_list],
'license': [mandatory, overheid_license],
'format': [mandatory, mdr_filetype_nal],
'size': [recommended, is_number],
'download_url': [recommended, is_uri],
'download_url': [recommended, are_uris, to_curly_string_if_list],
'mimetype': [recommended, iana_mediatypes],
'release_date': [recommended, is_date],
'rights': [recommended, is_string],
'status': [recommended, adms_distributiestatus],
'modification_date': [recommended, is_date],
'linked_schemas': [recommended, is_string],
'linked_schemas': [recommended, is_list, to_curly_string_if_list],
'hash': [optional, is_string],
'hash_algorithm': [optional, is_string],
'documentation': [optional, is_uri],
'documentation': [optional, are_uris, to_curly_string_if_list],
'__after': [hash_validation]
})
......@@ -152,6 +153,7 @@ def update_schema(schema):
is_list = tk.get_validator('is_list')
are_uris = tk.get_validator('are_uris')
to_list_if_curly_string = tk.get_converter('convert_to_list_if_curly_string')
to_curly_string_if_list = tk.get_converter('convert_to_curly_string_if_list')
spatial_validation = tk.get_validator('spatial_validation')
temporal_validation = tk.get_validator('temporal_validation')
contact_point_validation = tk.get_validator('contact_point_validation')
......@@ -210,20 +212,20 @@ def update_schema(schema):
'name': [mandatory, is_string],
'description': [mandatory, is_string],
'metadata_language': [mandatory, donl_language],
'language': [mandatory, donl_language],
'language': [mandatory, donl_languages, to_curly_string_if_list],
'license': [mandatory, overheid_license],
'format': [mandatory, mdr_filetype_nal],
'size': [recommended, is_number],
'download_url': [recommended, is_uri],
'download_url': [recommended, are_uris, to_curly_string_if_list],
'mimetype': [recommended, iana_mediatypes],
'release_date': [recommended, is_date],
'rights': [recommended, is_string],
'status': [recommended, adms_distributiestatus],
'modification_date': [recommended, is_date],
'linked_schemas': [recommended, is_string],
'linked_schemas': [recommended, is_list, to_curly_string_if_list],
'hash': [optional, is_string],
'hash_algorithm': [optional, is_string],
'documentation': [optional, is_uri],
'documentation': [optional, are_uris, to_curly_string_if_list],
'__after': [hash_validation]
})
......@@ -252,7 +254,7 @@ def show_schema(schema):
'changetype': [from_extras, mandatory],
'source_catalog': [from_extras, recommended],
'language': [from_extras, mandatory, to_list_if_curly_string],
'metadata_language': [from_extras, mandatory, to_list_if_curly_string],
'metadata_language': [from_extras, mandatory],
'theme': [from_extras, mandatory, to_list_if_curly_string],
'contact_point_email': [from_extras, recommended],
'contact_point_address': [from_extras, recommended],
......@@ -265,7 +267,7 @@ def show_schema(schema):
'license': [recommended],
'access_rights': [from_extras, recommended],
'url': [recommended],
'spatial_scheme': [from_extras, recommended],
'spatial_scheme': [from_extras, recommended, to_list_if_curly_string],
'spatial_value': [from_extras, recommended, to_list_if_curly_string],
'temporal_label': [from_extras, recommended],
'temporal_start': [from_extras, recommended],
......@@ -294,20 +296,20 @@ def show_schema(schema):
'name': [mandatory],
'description': [mandatory],
'metadata_language': [mandatory],
'language': [mandatory],
'language': [mandatory, to_list_if_curly_string],
'license': [mandatory],
'format': [mandatory],
'size': [recommended],
'download_url': [recommended],
'download_url': [recommended, to_list_if_curly_string],
'mimetype': [recommended],
'release_date': [recommended],
'rights': [recommended],
'status': [recommended],
'modification_date': [recommended],
'linked_schemas': [recommended],
'linked_schemas': [recommended, to_list_if_curly_string],
'hash': [optional],
'hash_algorithm': [optional],
'documentation': [optional]
'documentation': [optional, to_list_if_curly_string]
})
return schema
......@@ -63,6 +63,24 @@ def convert_to_list_if_string(key, data_dict, errors, context):
values = values.replace('"', '')
if isinstance(values, basestring) and values.startswith('{') and values.endswith('}'):
values = values.replace('"', '')
data_dict[key] = values[1:len(values) - 1].split(',')
return key, data_dict, errors, context
def convert_to_curly_string_if_list(key, data_dict, errors, context):
"""
Converts a list of strings to a string surrounded with curly braces.
:param key: str, the key of the data_dict dictionary
:param data_dict: dict, the dictionary to modify
:param errors: dict, argument to match CKAN method signature, not used
:param context: dict, argument to match CKAN method signature, not used
:return: (key, data, errors, context), the original arguments, possibly modified
"""
values = data_dict[key]
if isinstance(values, list):
data_dict[key] = '{' + ','.join(map(str, values)) + '}'
return key, data_dict, errors, context
......@@ -61,7 +61,8 @@ _VALIDATORS = {
'basisregister_on_create': system_properties_validator.basisregister_on_create,
'basisregister_on_update': system_properties_validator.basisregister_on_update,
'link_status_default': system_properties_validator.link_status_default,
'link_status_update': system_properties_validator.link_status_update
'link_status_update': system_properties_validator.link_status_update,
'convert_to_curly_string_if_list': type_validator.convert_to_curly_string_if_list
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment