Project

General

Profile

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="2018-06-04T11:15:30+00:00"/>
8
	</HEADER>
9
	<BODY>
10
		<CONFIGURATION>
11
			<IMPORTED/>
12
			<SCRIPT>
13
				<TITLE>RCUK 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('rcuk________')"/>
21

    
22
    <xsl:variable name="dateFormat" select="string('yyyy-MM-dd')"/>
23
    <xsl:variable name="funderID" select="concat($namespacePrefix, '::RCUK')"/>
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="optional1">
102
                            <xsl:value-of
103
                                select="concat(.//*[local-name() = 'valuePounds']/@*[local-name() = 'amount'], ' ', .//*[local-name() = 'valuePounds']/@*[local-name() = 'currencyCode'])"
104
                            />
105
                        </FIELD>
106

    
107
                        <xsl:variable name="principalInvestigators">
108
                            <xsl:apply-templates select=".//*[local-name() = 'person']"/>
109
                        </xsl:variable>
110

    
111
                        <xsl:if test="string-length($principalInvestigators) &gt; 0">
112
                            <FIELD name="contactfullname">
113
                                <xsl:value-of select="$principalInvestigators"/>
114
                            </FIELD>
115
                        </xsl:if>
116
                        <FIELD name="lastupdate" type="date">
117
                            <xsl:value-of select="current-dateTime()"/>
118
                        </FIELD>
119
                    </ROW>
120

    
121
                    <ROW table="project_fundingpath">
122
                        <FIELD name="_dnet_resource_identifier_">
123
                            <xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
124
                        </FIELD>
125
                        <FIELD name="funding">
126
                            <xsl:value-of select="$fundingId"/>
127
                        </FIELD>
128
                        <FIELD name="project">
129
                            <xsl:value-of select="$projectId"/>
130
                        </FIELD>
131
                        <FIELD name="startdate" type="date" format="{$dateFormat}">
132
                            <xsl:value-of select="$startDate"/>
133
                        </FIELD>
134
                        <FIELD name="enddate" type="date" format="{$dateFormat}">
135
                            <xsl:value-of select="$endDate"/>
136
                        </FIELD>
137
                    </ROW>
138

    
139
                    <xsl:for-each select=".//pp-org">
140
                        <xsl:variable name="organizationId"
141
                            select="concat($namespacePrefix, '::', normalize-space(./id))"/>
142
                        <xsl:variable name="country" select="./country"/>
143
                        <ROW table="dsm_organizations">
144
                            <FIELD name="_dnet_resource_identifier_">
145
                                <xsl:value-of select="$organizationId"/>
146
                            </FIELD>
147
                            <FIELD name="id">
148
                                <xsl:value-of select="$organizationId"/>
149
                            </FIELD>
150
                            <FIELD name="legalname">
151
                                <xsl:value-of select="./name"/>
152
                            </FIELD>
153

    
154
                            <xsl:if test="string-length($country) &gt; 0">
155
                                <FIELD name="country">
156
                                    <xsl:value-of select="$country"/>
157
                                </FIELD>
158

    
159
                            </xsl:if>
160

    
161
                            <FIELD name="collectedfrom">
162
                                <xsl:value-of select="$varDataSourceId"/>
163
                            </FIELD>
164
                            <FIELD name="provenanceaction"
165
                                >sysimport:crosswalk:entityregistry</FIELD>
166
                            <FIELD name="lastupdate" type="date">
167
                                <xsl:value-of select="current-dateTime()"/>
168
                            </FIELD>
169
                        </ROW>
170
                        <ROW table="project_organization">
171
                            <FIELD name="_dnet_resource_identifier_">
172
                                <xsl:value-of select='concat($projectId, "@@", $organizationId)'/>
173
                            </FIELD>
174
                            <FIELD name="project">
175
                                <xsl:value-of select="$projectId"/>
176
                            </FIELD>
177
                            <FIELD name="resporganization">
178
                                <xsl:value-of select="$organizationId"/>
179
                            </FIELD>
180
                            <FIELD name="semanticclass">participant</FIELD>
181
                        </ROW>
182

    
183
                    </xsl:for-each>
184

    
185
                    <xsl:variable name="leadOrgId"
186
                        select="concat($namespacePrefix, '::', normalize-space(.//ld-org/id))"/>
187
                    <ROW table="organizations">
188
                        <FIELD name="_dnet_resource_identifier_">
189
                            <xsl:value-of select="$leadOrgId"/>
190
                        </FIELD>
191
                        <FIELD name="id">
192
                            <xsl:value-of select="$leadOrgId"/>
193
                        </FIELD>
194
                        <FIELD name="legalname">
195
                            <xsl:value-of select=".//ld-org/name"/>
196
                        </FIELD>
197
                        <xsl:variable name="country" select=".//ld-org/country"/>
198
                        <xsl:if test="string-length($country) &gt; 0">
199
                            <FIELD name="countryclass">
200
                                <xsl:value-of select="$country"/>
201
                            </FIELD>
202
                            <FIELD name="countryscheme">dnet:countries</FIELD>
203
                        </xsl:if>
204

    
205
                        <FIELD name="collectedfrom">
206
                            <xsl:value-of select="$varDataSourceId"/>
207
                        </FIELD>
208
                        <FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
209
                        <FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
210
                    </ROW>
211

    
212
                    <ROW table="project_organization">
213
                        <FIELD name="_dnet_resource_identifier_">
214
                            <xsl:value-of select='concat($projectId, "@@", $leadOrgId)'/>
215
                        </FIELD>
216
                        <FIELD name="project">
217
                            <xsl:value-of select="$projectId"/>
218
                        </FIELD>
219
                        <FIELD name="resporganization">
220
                            <xsl:value-of select="$leadOrgId"/>
221
                        </FIELD>
222
                        <FIELD name="participantnumber" type="int">1</FIELD>
223
                        <FIELD name="semanticclass">coordinator</FIELD>
224
                    </ROW>
225

    
226
                </ROWS>
227
            </metadata>
228
        </record>
229
    </xsl:template>
230

    
231
    <xsl:template match="per:person">
232
        <xsl:variable name="personSurname"
233
            select="normalize-space(.//*[local-name() = 'surname'])"/>
234
        <xsl:variable name="personFirstName"
235
            select="normalize-space(.//*[local-name() = 'firstName'])"/>
236
        <xsl:variable name="contactfullname">
237
        <xsl:choose>
238
            <xsl:when
239
                test="string-length($personFirstName) &gt; 0 and string-length($personSurname) &gt; 0">
240
                <xsl:value-of
241
                    select="normalize-space(concat($personSurname, ', ', $personFirstName))"
242
                />
243
            </xsl:when>
244
            <xsl:when test="string-length($personFirstName) &gt; 0">
245
                <xsl:value-of select="$personFirstName"/>
246
            </xsl:when>
247
            <xsl:when test="string-length($personSurname) &gt; 0">
248
                <xsl:value-of select="$personSurname"/>
249
            </xsl:when>
250
            <xsl:otherwise>
251
                <xsl:value-of select="''"/>
252
            </xsl:otherwise>
253
        </xsl:choose>
254
        </xsl:variable>
255
        <xsl:value-of select="concat($contactfullname,';')"/>
256
    </xsl:template>
257
</xsl:stylesheet>
258
                    ]]>
259
				</CODE>
260
			</SCRIPT>
261
		</CONFIGURATION>
262
		<STATUS/>
263
		<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
264
	</BODY>
265
</RESOURCE_PROFILE>
(17-17/24)