Skip to content

Commit ef31c30

Browse files
author
Ricardo Garcia Silva
committed
Updating the PDN harvester in order to work with recent changes to upstream GeoNode
1 parent 16bbf44 commit ef31c30

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

src/pdn/harvesters.py

+15-18
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ def get_geonode_resource_type(self, remote_resource_type: str) -> ResourceBase:
258258
def get_resource(
259259
self,
260260
harvestable_resource: harvesting_models.HarvestableResource,
261-
harvesting_session_id: int
262261
) -> typing.Optional[resourcedescriptor.RecordDescription]:
263262
"""Harvest a single resource from the remote service"""
264263
remote_id = harvestable_resource.unique_identifier.rpartition(self._UNIQUE_ID_SEPARATOR)[-1]
@@ -281,6 +280,15 @@ def get_resource(
281280
)
282281
return result
283282

283+
def get_geonode_resource_defaults(
284+
self,
285+
harvested_info: base.HarvestedResourceInfo,
286+
harvestable_resource: harvesting_models.HarvestableResource,
287+
) -> typing.Dict:
288+
defaults = super().get_geonode_resource_defaults(harvested_info, harvestable_resource)
289+
defaults["doc_url"] = harvested_info.resource_descriptor.distribution.download_url
290+
return defaults
291+
284292
def update_geonode_resource(
285293
self,
286294
harvested_info: base.HarvestedResourceInfo,
@@ -298,21 +306,6 @@ def update_geonode_resource(
298306
else:
299307
raise RuntimeError(f"Invalid resource type: {harvestable_resource.remote_resource_type}")
300308

301-
def finalize_resource_update(
302-
self,
303-
geonode_resource: ResourceBase,
304-
harvested_info: base.HarvestedResourceInfo,
305-
harvestable_resource: harvesting_models.HarvestableResource,
306-
harvesting_session_id: int
307-
) -> ResourceBase:
308-
if harvestable_resource.remote_resource_type != PdnResourceType.DOCUMENT.value:
309-
raise RuntimeError(f"Unexpected resource type: {harvestable_resource.remote_resource_type}")
310-
else:
311-
geonode_resource.thumbnail_url = harvested_info.resource_descriptor.distribution.thumbnail_url
312-
geonode_resource.doc_url = harvested_info.resource_descriptor.distribution.original_format_url
313-
geonode_resource.save()
314-
return geonode_resource
315-
316309
def finalize_resource_deletion(self, harvestable_resource: harvesting_models.HarvestableResource):
317310
record_class = {
318311
PdnResourceType.ALERT: models.Alert,
@@ -658,6 +651,7 @@ def _get_resource_descriptor_for_document_resource(
658651
point_of_contact=point_of_contact,
659652
author=author,
660653
date_stamp=date_stamp,
654+
reference_systems=["EPSG:4326"],
661655
identification=resourcedescriptor.RecordIdentification(
662656
name=raw_resource.get("title"),
663657
title=raw_resource.get("title"),
@@ -666,7 +660,6 @@ def _get_resource_descriptor_for_document_resource(
666660
abstract=raw_resource.get("description", ""),
667661
purpose=raw_resource.get("targetaudicent"),
668662
originator=author,
669-
graphic_overview_uri=graphic_overview_url,
670663
place_keywords=[country] if country is not None else [],
671664
other_keywords=tuple(),
672665
license=[],
@@ -680,6 +673,10 @@ def _get_resource_descriptor_for_document_resource(
680673
distribution=resourcedescriptor.RecordDistribution(
681674
link_url=f"{self.remote_url}/document/{raw_resource['id']}",
682675
thumbnail_url=graphic_overview_url,
683-
original_format_url=download_url,
676+
download_url=download_url,
684677
),
678+
additional_parameters={
679+
"extension": raw_resource.get("filename", "").rpartition(".")[-1],
680+
"doc_url": download_url,
681+
}
685682
)

0 commit comments

Comments
 (0)