diff --git a/hsmodels/schemas/aggregations.py b/hsmodels/schemas/aggregations.py index eee43d0..2e7d6ef 100644 --- a/hsmodels/schemas/aggregations.py +++ b/hsmodels/schemas/aggregations.py @@ -41,7 +41,9 @@ class BaseAggregationMetadataIn(BaseMetadata): title: str = Field( - title="Aggregation title", description="A string containing a descriptive title for the aggregation" + default=None, + title="Aggregation title", + description="A string containing a descriptive title for the aggregation", ) subjects: List[str] = Field( default=[], @@ -68,11 +70,6 @@ class BaseAggregationMetadataIn(BaseMetadata): title="Temporal coverage", description="An object containing the temporal coverage for a aggregation expressed as a date range", ) - rights: Rights = Field( - default=None, - title="Rights statement", - description="An object containing information about the rights held in and over the aggregation and the license under which a aggregation is shared", - ) _parse_additional_metadata = root_validator(pre=True, allow_reuse=True)(parse_additional_metadata) _parse_coverages = root_validator(pre=True, allow_reuse=True)(split_coverages) @@ -129,6 +126,12 @@ class GeographicRasterMetadata(GeographicRasterMetadataIn): title="Aggregation URL", description="An object containing the URL of the aggregation", allow_mutation=False ) + rights: Rights = Field( + default=None, + title="Rights statement", + description="An object containing information about the rights held in and over the aggregation and the license under which a aggregation is shared", + ) + _parse_url = root_validator(pre=True, allow_reuse=True)(parse_url) @@ -178,6 +181,12 @@ class GeographicFeatureMetadata(GeographicFeatureMetadataIn): title="Aggregation URL", description="An object containing the URL of the aggregation", allow_mutation=False ) + rights: Rights = Field( + default=None, + title="Rights statement", + description="An object containing information about the rights held in and over the aggregation and the license under which a aggregation is shared", + ) + _parse_url = root_validator(pre=True, allow_reuse=True)(parse_url) @@ -225,6 +234,12 @@ class MultidimensionalMetadata(MultidimensionalMetadataIn): title="Aggregation URL", description="An object containing the URL of the aggregation", allow_mutation=False ) + rights: Rights = Field( + default=None, + title="Rights statement", + description="An object containing information about the rights held in and over the aggregation and the license under which a aggregation is shared", + ) + _parse_url = root_validator(pre=True, allow_reuse=True)(parse_url) @@ -257,6 +272,12 @@ class ReferencedTimeSeriesMetadata(ReferencedTimeSeriesMetadataIn): title="Aggregation URL", description="An object containing the URL of the aggregation", allow_mutation=False ) + rights: Rights = Field( + default=None, + title="Rights statement", + description="An object containing information about the rights held in and over the aggregation and the license under which a aggregation is shared", + ) + _parse_url = root_validator(pre=True, allow_reuse=True)(parse_url) @@ -289,6 +310,12 @@ class FileSetMetadata(FileSetMetadataIn): title="Aggregation URL", description="An object containing the URL of the aggregation", allow_mutation=False ) + rights: Rights = Field( + default=None, + title="Rights statement", + description="An object containing information about the rights held in and over the aggregation and the license under which a aggregation is shared", + ) + _parse_url = root_validator(pre=True, allow_reuse=True)(parse_url) @@ -320,6 +347,12 @@ class SingleFileMetadata(SingleFileMetadataIn): title="Aggregation URL", description="An object containing the URL of the aggregation", allow_mutation=False ) + rights: Rights = Field( + default=None, + title="Rights statement", + description="An object containing information about the rights held in and over the aggregation and the license under which a aggregation is shared", + ) + _parse_url = root_validator(pre=True, allow_reuse=True)(parse_url) @@ -364,6 +397,12 @@ class TimeSeriesMetadata(TimeSeriesMetadataIn): title="Aggregation URL", description="An object containing the URL of the aggregation", allow_mutation=False ) + rights: Rights = Field( + default=None, + title="Rights statement", + description="An object containing information about the rights held in and over the aggregation and the license under which a aggregation is shared", + ) + _parse_url = root_validator(pre=True, allow_reuse=True)(parse_url) @@ -445,6 +484,12 @@ class ModelProgramMetadata(ModelProgramMetadataIn): title="Aggregation URL", description="An object containing the URL of the aggregation", allow_mutation=False ) + rights: Rights = Field( + default=None, + title="Rights statement", + description="An object containing information about the rights held in and over the aggregation and the license under which a aggregation is shared", + ) + _parse_url = root_validator(pre=True, allow_reuse=True)(parse_url) @@ -496,4 +541,10 @@ class ModelInstanceMetadata(ModelInstanceMetadataIn): title="Aggregation URL", description="An object containing the URL of the aggregation", allow_mutation=False ) + rights: Rights = Field( + default=None, + title="Rights statement", + description="An object containing information about the rights held in and over the aggregation and the license under which a aggregation is shared", + ) + _parse_url = root_validator(pre=True, allow_reuse=True)(parse_url) diff --git a/hsmodels/schemas/validators.py b/hsmodels/schemas/validators.py index 5bac805..71fb733 100644 --- a/hsmodels/schemas/validators.py +++ b/hsmodels/schemas/validators.py @@ -20,6 +20,13 @@ def parse_spatial_reference(cls, value): def parse_multidimensional_spatial_reference(cls, value): + # This is a workaround for form submissions that do not include type + if isinstance(value, dict) and "type" not in value: + if "north" in value or "east" in value: + # it's a type point + value["type"] = "point" + else: + value["type"] = "box" if value['type'] == enums.MultidimensionalSpatialReferenceType.box: d = to_coverage_dict(value['value']) return fields.MultidimensionalBoxSpatialReference(**d) diff --git a/setup.py b/setup.py index 92dcbce..f6e5fff 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='hsmodels', - version='0.4.0', + version='0.4.1', packages=find_packages(include=['hsmodels', 'hsmodels.*', 'hsmodels.schemas.*', 'hsmodels.schemas.rdf.*'], exclude=("tests",)), install_requires=[ diff --git a/tests/data/json/fileset.json b/tests/data/json/fileset.json index ae18249..5abcb53 100644 --- a/tests/data/json/fileset.json +++ b/tests/data/json/fileset.json @@ -20,9 +20,5 @@ "period_coverage": { "start": "2020-11-03T00:00:00", "end": "2020-11-19T00:00:00" - }, - "rights": { - "statement": "my statement", - "url": "http://studio.bakajo.com" } } \ No newline at end of file diff --git a/tests/data/json/geographicfeature.json b/tests/data/json/geographicfeature.json index b632cad..1ca720c 100644 --- a/tests/data/json/geographicfeature.json +++ b/tests/data/json/geographicfeature.json @@ -22,10 +22,6 @@ "start": "2020-11-05T00:00:00", "end": "2020-11-26T00:00:00" }, - "rights": { - "statement": "my statement", - "url": "http://studio.bakajo.com" - }, "field_information": [ { "field_name": "Id", diff --git a/tests/data/json/geographicraster.json b/tests/data/json/geographicraster.json index 9d1d769..cdb7226 100644 --- a/tests/data/json/geographicraster.json +++ b/tests/data/json/geographicraster.json @@ -23,10 +23,6 @@ "start": "2020-11-05T00:00:00", "end": "2020-11-26T00:00:00" }, - "rights": { - "statement": "my statement", - "url": "http://studio.bakajo.com" - }, "band_information": { "name": "Band_1", "variable_name": "variablename", diff --git a/tests/data/json/modelinstance.json b/tests/data/json/modelinstance.json index 942a0e4..05e02fb 100644 --- a/tests/data/json/modelinstance.json +++ b/tests/data/json/modelinstance.json @@ -21,10 +21,6 @@ "start": "2021-10-08T00:00:00", "end": "2021-10-15T00:00:00" }, - "rights": { - "statement": "This resource is shared under the Creative Commons Attribution CC BY.", - "url": "http://creativecommons.org/licenses/by/4.0/" - }, "includes_model_output": false, "executed_by": "https://www.hydroshare.org/resource/636729f24c03497e9b844ec3be63e823/data/contents/modelprogram_resmap.xml#aggregation", "program_schema_json": "https://www.hydroshare.org/resource/636729f24c03497e9b844ec3be63e823/data/contents/modelinstance_schema.json", diff --git a/tests/data/json/modelprogram.json b/tests/data/json/modelprogram.json index 2dcde45..0d2f09f 100644 --- a/tests/data/json/modelprogram.json +++ b/tests/data/json/modelprogram.json @@ -9,10 +9,6 @@ "1": "2", "3": "4" }, - "rights": { - "statement": "This resource is shared under the Creative Commons Attribution CC BY.", - "url": "http://creativecommons.org/licenses/by/4.0/" - }, "version": "1", "name": "Unknown Model Program", "programming_languages": [ diff --git a/tests/data/json/multidimensional.json b/tests/data/json/multidimensional.json index 2283f9c..e2b863a 100644 --- a/tests/data/json/multidimensional.json +++ b/tests/data/json/multidimensional.json @@ -25,10 +25,6 @@ "start": "2008-10-05T00:00:00", "end": "2009-06-18T00:00:00" }, - "rights": { - "statement": "my statement", - "url": "http://studio.bakajo.com" - }, "variables": [ { "name": "x", diff --git a/tests/data/json/referencedtimeseries.refts.json b/tests/data/json/referencedtimeseries.refts.json index 2812df9..ab760de 100644 --- a/tests/data/json/referencedtimeseries.refts.json +++ b/tests/data/json/referencedtimeseries.refts.json @@ -22,9 +22,5 @@ "period_coverage": { "start": "2016-04-06T00:00:00", "end": "2017-02-09T00:00:00" - }, - "rights": { - "statement": "my statement", - "url": "http://studio.bakajo.com" } } \ No newline at end of file diff --git a/tests/data/json/singlefile.json b/tests/data/json/singlefile.json index 3d5a55f..3e889f7 100644 --- a/tests/data/json/singlefile.json +++ b/tests/data/json/singlefile.json @@ -20,9 +20,5 @@ "period_coverage": { "start": "2020-11-03T00:00:00", "end": "2020-11-19T00:00:00" - }, - "rights": { - "statement": "my statement", - "url": "http://studio.bakajo.com" } } \ No newline at end of file diff --git a/tests/data/json/timeseries.json b/tests/data/json/timeseries.json index 819cda5..865e513 100644 --- a/tests/data/json/timeseries.json +++ b/tests/data/json/timeseries.json @@ -18,10 +18,6 @@ "start": "2008-01-01T00:00:00", "end": "2008-01-30T23:30:00" }, - "rights": { - "statement": "This resource is shared under the Creative Commons Attribution CC BY.", - "url": "http://creativecommons.org/licenses/by/4.0/" - }, "time_series_results": [ { "series_id": "182d8fa3-1ebc-11e6-ad49-f45c8999816f",