diff --git a/json_datacite.py b/json_datacite.py index 04bbefafa..bdf08edce 100644 --- a/json_datacite.py +++ b/json_datacite.py @@ -163,7 +163,7 @@ def get_publication_year(combi): def get_subjects(combi): """Get list in DataCite format containing: - 1) standard objects like tags/disciplne + 1) standard objects like tags/discipline 2) free items, for now specifically for GEO schemas :param combi: Combined JSON file that holds both user and system metadata @@ -175,8 +175,19 @@ def get_subjects(combi): for discipline in combi.get('Discipline', []): subjects.append({'subjectScheme': 'OECD FOS 2007', 'subject': discipline}) - for keyword in combi.get('Keyword', []): - subjects.append({'subject': keyword, 'subjectScheme': 'Keyword'}) + # Assume that there is only one keyword field, + # either called HierarchicalKeyword or Keyword + # TODO combine with the json_landing_page one? + if "HierarchicalKeyword" in combi: + subjects.extend(combi["HierarchicalKeyword"]) + # for keyword in combi["HierarchicalKeyword"]: + # keyword['subject'] = keyword['Subject'] + # del keyword['Subject'] + # subjects.append(keyword) + else: + for keyword in combi.get('Keyword', []): + # TODO why is this not uppercase here? + subjects.append({'subject': keyword, 'subjectScheme': 'Keyword'}) # for backward compatibility. Tag will become obsolete for tag in combi.get('Tag', []): diff --git a/json_landing_page.py b/json_landing_page.py index 5a67f9114..a20a253f1 100644 --- a/json_landing_page.py +++ b/json_landing_page.py @@ -100,7 +100,12 @@ def json_landing_page_create_json_landing_page(ctx, zone, template_name, combi_j keywords = json_data.get("Tag", []) # From core-2 and default-3 Tag is renamed to Keyword - keywords.extend(json_data.get("Keyword", [])) + if "HierarchicalKeyword" in json_data: + log.write(ctx, "keyword {}".format(json_data.get("HierarchicalKeyword"))) + keywords.extend(json_data.get("HierarchicalKeyword")) + else: + for keyword in json_data.get('Keyword', []): + keywords.append({'Subject': keyword, 'subjectScheme': 'Keyword'}) try: disciplines = [] @@ -168,6 +173,7 @@ def json_landing_page_create_json_landing_page(ctx, zone, template_name, combi_j labs = [] # Geo specific keywords + # TODO remove these, or at least remove the ones that aren't relevant anymore keywords.extend(json_data.get("Apparatus", [])) # teclab-0, teclab-1, hptlab-0, hptlab-1 keywords.extend(json_data.get("Material", [])) # teclab-0, teclab-1, hptlab-0, hptlab-1 keywords.extend(json_data.get("Measured_Property", [])) # teclab-0, teclab-1, hptlab-0, hptlab-1 diff --git a/templates/landingpage.html.j2 b/templates/landingpage.html.j2 index daf16d10d..5d76d2d81 100644 --- a/templates/landingpage.html.j2 +++ b/templates/landingpage.html.j2 @@ -62,7 +62,13 @@
{% for keyword in keywords %} - {{ keyword }} + {% if "valueURI" in keyword %} + + {{ keyword.Subject }} + + {% else %} + {{ keyword.Subject }} + {% endif %} {% endfor %}