Skip to content

Commit 33709cf

Browse files
committed
return detail_url for SLD and XML and prepare for the new input params
1 parent 1787c78 commit 33709cf

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

importer/handlers/common/metadata.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
from geonode.resource.enumerator import ExecutionRequestAction as exa
33
from importer.handlers.base import BaseHandler
4+
from importer.models import ResourceHandlerInfo
45
from importer.handlers.xml.serializer import MetadataFileSerializer
56
from importer.utils import ImporterRequestAction as ira
67
from importer.orchestrator import orchestrator
@@ -53,18 +54,39 @@ def extract_params_from_data(_data, action=None):
5354

5455
@staticmethod
5556
def perform_last_step(execution_id):
56-
pass
57+
_exec = orchestrator.get_execution_object(execution_id)
58+
59+
_exec.output_params.update(
60+
**{
61+
"detail_url": [
62+
x.resource.detail_url
63+
for x in ResourceHandlerInfo.objects.filter(execution_request=_exec)
64+
]
65+
}
66+
)
67+
_exec.save()
5768

5869
def import_resource(self, files: dict, execution_id: str, **kwargs):
5970
_exec = orchestrator.get_execution_object(execution_id)
6071
# getting the dataset
6172
alternate = _exec.input_params.get("dataset_title")
62-
dataset = get_object_or_404(Dataset, alternate=alternate)
73+
resource_id = _exec.input_params.get("resource_id")
74+
if resource_id:
75+
dataset = get_object_or_404(Dataset, pk=resource_id)
76+
elif alternate:
77+
dataset = get_object_or_404(Dataset, alternate=alternate)
6378

6479
# retrieving the handler used for the dataset
6580
original_handler = orchestrator.load_handler(
6681
dataset.resourcehandlerinfo_set.first().handler_module_path
6782
)()
83+
84+
ResourceHandlerInfo.objects.create(
85+
handler_module_path=dataset.resourcehandlerinfo_set.first().handler_module_path,
86+
resource=dataset,
87+
execution_request=_exec,
88+
kwargs=kwargs.get("kwargs", {}) or kwargs,
89+
)
6890

6991
self.handle_metadata_resource(_exec, dataset, original_handler)
7092

0 commit comments

Comments
 (0)