1
|
<RESOURCE_PROFILE>
|
2
|
<HEADER>
|
3
|
<RESOURCE_IDENTIFIER value="b4ac3d3d-419d-4312-b243-c14d768bd766_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
|
4
|
<RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
|
5
|
<RESOURCE_KIND value="TransformationRuleDSResources"/>
|
6
|
<RESOURCE_URI value=""/>
|
7
|
<DATE_OF_CREATION value="2021-02-02T16:42:14+00:00"/>
|
8
|
</HEADER>
|
9
|
<BODY>
|
10
|
<CONFIGURATION>
|
11
|
<IMPORTED/>
|
12
|
<SCRIPT>
|
13
|
<TITLE>UKRI to DB</TITLE>
|
14
|
<CODE>
|
15
|
<![CDATA[
|
16
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
17
|
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:per="http://gtr.ukri.org/gtr/api/person" exclude-result-prefixes="xs" version="2.0">
|
18
|
|
19
|
<xsl:param name="varDataSourceId"/>
|
20
|
<xsl:variable name="namespacePrefix" select="string('ukri________')"/>
|
21
|
|
22
|
<xsl:variable name="dateFormat" select="string('yyyy-MM-dd')"/>
|
23
|
<xsl:variable name="funderID" select="concat($namespacePrefix, '::UKRI')"/>
|
24
|
|
25
|
<xsl:template match="/">
|
26
|
<record>
|
27
|
<xsl:copy-of select=".//*[local-name() = 'header']"/>
|
28
|
<metadata>
|
29
|
<ROWS>
|
30
|
<xsl:variable name="projectCode"
|
31
|
select="//*[local-name() = 'identifier' and ./@*[local-name() = 'type' and . = 'RCUK']]"/>
|
32
|
<xsl:variable name="projectId"
|
33
|
select="concat($namespacePrefix, '::', $projectCode)"/>
|
34
|
|
35
|
<xsl:variable name="sDate"
|
36
|
select=".//*[local-name() = 'fund']/*[local-name() = 'start']"/>
|
37
|
<xsl:variable name="eDate"
|
38
|
select=".//*[local-name() = 'fund']/*[local-name() = 'end']"/>
|
39
|
<xsl:variable name="startDate">
|
40
|
<xsl:choose>
|
41
|
<xsl:when test="contains($sDate, '+')">
|
42
|
<xsl:value-of select="substring-before($sDate, '+')"/>
|
43
|
</xsl:when>
|
44
|
<xsl:when test="contains($sDate, 'Z')">
|
45
|
<xsl:value-of select="substring-before($sDate, 'Z')"/>
|
46
|
</xsl:when>
|
47
|
<xsl:otherwise>
|
48
|
<xsl:value-of select="$sDate"/>
|
49
|
</xsl:otherwise>
|
50
|
</xsl:choose>
|
51
|
</xsl:variable>
|
52
|
<xsl:variable name="endDate">
|
53
|
<xsl:choose>
|
54
|
<xsl:when test="contains($eDate, '+')">
|
55
|
<xsl:value-of select="substring-before($eDate, '+')"/>
|
56
|
</xsl:when>
|
57
|
<xsl:when test="contains($eDate, 'Z')">
|
58
|
<xsl:value-of select="substring-before($eDate, 'Z')"/>
|
59
|
</xsl:when>
|
60
|
<xsl:otherwise>
|
61
|
<xsl:value-of select="$eDate"/>
|
62
|
</xsl:otherwise>
|
63
|
</xsl:choose>
|
64
|
</xsl:variable>
|
65
|
<xsl:variable name="funding" select=".//*[local-name() = 'funder']/name"/>
|
66
|
<xsl:variable name="fundingId">
|
67
|
<xsl:choose>
|
68
|
<xsl:when test="string-length($funding) > 0">
|
69
|
<xsl:value-of select="concat($funderID, '::', .//*[local-name() = 'funder']/name)"/>
|
70
|
</xsl:when>
|
71
|
<xsl:otherwise>
|
72
|
<xsl:value-of select="$funderID"/>
|
73
|
</xsl:otherwise>
|
74
|
</xsl:choose>
|
75
|
</xsl:variable>
|
76
|
|
77
|
<ROW table="projects">
|
78
|
<FIELD name="_dnet_resource_identifier_">
|
79
|
<xsl:value-of select="$projectId"/>
|
80
|
</FIELD>
|
81
|
<FIELD name="id">
|
82
|
<xsl:value-of select="$projectId"/>
|
83
|
</FIELD>
|
84
|
<FIELD name="code">
|
85
|
<xsl:value-of select="$projectCode"/>
|
86
|
</FIELD>
|
87
|
<FIELD name="title">
|
88
|
<xsl:value-of select=".//*[local-name() = 'title']"/>
|
89
|
</FIELD>
|
90
|
<FIELD name="startdate" type="date" format="{$dateFormat}">
|
91
|
<xsl:value-of select="$startDate"/>
|
92
|
</FIELD>
|
93
|
<FIELD name="enddate" type="date" format="{$dateFormat}">
|
94
|
<xsl:value-of select="$endDate"/>
|
95
|
</FIELD>
|
96
|
<FIELD name="collectedfrom">
|
97
|
<xsl:value-of select="$varDataSourceId"/>
|
98
|
</FIELD>
|
99
|
<FIELD name="provenanceactionclass"
|
100
|
>sysimport:crosswalk:entityregistry</FIELD>
|
101
|
<FIELD name="fundedamount" type="float">
|
102
|
<xsl:value-of
|
103
|
select=".//*[local-name() = 'valuePounds']/@*[local-name() = 'amount']"
|
104
|
/>
|
105
|
</FIELD>
|
106
|
<FIELD name="currency">
|
107
|
<xsl:value-of
|
108
|
select=".//*[local-name() = 'valuePounds']/@*[local-name() = 'currencyCode']"
|
109
|
/>
|
110
|
</FIELD>
|
111
|
|
112
|
<FIELD name="summary">
|
113
|
<xsl:value-of
|
114
|
select=".//*[local-name() = 'abstractText']"
|
115
|
/>
|
116
|
</FIELD>
|
117
|
|
118
|
<xsl:variable name="principalInvestigators">
|
119
|
<xsl:apply-templates select=".//*[local-name() = 'person']"/>
|
120
|
</xsl:variable>
|
121
|
|
122
|
<xsl:if test="string-length($principalInvestigators) &gt; 0">
|
123
|
<FIELD name="contactfullname">
|
124
|
<xsl:value-of select="$principalInvestigators"/>
|
125
|
</FIELD>
|
126
|
</xsl:if>
|
127
|
<FIELD name="lastupdate" type="date">
|
128
|
<xsl:value-of select="current-dateTime()"/>
|
129
|
</FIELD>
|
130
|
</ROW>
|
131
|
|
132
|
<ROW table="project_fundingpath">
|
133
|
<FIELD name="_dnet_resource_identifier_">
|
134
|
<xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
|
135
|
</FIELD>
|
136
|
<FIELD name="funding">
|
137
|
<xsl:value-of select="$fundingId"/>
|
138
|
</FIELD>
|
139
|
<FIELD name="project">
|
140
|
<xsl:value-of select="$projectId"/>
|
141
|
</FIELD>
|
142
|
<FIELD name="startdate" type="date" format="{$dateFormat}">
|
143
|
<xsl:value-of select="$startDate"/>
|
144
|
</FIELD>
|
145
|
<FIELD name="enddate" type="date" format="{$dateFormat}">
|
146
|
<xsl:value-of select="$endDate"/>
|
147
|
</FIELD>
|
148
|
</ROW>
|
149
|
|
150
|
<xsl:for-each select=".//pp-org">
|
151
|
<xsl:variable name="organizationId"
|
152
|
select="concat($namespacePrefix, '::', normalize-space(./id))"/>
|
153
|
<xsl:variable name="country" select="./country"/>
|
154
|
<ROW table="dsm_organizations">
|
155
|
<FIELD name="_dnet_resource_identifier_">
|
156
|
<xsl:value-of select="$organizationId"/>
|
157
|
</FIELD>
|
158
|
<FIELD name="id">
|
159
|
<xsl:value-of select="$organizationId"/>
|
160
|
</FIELD>
|
161
|
<FIELD name="legalname">
|
162
|
<xsl:value-of select="./name"/>
|
163
|
</FIELD>
|
164
|
|
165
|
<xsl:if test="string-length($country) &gt; 0">
|
166
|
<FIELD name="country">
|
167
|
<xsl:value-of select="$country"/>
|
168
|
</FIELD>
|
169
|
</xsl:if>
|
170
|
|
171
|
<FIELD name="collectedfrom">
|
172
|
<xsl:value-of select="$varDataSourceId"/>
|
173
|
</FIELD>
|
174
|
<FIELD name="provenanceaction"
|
175
|
>sysimport:crosswalk:entityregistry</FIELD>
|
176
|
<FIELD name="lastupdate" type="date">
|
177
|
<xsl:value-of select="current-dateTime()"/>
|
178
|
</FIELD>
|
179
|
</ROW>
|
180
|
<ROW table="project_organization">
|
181
|
<FIELD name="_dnet_resource_identifier_">
|
182
|
<xsl:value-of select='concat($projectId, "@@", $organizationId)'/>
|
183
|
</FIELD>
|
184
|
<FIELD name="project">
|
185
|
<xsl:value-of select="$projectId"/>
|
186
|
</FIELD>
|
187
|
<FIELD name="resporganization">
|
188
|
<xsl:value-of select="$organizationId"/>
|
189
|
</FIELD>
|
190
|
|
191
|
<FIELD name="semanticclass">participant</FIELD>
|
192
|
|
193
|
</ROW>
|
194
|
|
195
|
</xsl:for-each>
|
196
|
|
197
|
<xsl:variable name="leadOrgId"
|
198
|
select="concat($namespacePrefix, '::', normalize-space(.//ld-org/id))"/>
|
199
|
<ROW table="dsm_organizations">
|
200
|
<FIELD name="_dnet_resource_identifier_">
|
201
|
<xsl:value-of select="$leadOrgId"/>
|
202
|
</FIELD>
|
203
|
<FIELD name="id">
|
204
|
<xsl:value-of select="$leadOrgId"/>
|
205
|
</FIELD>
|
206
|
<FIELD name="legalname">
|
207
|
<xsl:value-of select=".//ld-org/name"/>
|
208
|
</FIELD>
|
209
|
<xsl:variable name="country" select=".//ld-org/country"/>
|
210
|
<xsl:if test="string-length($country) &gt; 0">
|
211
|
<FIELD name="country">
|
212
|
<xsl:value-of select="$country"/>
|
213
|
</FIELD>
|
214
|
</xsl:if>
|
215
|
|
216
|
<FIELD name="collectedfrom">
|
217
|
<xsl:value-of select="$varDataSourceId"/>
|
218
|
</FIELD>
|
219
|
<FIELD name="provenanceAction">sysimport:crosswalk:entityregistry</FIELD>
|
220
|
</ROW>
|
221
|
|
222
|
<ROW table="project_organization">
|
223
|
<FIELD name="_dnet_resource_identifier_">
|
224
|
<xsl:value-of select='concat($projectId, "@@", $leadOrgId)'/>
|
225
|
</FIELD>
|
226
|
<FIELD name="project">
|
227
|
<xsl:value-of select="$projectId"/>
|
228
|
</FIELD>
|
229
|
<FIELD name="resporganization">
|
230
|
<xsl:value-of select="$leadOrgId"/>
|
231
|
</FIELD>
|
232
|
<FIELD name="participantnumber" type="int">1</FIELD>
|
233
|
<FIELD name="semanticclass">coordinator</FIELD>
|
234
|
</ROW>
|
235
|
|
236
|
</ROWS>
|
237
|
</metadata>
|
238
|
</record>
|
239
|
</xsl:template>
|
240
|
|
241
|
<xsl:template match="per:person">
|
242
|
<xsl:variable name="personSurname"
|
243
|
select="normalize-space(.//*[local-name() = 'surname'])"/>
|
244
|
<xsl:variable name="personFirstName"
|
245
|
select="normalize-space(.//*[local-name() = 'firstName'])"/>
|
246
|
<xsl:variable name="contactfullname">
|
247
|
<xsl:choose>
|
248
|
<xsl:when
|
249
|
test="string-length($personFirstName) &gt; 0 and string-length($personSurname) &gt; 0">
|
250
|
<xsl:value-of
|
251
|
select="normalize-space(concat($personSurname, ', ', $personFirstName))"
|
252
|
/>
|
253
|
</xsl:when>
|
254
|
<xsl:when test="string-length($personFirstName) &gt; 0">
|
255
|
<xsl:value-of select="$personFirstName"/>
|
256
|
</xsl:when>
|
257
|
<xsl:when test="string-length($personSurname) &gt; 0">
|
258
|
<xsl:value-of select="$personSurname"/>
|
259
|
</xsl:when>
|
260
|
<xsl:otherwise>
|
261
|
<xsl:value-of select="''"/>
|
262
|
</xsl:otherwise>
|
263
|
</xsl:choose>
|
264
|
</xsl:variable>
|
265
|
<xsl:value-of select="concat($contactfullname,';')"/>
|
266
|
</xsl:template>
|
267
|
</xsl:stylesheet>
|
268
|
]]>
|
269
|
|
270
|
</CODE>
|
271
|
</SCRIPT>
|
272
|
</CONFIGURATION>
|
273
|
<STATUS/>
|
274
|
<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
|
275
|
</BODY>
|
276
|
</RESOURCE_PROFILE>
|