Skip to content

Commit

Permalink
YDA-5059: Support tree keywords in landingpages and datacite
Browse files Browse the repository at this point in the history
  • Loading branch information
claravox committed Dec 13, 2024
1 parent 45bb675 commit 69cee11
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
17 changes: 14 additions & 3 deletions json_datacite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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', []):
Expand Down
8 changes: 7 additions & 1 deletion json_landing_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion templates/landingpage.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@
<div class="keywords">
<label>Keywords</label>
{% for keyword in keywords %}
<span class="keyword" property="dc:subject">{{ keyword }}</span>
{% if "valueURI" in keyword %}
<span class="keyword" property="dc:subject">
<a href="{{keyword.valueURI}}">{{ keyword.Subject }}</a>
</span>
{% else %}
<span class="keyword" property="dc:subject">{{ keyword.Subject }}</span>
{% endif %}
{% endfor %}
</div>
</section>
Expand Down

0 comments on commit 69cee11

Please sign in to comment.