|
1 | 1 | import logging
|
2 | 2 | from geonode.resource.enumerator import ExecutionRequestAction as exa
|
3 | 3 | from importer.handlers.base import BaseHandler
|
| 4 | +from importer.models import ResourceHandlerInfo |
4 | 5 | from importer.handlers.xml.serializer import MetadataFileSerializer
|
5 | 6 | from importer.utils import ImporterRequestAction as ira
|
6 | 7 | from importer.orchestrator import orchestrator
|
@@ -53,18 +54,39 @@ def extract_params_from_data(_data, action=None):
|
53 | 54 |
|
54 | 55 | @staticmethod
|
55 | 56 | 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() |
57 | 68 |
|
58 | 69 | def import_resource(self, files: dict, execution_id: str, **kwargs):
|
59 | 70 | _exec = orchestrator.get_execution_object(execution_id)
|
60 | 71 | # getting the dataset
|
61 | 72 | 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) |
63 | 78 |
|
64 | 79 | # retrieving the handler used for the dataset
|
65 | 80 | original_handler = orchestrator.load_handler(
|
66 | 81 | dataset.resourcehandlerinfo_set.first().handler_module_path
|
67 | 82 | )()
|
| 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 | + ) |
68 | 90 |
|
69 | 91 | self.handle_metadata_resource(_exec, dataset, original_handler)
|
70 | 92 |
|
|
0 commit comments