-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump_to_scholix_v2api.js
64 lines (63 loc) · 2.97 KB
/
dump_to_scholix_v2api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//dump to scholix
//transforms the datadump into a scholix like format.
db.orciddump.find().forEach(function(record) {
if (record["activities-summary"]["works"]["group"] != null){
record["activities-summary"]["works"]["group"].forEach(
function(group){
if (group["external-ids"] != null && group["external-ids"]["external-id"] !=null){
group["external-ids"]["external-id"].forEach(
function(id){
//group?
}
);
}
group["work-summary"].forEach(
function(work){
if (work["external-ids"] != null && work["external-ids"]["external-id"] !=null){
work["external-ids"]["external-id"].forEach(
function(id){
var out = {};
out.link_publisher = {};
out.link_publisher.name = work.source["source-name"].value;
out.link_publisher.id = {};
if (work.source["source-orcid"]){
out.link_publisher.id.value = work.source["source-orcid"].uri;
out.link_publisher.id.type = "orcid";
}else if (work.source["source-client-id"]){
out.link_publisher.id.value = work.source["source-client-id"].uri;
out.link_publisher.id.type = "orcid-client";
}
out.link_provider = {};
out.link_provider.name = "orcid";
out.link_provider.id = {};
out.link_provider.id.type = "grid.ac";
out.link_provider.id.value = "grid.455335.1";
out.source_object = {};
if (record.person.name["credit-name"])
out.source_object.name = record.person.name["credit-name"].value;
else if (record.person.name["given-names"]){
out.source_object.name =record.person.name["given-names"].value +" "+record.person.name["family-name"].value;
}
out.source_object.id = {};
out.source_object.id.value = record["orcid-identifier"].uri;
out.source_object.id.schema = "orcid";
out.source_object.id.type = "person";
out.target_object = {};
out.target_object.name = work.title.title.value;
out.target_object.id = {};
out.target_object.id.value = id["external-id-value"];
out.target_object.id.schema = id["external-id-type"];
out.target_object.name = work.title.title.value;
out.target_object.id.type = work.type;
out.relationship_type = "relatedTo";
out._id = work["put-code"];
db.scholix.save(out);
}
);
}
}
);
}
);
}
});