[Library & Explore | develop]: Added software heritage as pid for research products.

1. environments/: Added in all environments, property: swhURL: "https://archive.softwareheritage.org/".
2. env-properties.ts: Added property swhURL?: string;
3. string-utils.class.ts: Added method "isValidSwhId()" and swhid in checks and definitions.
4. resultLandingInfo.ts: Added swhid in accepted types of interface Id.
5. resultLanding.component.ts: Added check for swhid in "getReferenceIdName()" and "getReferenceUrl()".
6. parsingFunctions.class.ts: Added pid[i].classid == "swhid" check in "parseIdentifiers()".
7. showIdentifiers.component.ts: Added "swhid" in display of pids.
This commit is contained in:
Konstantina Galouni 2023-10-06 12:22:00 +03:00
parent 1c5a0b22a8
commit 445441572d
6 changed files with 23 additions and 6 deletions

View File

@ -514,7 +514,8 @@ export class ParsingFunctions {
let identifiers = new Map<string, string[]>();
if (pid.hasOwnProperty("classid") && pid['classid'] != "") {
if (pid.classid == "doi" || pid.classid == "pmc" || pid.classid == "handle" || pid.classid == "pmid" || pid.classid == "re3data") {
if (pid.classid == "doi" || pid.classid == "pmc" || pid.classid == "handle" || pid.classid == "pmid" || pid.classid == "re3data"
|| pid.classid == "swhid") {
if (!identifiers.has(pid.classid)) {
identifiers.set(pid.classid, new Array<string>());
}
@ -522,7 +523,8 @@ export class ParsingFunctions {
}
} else {
for (let i = 0; i < pid.length; i++) {
if (pid[i].classid == "doi" || pid[i].classid == "pmc" || pid[i].classid == "handle" || pid[i].classid == "pmid" || pid[i].classid == "re3data") {
if (pid[i].classid == "doi" || pid[i].classid == "pmc" || pid[i].classid == "handle" || pid[i].classid == "pmid" || pid[i].classid == "re3data"
|| pid[i].classid == "swhid") {
if (!identifiers.has(pid[i].classid)) {
identifiers.set(pid[i].classid, new Array<string>());
}

View File

@ -26,7 +26,7 @@ import {properties} from "../../../../environments/environment";
<span class="uk-text-meta uk-text-small" [class.uk-text-uppercase]="key != 're3data'">{{key}}: </span>
<span [class.uk-margin-small-left]="modal">
<ng-container *ngFor="let item of identifiers.get(key) let j=index">
<a *ngIf="key == 'doi' || key == 'pmc' || key == 'pmid' || key == 'handle' || key == 're3data'"
<a *ngIf="key == 'doi' || key == 'pmc' || key == 'pmid' || key == 'handle' || key == 're3data' || key == 'swhid'"
[href]="getUrl(key) + item" target="_blank" class="uk-display-inline-block custom-external">
{{item}}
</a>
@ -124,6 +124,8 @@ export class ShowIdentifiersComponent implements AfterViewInit {
return properties.handleURL;
} else if(key == "re3data") {
return properties.r3DataURL;
} else if(key == "swhid") {
return properties.swhURL;
}
}

View File

@ -825,6 +825,8 @@ export class ResultLandingComponent {
return this.properties.pmidURL + id.value;
} else if (id.type === "handle") {
return this.properties.handleURL + id.value;
} else if (id.type === "swhid") {
return this.properties.swhURL + id.value;
} else {
return null;
}
@ -839,6 +841,8 @@ export class ResultLandingComponent {
return 'PubMed';
} else if (id.type === "handle") {
return 'Handle.NET';
} else if(id.type == "swhid") {
return 'Software Heritage';
} else {
return null;
}

View File

@ -8,7 +8,7 @@ import {
} from "../result-preview/result-preview";
export interface Id {
type: "pmid" | "doi" | "pmc" | "handle" | "openaire";
type: "pmid" | "doi" | "pmc" | "handle" | "openaire" | "swhid";
value: string;
trust: number
}

View File

@ -44,6 +44,7 @@ export interface EnvProperties {
cordisURL?: string;
openDoarURL?: string;
r3DataURL?: string;
swhURL?: string;
fairSharingURL?: string,
eoscMarketplaceURL?: string,
sherpaURL?: string;

View File

@ -149,7 +149,7 @@ export class DOI {
}
export class Identifier {
class: "doi" | "pmc" | "pmid" | "handle" | "ORCID" | "re3data" = null;
class: "doi" | "pmc" | "pmid" | "handle" | "ORCID" | "re3data" | "swhid" = null;
id: string;
public static getDOIsFromString(str: string): string[] {
@ -202,13 +202,15 @@ export class Identifier {
return {"class": "handle", "id": pid};
} else if (Identifier.isValidRe3Data(pid)) {
return {"class": "re3data", "id": pid};
} else if (Identifier.isValidSwhId(pid)) {
return {"class": "swhid", "id": pid};
}
//set it as a doi, to catch the case that doi has not valid format
return (strict?null:{"class": "doi", "id": pid});
}
public static getPIDFromIdentifiers(identifiers: Map<string, string[]>): Identifier {
let classes:string [] = ["doi", "handle", "pmc", "pmid", "re3data"];
let classes:string [] = ["doi", "handle", "pmc", "pmid", "re3data", "swhid"];
if(identifiers) {
for (let cl of classes) {
if (identifiers.get(cl)) {
@ -257,6 +259,12 @@ export class Identifier {
let exp = /(r3d[1-9]\d{0,8})/g;
return str.match(exp) != null;
}
public static isValidSwhId(str: string): boolean {
// let exp = /swh:1:(snp|rel|rev|dir|cnt):[0-9a-f]{40}/g;
let exp = /swh:1:snp:[0-9a-f]{40}/g;
return str.match(exp) != null;
}
}
export class StringUtils {