Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YDA-5059: add hierarchical keyword selector #537

Open
wants to merge 19 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 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,13 @@ 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 TreeKeyword or Keyword
if "TreeKeyword" in combi:
subjects.extend(combi["TreeKeyword"])
else:
for keyword in combi.get('Keyword', []):
subjects.append({'subject': keyword, 'subjectScheme': 'Keyword'})

# for backward compatibility. Tag will become obsolete
for tag in combi.get('Tag', []):
Expand Down
11 changes: 9 additions & 2 deletions json_landing_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,16 @@ def json_landing_page_create_json_landing_page(ctx, zone, template_name, combi_j
data_access_restriction = json_data["Data_Access_Restriction"]
data_classification = json_data["Data_Classification"]

keywords = json_data.get("Tag", [])
keywords = []
for keyword in json_data.get("Tag", []):
keywords.append({'subject': keyword, 'subjectScheme': 'Keyword'})

# From core-2 and default-3 Tag is renamed to Keyword
keywords.extend(json_data.get("Keyword", []))
if "TreeKeyword" in json_data:
keywords.extend(json_data.get("TreeKeyword"))
else:
for keyword in json_data.get('Keyword', []):
keywords.append({'subject': keyword, 'subjectScheme': 'Keyword'})

try:
disciplines = []
Expand Down
36 changes: 28 additions & 8 deletions schemas/epos-msl-0/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@
"Analogue modelling of geologic processes",
"Paleomagnetic and magnetic data",
"Rock and melt physical properties",
"Analytical and microscopy data"
"Microscopy and tomography data",
"Geochemistry",
"Geo-energy test beds"
]
},
"optionsLicense": {
Expand Down Expand Up @@ -839,7 +841,7 @@
"Version",
"Language",
"Collected",
"Keyword",
"TreeKeyword",
"Retention_Period",
"Data_Type",
"Data_Classification",
Expand Down Expand Up @@ -995,14 +997,32 @@
}
}
},
"Keyword": {
"title": "Keywords",
"TreeKeyword": {
"type": "array",
"minItems": 1,
lwesterhof marked this conversation as resolved.
Show resolved Hide resolved
"additionalProperties": false,
"title": "Keywords",
"items": {
"$ref": "#/definitions/stringNormal",
"title": "Keyword",
"default": null
"type": "object",
"additionalProperties": false,
"properties": {
"subject": {
"$ref": "#/definitions/stringNormal",
"title": "Keyword name"
},
"subjectScheme": {
"$ref": "#/definitions/stringNormal",
"title": "Name of the subject scheme"
},
"schemeUri": {
"$ref": "#/definitions/stringNormal",
"title": "URI of the subject identifier scheme"
},
"valueUri": {
"$ref": "#/definitions/stringNormal",
"title": "URI of the subject term"
}
},
"required": ["subject"]
}
},
"Related_Resource": {
Expand Down
12 changes: 8 additions & 4 deletions schemas/epos-msl-0/uischema.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@
}
},
"GeoLocation": {
"ui:description": "Geographical location refers to a specific physical point on Earth. This is more precise than 'area' or 'place' often defined by a set of latitude and longitude coordinates.",
"ui:description": "Sample location: the location of the outcrop/quarry/borehole/other from which the sample(s) used in your study were taken originally. Please do not add a location of a shop, repository or other facility that temporarily stores samples. Model location: include only if a model you publish refers to a specific location on Earth.",
"items": {
"geoLocationBox": {
"ui:field": "geo"
}
}
},
"Keyword": {
"ui:description": "Free text field for adding (searchable) keywords to your data package"
"TreeKeyword": {
"ui:description": "Adding (searchable) keywords to your data package.",
"ui:field": "tree_keyword_selector",
"ui:data": "https://raw.githubusercontent.com/UtrechtUniversity/msl_vocabularies/refs/heads/main/vocabularies/combined/editor/1.3/editor_1-3.json",
lwesterhof marked this conversation as resolved.
Show resolved Hide resolved
"ui:subjectScheme": "EPOS MSL",
"ui:schemeUri": "https://github.com/UtrechtUniversity/msl_vocabularies"
},
"Related_Resource": {
"items": {
Expand Down Expand Up @@ -87,7 +91,7 @@
"ui:help": "How is your data classified with regard to information security policy"
},
"Creator": {
"ui:description": "The person(s) who created (a version of) the data package.",
"ui:description": "The main researchers involved in producing the data or model, and/or the authors of the publication, in priority order. To supply multiple creators/authors (adviced), please repeat this property (plus sign top-richt corner).",
"items": {
"Name": {
"Given_Name": {
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
26 changes: 24 additions & 2 deletions tests/features/ui/ui_meta.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ Feature: Meta UI
Given user researcher is authenticated
And collection /tempZone/home/research-initial exists
And collection /tempZone/home/research-initial/folder space exists
And collection /tempZone/home/research-epos-msl-0 exists
And /tempZone/home/research-initial is unlocked
And /tempZone/home/research-epos-msl-0 is unlocked


Scenario Outline: Save metadata
Expand Down Expand Up @@ -36,6 +38,25 @@ Feature: Meta UI
| research-initial/folder space | research-initial | folder space |


Scenario Outline: Save hierarchical keywords
Given user researcher is logged in
And module "research" is shown
When user browses to folder <folder>
And user opens metadata form
# EPOS keyword
And user selects keyword "decane"
# user-defined keyword
And user selects keyword "totally custom keyword!42"
And user clicks save button
Then metadata form is saved as yoda-metadata.json for folder <folder>
When user clears keyword selector
And user clicks save button

Examples:
| folder |
| research-epos-msl-0 |


Scenario Outline: Delete metadata
Given user researcher is logged in
And module "research" is shown
Expand All @@ -45,8 +66,9 @@ Feature: Meta UI
Then metadata is deleted from folder

Examples:
| folder |
| research-initial |
| folder |
| research-initial |
| research-epos-msl-0 |


Scenario Outline: Check person identifier functionality in metadata form
Expand Down
14 changes: 14 additions & 0 deletions tests/step_defs/ui/test_ui_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
then,
when,
)
from selenium.webdriver.common.keys import Keys

scenarios('../../features/ui/ui_meta.feature')

Expand All @@ -31,6 +32,19 @@ def ui_metadata_fill(browser):
input.fill('The quick brown fox jumps over the lazy dog')


@when(parsers.parse('user selects keyword "{keyword}"'))
def ui_metadata_select_keyword(browser, keyword):
browser.find_by_css('.ant-select').click()
active_web_el = browser.switch_to.active_element
active_web_el.send_keys(keyword)
active_web_el.send_keys(Keys.ENTER)


@when('user clears keyword selector')
def ui_metadata_clear_hierarchal_keywords(browser):
browser.find_by_css('.ant-select-clear').click()


@when('users checks person identifier field in metadata form')
def ui_metadata_check_person_id_field(browser):
# Find the fieldset for the first 'Person identifier'.
Expand Down
Loading
Loading