|
10 | 10 | from metax_api.models.catalog_record import CatalogRecord
|
11 | 11 | from metax_api.services import CatalogRecordService as CRS
|
12 | 12 |
|
| 13 | +syke_url_prefix_template = 'http://metatieto.ymparisto.fi:8080/geoportal/catalog/search/resource/details.page?uuid=%s' |
| 14 | + |
13 | 15 |
|
14 | 16 | class MetaxOAIServer(ResumptionOAIPMH):
|
15 | 17 |
|
@@ -48,22 +50,41 @@ def _get_filtered_records(self, set, cursor, batch_size, from_=None, until=None)
|
48 | 50 | query_set = query_set.filter(data_catalog__catalog_json__identifier__in=self._get_default_set_filter())
|
49 | 51 | return query_set[cursor:batch_size]
|
50 | 52 |
|
| 53 | + def _handle_syke_urnresolver_metadata(self, record): |
| 54 | + identifiers = [] |
| 55 | + preferred_identifier = record.research_dataset.get('preferred_identifier') |
| 56 | + identifiers.append(preferred_identifier) |
| 57 | + for id_obj in record.research_dataset.get('other_identifier', []): |
| 58 | + if id_obj.get('notation', '').startswith('{'): |
| 59 | + uuid = id_obj['notation'] |
| 60 | + identifiers.append(syke_url_prefix_template % uuid) |
| 61 | + return identifiers |
| 62 | + |
51 | 63 | def _get_oai_dc_urnresolver_metadata(self, record):
|
52 | 64 | """
|
53 | 65 | Preferred identifier is added only for ida and att catalog records
|
54 | 66 | other identifiers are added for all.
|
| 67 | +
|
| 68 | + Special handling for SYKE catalog. |
55 | 69 | """
|
| 70 | + |
56 | 71 | identifiers = []
|
57 |
| - identifiers.append(settings.OAI['ETSIN_URL_TEMPLATE'] % record.identifier) |
58 | 72 |
|
59 |
| - # assuming ida and att catalogs are not harvested |
60 |
| - if not record.catalog_is_harvested(): |
61 |
| - preferred_identifier = record.research_dataset.get('preferred_identifier') |
62 |
| - identifiers.append(preferred_identifier) |
63 |
| - for id_obj in record.research_dataset.get('other_identifier', []): |
64 |
| - if id_obj.get('notation', '').startswith('urn:nbn:fi:csc-kata'): |
65 |
| - other_urn = id_obj['notation'] |
66 |
| - identifiers.append(other_urn) |
| 73 | + data_catalog = record.data_catalog.catalog_json.get('identifier') |
| 74 | + if data_catalog == 'urn:nbn:fi:att:data-catalog-harvest-syke': |
| 75 | + identifiers = self._handle_syke_urnresolver_metadata(record) |
| 76 | + |
| 77 | + else: |
| 78 | + identifiers.append(settings.OAI['ETSIN_URL_TEMPLATE'] % record.identifier) |
| 79 | + |
| 80 | + # assuming ida and att catalogs are not harvested |
| 81 | + if not record.catalog_is_harvested(): |
| 82 | + preferred_identifier = record.research_dataset.get('preferred_identifier') |
| 83 | + identifiers.append(preferred_identifier) |
| 84 | + for id_obj in record.research_dataset.get('other_identifier', []): |
| 85 | + if id_obj.get('notation', '').startswith('urn:nbn:fi:csc-kata'): |
| 86 | + other_urn = id_obj['notation'] |
| 87 | + identifiers.append(other_urn) |
67 | 88 |
|
68 | 89 | meta = {
|
69 | 90 | 'identifier': identifiers
|
@@ -189,7 +210,7 @@ def getRecord(self, metadataPrefix, identifier):
|
189 | 210 | """Implement OAI-PMH verb GetRecord."""
|
190 | 211 | try:
|
191 | 212 | record = CatalogRecord.objects.get(
|
192 |
| - data_catalog__catalog_json__identifier__in=self._get_default_set_filter(), |
| 213 | + # data_catalog__catalog_json__identifier__in=self._get_default_set_filter(), |
193 | 214 | identifier__exact=identifier
|
194 | 215 | )
|
195 | 216 | except CatalogRecord.DoesNotExist:
|
|
0 commit comments