Project

General

Profile

1
<RESOURCE_PROFILE>
2
	<HEADER>
3
		<RESOURCE_IDENTIFIER
4
				value="b4ac3d3d-419d-4312-b243-c14d768bd766_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
5
		<RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
6
		<RESOURCE_KIND value="TransformationRuleDSResources"/>
7
		<RESOURCE_URI value=""/>
8
		<DATE_OF_CREATION value="2018-07-31T12:24:40+00:00"/>
9
	</HEADER>
10
	<BODY>
11
		<CONFIGURATION>
12
			<IMPORTED/>
13
			<SCRIPT>
14
				<TITLE>RCUK to DB</TITLE>
15
				<CODE>
16
					<![CDATA[
17
					<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18
					                xmlns:xs="http://www.w3.org/2001/XMLSchema"
19
					                xmlns:per="http://gtr.ukri.org/gtr/api/person" exclude-result-prefixes="xs"
20
					                version="2.0">
21

    
22
						<xsl:param name="varDataSourceId"/>
23
						<xsl:variable name="namespacePrefix" select="string('rcuk________')"/>
24

    
25
						<xsl:variable name="dateFormat" select="string('yyyy-MM-dd')"/>
26
						<xsl:variable name="funderID" select="concat($namespacePrefix, '::RCUK')"/>
27

    
28
						<xsl:template match="/">
29
							<record>
30
								<xsl:copy-of select=".//*[local-name() = 'header']"/>
31
								<metadata>
32
									<ROWS>
33
										<xsl:variable name="projectCode"
34
										              select="//*[local-name() = 'identifier' and ./@*[local-name() = 'type' and . = 'RCUK']]"/>
35
										<xsl:variable name="projectId"
36
										              select="concat($namespacePrefix, '::', $projectCode)"/>
37

    
38
										<xsl:variable name="sDate"
39
										              select=".//*[local-name() = 'fund']/*[local-name() = 'start']"/>
40
										<xsl:variable name="eDate"
41
										              select=".//*[local-name() = 'fund']/*[local-name() = 'end']"/>
42
										<xsl:variable name="startDate">
43
											<xsl:choose>
44
												<xsl:when test="contains($sDate, '+')">
45
													<xsl:value-of
46
															select="substring-before($sDate, '+')"/>
47
												</xsl:when>
48
												<xsl:when test="contains($sDate, 'Z')">
49
													<xsl:value-of
50
															select="substring-before($sDate, 'Z')"/>
51
												</xsl:when>
52
												<xsl:otherwise>
53
													<xsl:value-of select="$sDate"/>
54
												</xsl:otherwise>
55
											</xsl:choose>
56
										</xsl:variable>
57
										<xsl:variable name="endDate">
58
											<xsl:choose>
59
												<xsl:when test="contains($eDate, '+')">
60
													<xsl:value-of
61
															select="substring-before($eDate, '+')"/>
62
												</xsl:when>
63
												<xsl:when test="contains($eDate, 'Z')">
64
													<xsl:value-of
65
															select="substring-before($eDate, 'Z')"/>
66
												</xsl:when>
67
												<xsl:otherwise>
68
													<xsl:value-of select="$eDate"/>
69
												</xsl:otherwise>
70
											</xsl:choose>
71
										</xsl:variable>
72
										<xsl:variable name="funding"
73
										              select=".//*[local-name() = 'funder']/name"/>
74
										<xsl:variable name="fundingId">
75
											<xsl:choose>
76
												<xsl:when test="string-length($funding) > 0">
77
													<xsl:value-of
78
															select="concat($funderID, '::', .//*[local-name() = 'funder']/name)"
79
													/>
80
												</xsl:when>
81
												<xsl:otherwise>
82
													<xsl:value-of select="$funderID"/>
83
												</xsl:otherwise>
84
											</xsl:choose>
85
										</xsl:variable>
86

    
87
										<ROW table="projects">
88
											<FIELD name="_dnet_resource_identifier_">
89
												<xsl:value-of select="$projectId"/>
90
											</FIELD>
91
											<FIELD name="id">
92
												<xsl:value-of select="$projectId"/>
93
											</FIELD>
94
											<FIELD name="code">
95
												<xsl:value-of select="$projectCode"/>
96
											</FIELD>
97
											<FIELD name="title">
98
												<xsl:value-of select=".//*[local-name() = 'title']"
99
												/>
100
											</FIELD>
101
											<FIELD name="startdate" type="date"
102
											       format="{$dateFormat}">
103
												<xsl:value-of select="$startDate"/>
104
											</FIELD>
105
											<FIELD name="enddate" type="date" format="{$dateFormat}">
106
												<xsl:value-of select="$endDate"/>
107
											</FIELD>
108
											<FIELD name="collectedfrom">
109
												<xsl:value-of select="$varDataSourceId"/>
110
											</FIELD>
111
											<FIELD name="provenanceactionclass"
112
											>sysimport:crosswalk:entityregistry</FIELD>
113
											<FIELD name="optional1">
114
												<xsl:value-of
115
														select="concat(.//*[local-name() = 'valuePounds']/@*[local-name() = 'amount'], ' ', .//*[local-name() = 'valuePounds']/@*[local-name() = 'currencyCode'])"
116
												/>
117
											</FIELD>
118
<FIELD name="fundedamount" type="float">
119
                            <xsl:value-of
120
                                select=".//*[local-name() = 'valuePounds']/@*[local-name() = 'amount']"
121
                            />
122
                        </FIELD>
123

    
124
                        <FIELD name="currency">
125
                           <xsl:value-of select=".//*[local-name() = 'valuePounds']/@*[local-name() = 'currencyCode']"/>
126
                        </FIELD>
127
                       <FIELD name="summary">
128
                           <xsl:value-of select=".//*[local-name() = 'abstractText']"/>
129
                       </FIELD>
130
											<xsl:variable name="principalInvestigators">
131
												<xsl:apply-templates
132
														select=".//*[local-name() = 'person']"/>
133
											</xsl:variable>
134

    
135
											<xsl:if
136
													test="string-length($principalInvestigators) &gt; 0">
137
												<FIELD name="contactfullname">
138
													<xsl:value-of select="$principalInvestigators"/>
139
												</FIELD>
140
											</xsl:if>
141
											<FIELD name="lastupdate" type="date">
142
												<xsl:value-of select="current-dateTime()"/>
143
											</FIELD>
144
										</ROW>
145

    
146
										<ROW table="project_fundingpath">
147
											<FIELD name="_dnet_resource_identifier_">
148
												<xsl:value-of
149
														select="concat($fundingId, '@@', $projectId)"/>
150
											</FIELD>
151
											<FIELD name="funding">
152
												<xsl:value-of select="$fundingId"/>
153
											</FIELD>
154
											<FIELD name="project">
155
												<xsl:value-of select="$projectId"/>
156
											</FIELD>
157
											<FIELD name="startdate" type="date"
158
											       format="{$dateFormat}">
159
												<xsl:value-of select="$startDate"/>
160
											</FIELD>
161
											<FIELD name="enddate" type="date" format="{$dateFormat}">
162
												<xsl:value-of select="$endDate"/>
163
											</FIELD>
164
										</ROW>
165

    
166
										<xsl:for-each select=".//pp-org">
167
											<xsl:variable name="organizationId"
168
											              select="concat($namespacePrefix, '::', normalize-space(./id))"/>
169
											<xsl:variable name="country" select="./country"/>
170
											<ROW table="dsm_organizations">
171
												<FIELD name="_dnet_resource_identifier_">
172
													<xsl:value-of select="$organizationId"/>
173
												</FIELD>
174
												<FIELD name="id">
175
													<xsl:value-of select="$organizationId"/>
176
												</FIELD>
177
												<FIELD name="legalname">
178
													<xsl:value-of select="./name"/>
179
												</FIELD>
180

    
181
												<xsl:if test="string-length($country) &gt; 0">
182
													<FIELD name="country">
183
														<xsl:value-of select="$country"/>
184
													</FIELD>
185
												</xsl:if>
186

    
187
												<FIELD name="collectedfrom">
188
													<xsl:value-of select="$varDataSourceId"/>
189
												</FIELD>
190
												<FIELD name="provenanceaction"
191
												>sysimport:crosswalk:entityregistry</FIELD>
192
												<FIELD name="lastupdate" type="date">
193
													<xsl:value-of select="current-dateTime()"/>
194
												</FIELD>
195
											</ROW>
196
											<ROW table="project_organization">
197
												<FIELD name="_dnet_resource_identifier_">
198
													<xsl:value-of
199
															select='concat($projectId, "@@", $organizationId)'
200
													/>
201
												</FIELD>
202
												<FIELD name="project">
203
													<xsl:value-of select="$projectId"/>
204
												</FIELD>
205
												<FIELD name="resporganization">
206
													<xsl:value-of select="$organizationId"/>
207
												</FIELD>
208

    
209
												<FIELD name="semanticclass">participant</FIELD>
210

    
211
											</ROW>
212

    
213
										</xsl:for-each>
214

    
215
										<xsl:variable name="leadOrgId"
216
										              select="concat($namespacePrefix, '::', normalize-space(.//ld-org/id))"/>
217
										<ROW table="dsm_organizations">
218
											<FIELD name="_dnet_resource_identifier_">
219
												<xsl:value-of select="$leadOrgId"/>
220
											</FIELD>
221
											<FIELD name="id">
222
												<xsl:value-of select="$leadOrgId"/>
223
											</FIELD>
224
											<FIELD name="legalname">
225
												<xsl:value-of select=".//ld-org/name"/>
226
											</FIELD>
227
											<xsl:variable name="country" select=".//ld-org/country"/>
228
											<xsl:if test="string-length($country) &gt; 0">
229
												<FIELD name="country">
230
													<xsl:value-of select="$country"/>
231
												</FIELD>
232
											</xsl:if>
233

    
234
											<FIELD name="collectedfrom">
235
												<xsl:value-of select="$varDataSourceId"/>
236
											</FIELD>
237
											<FIELD name="provenanceAction"
238
											>sysimport:crosswalk:entityregistry</FIELD>
239
										</ROW>
240

    
241
										<ROW table="project_organization">
242
											<FIELD name="_dnet_resource_identifier_">
243
												<xsl:value-of
244
														select='concat($projectId, "@@", $leadOrgId)'/>
245
											</FIELD>
246
											<FIELD name="project">
247
												<xsl:value-of select="$projectId"/>
248
											</FIELD>
249
											<FIELD name="resporganization">
250
												<xsl:value-of select="$leadOrgId"/>
251
											</FIELD>
252
											<FIELD name="participantnumber" type="int">1</FIELD>
253
											<FIELD name="semanticclass">coordinator</FIELD>
254
										</ROW>
255

    
256
									</ROWS>
257
								</metadata>
258
							</record>
259
						</xsl:template>
260

    
261
						<xsl:template match="per:person">
262
							<xsl:variable name="personSurname"
263
							              select="normalize-space(.//*[local-name() = 'surname'])"/>
264
							<xsl:variable name="personFirstName"
265
							              select="normalize-space(.//*[local-name() = 'firstName'])"/>
266
							<xsl:variable name="contactfullname">
267
								<xsl:choose>
268
									<xsl:when
269
											test="string-length($personFirstName) &gt; 0 and string-length($personSurname) &gt; 0">
270
										<xsl:value-of
271
												select="normalize-space(concat($personSurname, ', ', $personFirstName))"
272
										/>
273
									</xsl:when>
274
									<xsl:when test="string-length($personFirstName) &gt; 0">
275
										<xsl:value-of select="$personFirstName"/>
276
									</xsl:when>
277
									<xsl:when test="string-length($personSurname) &gt; 0">
278
										<xsl:value-of select="$personSurname"/>
279
									</xsl:when>
280
									<xsl:otherwise>
281
										<xsl:value-of select="''"/>
282
									</xsl:otherwise>
283
								</xsl:choose>
284
							</xsl:variable>
285
							<xsl:value-of select="concat($contactfullname,';')"/>
286
						</xsl:template>
287
					</xsl:stylesheet>
288

    
289
]]>
290
				</CODE>
291
			</SCRIPT>
292
		</CONFIGURATION>
293
		<STATUS/>
294
		<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
295
	</BODY>
296
</RESOURCE_PROFILE>
(22-22/32)