1
|
SELECT d.id AS datasourceid,
|
2
|
d.officialname AS officialname,
|
3
|
d.englishname AS englishname,
|
4
|
|
5
|
CASE
|
6
|
WHEN (array_agg( DISTINCT tcc.compliance :: TEXT ) @> ARRAY ['driver', 'openaire2.0'])
|
7
|
THEN
|
8
|
'driver-openaire2.0@@@OpenAIRE 2.0+ (DRIVER OA, EC funding)@@@dnet:datasourceCompatibilityLevel@@@dnet:datasourceCompatibilityLevel'
|
9
|
WHEN (array_agg( DISTINCT tcc.compliance :: TEXT ) @> ARRAY ['driver'])
|
10
|
THEN
|
11
|
'driver@@@OpenAIRE Basic (DRIVER OA)@@@dnet:datasourceCompatibilityLevel@@@dnet:datasourceCompatibilityLevel'
|
12
|
WHEN (array_agg( DISTINCT tcc.compliance :: TEXT ) @> ARRAY ['openaire2.0'])
|
13
|
THEN
|
14
|
'openaire2.0@@@OpenAIRE 2.0 (EC funding)@@@dnet:datasourceCompatibilityLevel@@@dnet:datasourceCompatibilityLevel'
|
15
|
WHEN (array_agg( DISTINCT tcc.compliance :: TEXT ) @> ARRAY ['openaire3.0'])
|
16
|
THEN
|
17
|
'openaire3.0@@@OpenAIRE 3.0 (OA, funding)@@@dnet:datasourceCompatibilityLevel@@@dnet:datasourceCompatibilityLevel'
|
18
|
WHEN (array_agg( DISTINCT tcc.compliance :: TEXT ) @> ARRAY ['openaire2.0_data'])
|
19
|
THEN
|
20
|
'openaire2.0_data@@@OpenAIRE Data (funded, referenced datasets)@@@dnet:datasourceCompatibilityLevel@@@dnet:datasourceCompatibilityLevel'
|
21
|
WHEN (array_agg( DISTINCT tcc.compliance :: TEXT ) @> ARRAY ['native'])
|
22
|
THEN
|
23
|
'native@@@proprietary@@@dnet:datasourceCompatibilityLevel@@@dnet:datasourceCompatibilityLevel'
|
24
|
WHEN (array_agg( DISTINCT tcc.compliance :: TEXT ) @> ARRAY ['hostedBy'])
|
25
|
THEN
|
26
|
'hostedBy@@@collected from a compatible aggregator@@@dnet:datasourceCompatibilityLevel@@@dnet:datasourceCompatibilityLevel'
|
27
|
WHEN (array_agg( DISTINCT tcc.compliance :: TEXT ) @> ARRAY ['notCompatible'])
|
28
|
THEN
|
29
|
'notCompatible@@@under validation@@@dnet:datasourceCompatibilityLevel@@@dnet:datasourceCompatibilityLevel'
|
30
|
ELSE
|
31
|
'UNKNOWN@@@not available@@@dnet:datasourceCompatibilityLevel@@@dnet:datasourceCompatibilityLevel'
|
32
|
END AS openairecompatibility,
|
33
|
|
34
|
d.websiteurl AS websiteurl,
|
35
|
d.logourl AS logourl,
|
36
|
d.contactemail AS contactemail,
|
37
|
array_agg( DISTINCT CASE
|
38
|
WHEN apc.param='baseUrl' and api.protocolclass='oai' THEN
|
39
|
CASE WHEN COALESCE(apc.edited, '') = '' THEN apc.original ELSE apc.edited END
|
40
|
ELSE
|
41
|
NULL
|
42
|
END ) AS accessinfopackage, -- we need baseUrl param only -when available-, but we can not use WHERE clause on apc.param, otherwise we exclude datasources without a baseUrl param and the returned rows are less than we expect.
|
43
|
d.latitude as latitude,
|
44
|
d.longitude as longitude,
|
45
|
d.namespaceprefix as namespaceprefix,
|
46
|
d.od_numberofitems as odnumberofitems,
|
47
|
d.od_numberofitemsdate as odnumberofitemsdate,
|
48
|
array_agg(DISTINCT s.name || '###' || sc.code || '@@@' || sc.name || '@@@' || ss.code || '@@@' || ss.name) as subjects,
|
49
|
d.description as description,
|
50
|
d.od_policies as odpolicies,
|
51
|
ARRAY(select trim(s) from unnest(string_to_array(d.od_languages, ',')) as s) as odlanguages,
|
52
|
ARRAY(select trim(s) from unnest(string_to_array(d.od_contenttypes, '-')) as s) as odcontenttypes,
|
53
|
d.inferred as inferred,
|
54
|
d.deletedbyinference as deletedbyinference,
|
55
|
d.trust as trust,
|
56
|
d.inferenceprovenance as inferenceprovenance,
|
57
|
d.dateofcollection as dateofcollection,
|
58
|
d.dateofvalidation as dateofvalidation,
|
59
|
|
60
|
-- re3data fields
|
61
|
d.releasestartdate as releasestartdate,
|
62
|
d.releaseenddate as releaseenddate,
|
63
|
d.missionstatementurl as missionstatementurl,
|
64
|
d.dataprovider as dataprovider,
|
65
|
d.serviceprovider as serviceprovider,
|
66
|
d.databaseaccesstype as databaseaccesstype,
|
67
|
d.datauploadtype as datauploadtype,
|
68
|
d.databaseaccessrestriction as databaseaccessrestriction,
|
69
|
d.datauploadrestriction as datauploadrestriction,
|
70
|
d.versioning as versioning,
|
71
|
d.citationguidelineurl as citationguidelineurl,
|
72
|
d.qualitymanagementkind as qualitymanagementkind,
|
73
|
d.pidsystems as pidsystems,
|
74
|
d.certificates as certificates,
|
75
|
array_agg(DISTINCT p.name || '&&&' || p.url) as policies,
|
76
|
-- end of re3data fields
|
77
|
|
78
|
dc.id as collectedfromid,
|
79
|
dc.officialname as collectedfromname,
|
80
|
|
81
|
tc.code || '@@@' || tc.name || '@@@' || ts.code || '@@@' || ts.name as datasourcetype,
|
82
|
pac.code || '@@@' || pac.name || '@@@' || pas.code || '@@@' || pas.name as provenanceaction,
|
83
|
|
84
|
array_agg(DISTINCT i.pid || '###' || idc.code || '@@@' || idc.name || '@@@' || ids.code || '@@@' || ids.name) as pid
|
85
|
|
86
|
|
87
|
FROM datasources d
|
88
|
left outer join class tc on (tc.code = d.datasourceclass)
|
89
|
left outer join scheme ts on (ts.code = d.datasourcescheme)
|
90
|
|
91
|
left outer join class pac on (pac.code = d.provenanceactionclass)
|
92
|
left outer join scheme pas on (pas.code = d.provenanceactionscheme)
|
93
|
|
94
|
left outer join datasourcepids dps on (dps.datasource = d.id)
|
95
|
left outer join identities i on (i.pid = dps.pid)
|
96
|
|
97
|
left outer join class idc on (idc.code = i.issuertypeclass)
|
98
|
left outer join scheme ids on (ids.code = i.issuertypescheme)
|
99
|
|
100
|
left outer join datasources dc on (dc.id = d.collectedfrom)
|
101
|
left outer join api on (api.datasource = d.id)
|
102
|
left outer join apicollections apc on (apc.api = api.id)
|
103
|
|
104
|
left outer join temp_compliances tcc on (tcc.api = api.id)
|
105
|
|
106
|
left outer join datasource_subject ds on (ds.datasource = d.id)
|
107
|
left outer join subjects s on (s.id = ds.subject)
|
108
|
|
109
|
left outer join class sc on (sc.code = s.semanticclass)
|
110
|
left outer join scheme ss on (ss.code = s.semanticscheme)
|
111
|
|
112
|
left outer join datasource_policy dp on (dp.datasource = d.id)
|
113
|
left outer join policies p on (p.id = dp.policy)
|
114
|
|
115
|
-- These clauses have been commented to allow the import of all the datasource on the index
|
116
|
-- WHERE d.datasourceclass != 'entityregistry'
|
117
|
-- AND d.openairecompatibilityclass IS NOT null
|
118
|
-- AND d.openairecompatibilityclass != 'UNKNOWN'
|
119
|
-- AND d.openairecompatibilityclass != 'notCompatible'
|
120
|
|
121
|
GROUP BY
|
122
|
d.id,
|
123
|
d.officialname,
|
124
|
d.englishname,
|
125
|
d.websiteurl,
|
126
|
d.logourl,
|
127
|
d.contactemail,
|
128
|
d.namespaceprefix,
|
129
|
d.description,
|
130
|
d.od_numberofitems,
|
131
|
d.od_numberofitemsdate,
|
132
|
d.od_policies,
|
133
|
d.od_languages,
|
134
|
d.od_contenttypes,
|
135
|
d.latitude,
|
136
|
d.longitude,
|
137
|
d.inferred,
|
138
|
d.deletedbyinference,
|
139
|
d.trust,
|
140
|
d.inferenceprovenance,
|
141
|
d.dateofcollection,
|
142
|
d.dateofvalidation,
|
143
|
dc.id,
|
144
|
d.releasestartdate,
|
145
|
d.releaseenddate,
|
146
|
d.missionstatementurl,
|
147
|
d.dataprovider,
|
148
|
d.serviceprovider,
|
149
|
d.databaseaccesstype,
|
150
|
d.datauploadtype,
|
151
|
d.databaseaccessrestriction,
|
152
|
d.datauploadrestriction,
|
153
|
d.versioning,
|
154
|
d.citationguidelineurl,
|
155
|
d.qualitymanagementkind,
|
156
|
d.pidsystems,
|
157
|
d.certificates,
|
158
|
dc.officialname,
|
159
|
tc.code, tc.name, ts.code, ts.name,
|
160
|
pac.code, pac.name, pas.code, pas.name,
|
161
|
sc.code, sc.name, ss.code, ss.name
|