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

feat: syncs funding organizations and contract numbers to ESS-DIVE #426

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 15 additions & 1 deletion archive_api/service/essdive_transfer/crosswalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
import csv
import collections
import re
from io import StringIO

from typing import Dict, IO, List, Optional, TextIO, Tuple, Union
Expand Down Expand Up @@ -266,6 +267,18 @@ def dataset_transform(dataset) -> Tuple[Dict, Optional[TextIO]]:
if dataset.qaqc_method_description is not None:
measurement_technique = dataset.qaqc_method_description and [r for r in dataset.qaqc_method_description .split('\n') if r] or list()

# --- Funding Organization and Contract Numbers ---
funders = [JSONLD_FUNDER]
if dataset.funding_organizations:
# if there are line breaks, commas, or semicolons, we assume multiple funders
for f in re.split('[\n,;]', dataset.funding_organizations):
funders.append({"name": f.strip()})

# --- DOE Funding Contract Numbers --
awards = None
if dataset.doe_funding_contract_numbers:
awards = re.split('[\n,;]', dataset.doe_funding_contract_numbers)

# --- ASSIGN TO JSON-LD ----

json_ld = {
Expand All @@ -282,7 +295,8 @@ def dataset_transform(dataset) -> Tuple[Dict, Optional[TextIO]]:
"variableMeasured": variable_measured,
"license": JSONLD_LICENSE,
"spatialCoverage": spatial_coverage,
"funder": JSONLD_FUNDER,
"funder": funders,
"award": awards,
"temporalCoverage": temporal_coverage,
"editor": editor,
"provider": JSONLD_PROVIDER,
Expand Down
8 changes: 5 additions & 3 deletions archive_api/tests/essdive-transfer.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"@id": "http://dx.doi.org/10.15486/ngt/1783737",
"name": "Leaf structural and chemical traits, and BNL field campaign sample details, San Lorenzo, Panama, 2020",
"alternateName": "NGT0004",
"award": ["DE-SC0012704"],
"citation": [
"Larson, Kristine & Small, Eric & Gutmann, Ethan & Bilich, Andria & Braun, John & Zavorotny, Valery & Larson, Citation. (2008). Use of GPS receivers as a soil moisture network for water cycle studies. Geophysical Research Letters - GEOPHYS RES LETT. 35. 10.1029/2008GL036013. Solander et al.: The pantropical response of soil moisture to El Niño, Hydrol. Earth Syst. Sci., 24, 2303–2322, https://doi.org/10.5194/hess-24-2303-2020, 2020.",
"Additional information about citations:",
Expand Down Expand Up @@ -56,9 +57,10 @@
]
}
],
"funder": {
"name": "U.S. DOE > Office of Science > Biological and Environmental Research (BER)"
},
"funder":
[{"name": "U.S. DOE > Office of Science > Biological and Environmental Research (BER)"},
{"name": "U.S. Department of Energy Office of Science Office of Biological and Environmental Research"}]
,
"temporalCoverage": {
"endDate": "2020-03-13",
"startDate": "2020-01-14"
Expand Down
1 change: 1 addition & 0 deletions archive_api/tests/test_essdive_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def test_dataset_transform(celery_setup, ack_size):
dataset.acknowledgement += added_ack

jsonld, ack_fp = crosswalk.dataset_transform(dataset)
print(jsonld)

if len(dataset.description)+ack_size >= 5000:
assert ack_fp is not None
Expand Down
12 changes: 9 additions & 3 deletions ui/static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ $(document).ready(function () {
}
});

$.getJSON("static/js/metadata/dataset.json?v=20240209", function (data) {
$.getJSON("static/js/metadata/dataset.json?v=20240329", function (data) {
templates.datasets = data;
createEditForm('datasets');
});
Expand Down Expand Up @@ -1715,15 +1715,21 @@ function createEditForm(templateType) {
label += '<i class="required">*</i>';
}

var tooltip = '<b class="desc-tooltip js-tooltip" title="' + templates[templateType][param].description + '" > ?</b>';

var tooltip = '<b class="desc-tooltip js-tooltip" title="' + templates[templateType][param].tooltip + '" > ?</b>';
paramHTML.append($('<span class="js-display-name display-name"></span>').html(label + '&nbsp;&nbsp;' + tooltip));

if (templates[templateType][param].description) {
paramHTML.append($(templates[templateType][param].description));
}
switch (templates[templateType][param].type) {
case "string":
var tag = $('.js-template' + '.' + templates[templateType][param].type).clone();
if (templates[templateType][param].max_length) {
tag.attr('maxlength', templates[templateType][param].max_length);
}
if(templates[templateType][param].placeholder) {
tag.attr('placeholder', templates[templateType][param].placeholder);
}
tag.removeClass('js-template').addClass('js-input');
paramHTML.append(tag);
break;
Expand Down
Loading
Loading