Skip to content

Commit

Permalink
Merge pull request #19 from nfdi4health/feat/dv-permalinks
Browse files Browse the repository at this point in the history
feat: Permalinks in Dataverse
  • Loading branch information
johannes-darms authored Aug 29, 2024
2 parents 92cc88d + d52d70d commit 4f4e7e9
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 3 deletions.
47 changes: 47 additions & 0 deletions k8s/dataverse/persona/nfdi4health/generate-permalink.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-- A script for creating, through a database stored procedure, sequential
-- 8 character identifiers from a base36 representation of current timestamp.
-- Adapted from: https://guides.dataverse.org/en/latest/_downloads/772201110a1c1b429e7c3336b6e9d36d/identifier_from_timestamp.sql

CREATE OR REPLACE FUNCTION base36_encode(
IN digits bigint, IN min_width int = 0)
RETURNS varchar AS $$
DECLARE
chars char[];
ret varchar;
val bigint;
BEGIN
chars := ARRAY[
'0','1','2','3','4','5','6','7','8','9',
'A','B','C','D','E','F','G','H','I','J',
'K','L','M','N','O','P','Q','R','S','T',
'U','V','W','X','Y','Z'];
val := digits;
ret := '';
IF val < 0 THEN
val := val * -1;
END IF;
WHILE val != 0 LOOP
ret := chars[(val % 36)+1] || ret;
val := val / 36;
END LOOP;

IF min_width > 0 AND char_length(ret) < min_width THEN
ret := lpad(ret, min_width, '0');
END IF;

RETURN ret;
END;
$$ LANGUAGE plpgsql IMMUTABLE;


CREATE OR REPLACE FUNCTION generateIdentifierFromStoredProcedure()
RETURNS varchar AS $$
DECLARE
curr_time_msec bigint;
identifier varchar;
BEGIN
curr_time_msec := extract(epoch from now())*1000;
identifier := base36_encode(curr_time_msec);
RETURN identifier;
END;
$$ LANGUAGE plpgsql IMMUTABLE;
4 changes: 2 additions & 2 deletions k8s/dataverse/persona/nfdi4health/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ echo "# hide progress meter
# fail script on server error
--fail-with-body" > ~/.curlrc

echo "Setting DOI provider to FAKE"
curl -s -H "X-Dataverse-key:$API_TOKEN" -X PUT -d FAKE $DATAVERSE_URL/api/admin/settings/:DoiProvider
echo "Configuring PID permalink generator function"
PGPASSWORD=$DATAVERSE_DB_PASSWORD psql -h $DATAVERSE_DB_HOST -U $DATAVERSE_DB_USER < /scripts/bootstrap/nfdi4health/generate-permalink.sql
echo

echo "Setting superuser status"
Expand Down
12 changes: 12 additions & 0 deletions k8s/dataverse/templates/dataverse-baker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ spec:
value: "/roles"
- name: USERS_PATH
value: "/users"
- name: DATAVERSE_DB_HOST
value: "{{ .Release.Name }}-dataverse-postgres-pooler"
- name: DATAVERSE_DB_PASSWORD
valueFrom:
secretKeyRef:
name: dataverse.{{ .Release.Name }}-dataverse-postgres.credentials.postgresql.acid.zalan.do
key: password
- name: DATAVERSE_DB_USER
valueFrom:
secretKeyRef:
name: dataverse.{{ .Release.Name }}-dataverse-postgres.credentials.postgresql.acid.zalan.do
key: username
volumeMounts:
- name: script
mountPath: "/scripts/bootstrap/nfdi4health"
Expand Down
100 changes: 99 additions & 1 deletion k8s/dataverse/templates/dataverse-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spec:
- name: DATAVERSE_DB_VALIDATION_CLASSNAME
value: "org.glassfish.api.jdbc.validation.PostgresConnectionValidation"
- name: DATAVERSE_PID_PROVIDERS
value: "fake"
value: "fake,csh,ctgov,euctr,per,isrctn,ctri,jprn,actrn,drks"
- name: DATAVERSE_PID_DEFAULT_PROVIDER
value: "fake"
- name: DATAVERSE_PID_FAKE_TYPE
Expand All @@ -106,6 +106,104 @@ spec:
value: "FK2/"
- name: DATAVERSE_PID_FAKE_AUTHORITY
value: "10.5072"
- name: DATAVERSE_PID_CSH_TYPE
value: "perma"
- name: DATAVERSE_PID_CSH_LABEL
value: "Permalink Provider"
- name: DATAVERSE_PID_CSH_AUTHORITY
value: {{.Values.dataverse.pid.permalink.authority}}
- name: DATAVERSE_PID_CSH_SHOULDER
value: {{.Values.dataverse.pid.permalink.shoulder}}
- name: DATAVERSE_PID_CSH_BASE_URL
value: {{.Values.dataverse.pid.permalink.base_url}}
- name: DATAVERSE_PID_CSH_SEPARATOR
value: {{.Values.dataverse.pid.permalink.separator}}
- name: DATAVERSE_PID_CSH_IDENTIFIER_GENERATION_STYLE
value: "storedProcGenerated"
- name: DATAVERSE_PID_CTGOV_TYPE
value: "perma"
- name: DATAVERSE_PID_CTGOV_LABEL
value: "CT.gov Permalink Provider"
- name: DATAVERSE_PID_CTGOV_AUTHORITY
value: "NCT"
- name: DATAVERSE_PID_CTGOV_SHOULDER
value: ""
- name: DATAVERSE_PID_CTGOV_PERMALINK_BASE_URL
value: "https://clinicaltrials.gov/study/"
- name: DATAVERSE_PID_EUCTR_TYPE
value: "perma"
- name: DATAVERSE_PID_EUCTR_LABEL
value: "ICTRP EUCTR Permalink Provider"
- name: DATAVERSE_PID_EUCTR_AUTHORITY
value: "EUCTR"
- name: DATAVERSE_PID_EUCTR_SHOULDER
value: ""
- name: DATAVERSE_PID_EUCTR_PERMALINK_BASE_URL
value: "https://trialsearch.who.int/Trial2.aspx?TrialID="
- name: DATAVERSE_PID_PER_TYPE
value: "perma"
- name: DATAVERSE_PID_PER_LABEL
value: "ICTRP PER Permalink Provider"
- name: DATAVERSE_PID_PER_AUTHORITY
value: "PER"
- name: DATAVERSE_PID_PER_SHOULDER
value: ""
- name: DATAVERSE_PID_PER_PERMALINK_BASE_URL
value: "https://trialsearch.who.int/Trial2.aspx?TrialID="
- name: DATAVERSE_PID_PER_PERMALINK_SEPARATOR
value: "-"
- name: DATAVERSE_PID_ISRCTN_TYPE
value: "perma"
- name: DATAVERSE_PID_ISRCTN_LABEL
value: "ICTRP ISRCTN Permalink Provider"
- name: DATAVERSE_PID_ISRCTN_AUTHORITY
value: "ISRCTN"
- name: DATAVERSE_PID_ISRCTN_SHOULDER
value: ""
- name: DATAVERSE_PID_ISRCTN_PERMALINK_BASE_URL
value: "https://trialsearch.who.int/Trial2.aspx?TrialID="
- name: DATAVERSE_PID_CTRI_TYPE
value: "perma"
- name: DATAVERSE_PID_CTRI_LABEL
value: "ICTRP CTRI Permalink Provider"
- name: DATAVERSE_PID_CTRI_AUTHORITY
value: "CTRI"
- name: DATAVERSE_PID_CTRI_SHOULDER
value: ""
- name: DATAVERSE_PID_CTRI_PERMALINK_BASE_URL
value: "https://trialsearch.who.int/Trial2.aspx?TrialID="
- name: DATAVERSE_PID_CTRI_PERMALINK_SEPARATOR
value: "/"
- name: DATAVERSE_PID_JPRN_TYPE
value: "perma"
- name: DATAVERSE_PID_JPRN_LABEL
value: "ICTRP JPRN Permalink Provider"
- name: DATAVERSE_PID_JPRN_AUTHORITY
value: "JPRN-jRCT"
- name: DATAVERSE_PID_JPRN_SHOULDER
value: ""
- name: DATAVERSE_PID_JPRN_PERMALINK_BASE_URL
value: "https://trialsearch.who.int/Trial2.aspx?TrialID="
- name: DATAVERSE_PID_ACTRN_TYPE
value: "perma"
- name: DATAVERSE_PID_ACTRN_LABEL
value: "ICTRP ACTRN Permalink Provider"
- name: DATAVERSE_PID_ACTRN_AUTHORITY
value: "ACTRN"
- name: DATAVERSE_PID_ACTRN_SHOULDER
value: ""
- name: DATAVERSE_PID_ACTRN_PERMALINK_BASE_URL
value: "https://trialsearch.who.int/Trial2.aspx?TrialID="
- name: DATAVERSE_PID_DRKS_TYPE
value: "perma"
- name: DATAVERSE_PID_DRKS_LABEL
value: "DRKS Permalink Provider"
- name: DATAVERSE_PID_DRKS_AUTHORITY
value: "DRKS"
- name: DATAVERSE_PID_DRKS_SHOULDER
value: ""
- name: DATAVERSE_PID_DRKS_PERMALINK_BASE_URL
value: "https://drks.de/search/de/trial/"
- name: DATAVERSE_DB_CONNECTION_VALIDATION_METHOD
value: "custom-validation"
# hack for https://dataverse.zulipchat.com/#narrow/stream/375812-containers/topic/MPC.20profile.20problem
Expand Down
6 changes: 6 additions & 0 deletions k8s/dataverse/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ dataverse:
memory: "4Gi"
requests:
memory: "1Gi"
pid:
permalink:
authority:
shoulder:
base_url:
separator:
images:
backend: ghcr.io/nfdi4health/csh-ui/dataverse:6.2
configbaker: ghcr.io/nfdi4health/csh-ui/dataverse-baker:6.2

0 comments on commit 4f4e7e9

Please sign in to comment.