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
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
16
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:per="http://gtr.ukri.org/gtr/api/person" exclude-result-prefixes="xs" version="2.0">
17

    
18
    <xsl:param name="varDataSourceId"/>
19
    <xsl:variable name="namespacePrefix" select="string('rcuk________')"/>
20

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

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

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

    
76
                    <ROW table="projects">
77
                        <FIELD name="_dnet_resource_identifier_">
78
                            <xsl:value-of select="$projectId"/>
79
                        </FIELD>
80
                        <FIELD name="id">
81
                            <xsl:value-of select="$projectId"/>
82
                        </FIELD>
83
                        <FIELD name="code">
84
                            <xsl:value-of select="$projectCode"/>
85
                        </FIELD>
86
                        <FIELD name="title">
87
                            <xsl:value-of select=".//*[local-name() = 'title']"/>
88
                        </FIELD>
89
                        <FIELD name="startdate" type="date" format="{$dateFormat}">
90
                            <xsl:value-of select="$startDate"/>
91
                        </FIELD>
92
                        <FIELD name="enddate" type="date" format="{$dateFormat}">
93
                            <xsl:value-of select="$endDate"/>
94
                        </FIELD>
95
                        <FIELD name="collectedfrom">
96
                            <xsl:value-of select="$varDataSourceId"/>
97
                        </FIELD>
98
                        <FIELD name="provenanceactionclass"
99
                            >sysimport:crosswalk:entityregistry</FIELD>
100
                        <FIELD name="optional1">
101
                            <xsl:value-of
102
                                select="concat(.//*[local-name() = 'valuePounds']/@*[local-name() = 'amount'], ' ', .//*[local-name() = 'valuePounds']/@*[local-name() = 'currencyCode'])"
103
                            />
104
                        </FIELD>
105

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

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

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

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

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

    
158
                            </xsl:if>
159

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

    
182
                    </xsl:for-each>
183

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

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

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

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

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