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="countryclass">
156
                                    <xsl:value-of select="$country"/>
157
                                </FIELD>
158
                                <FIELD name="countryscheme">dnet:countries</FIELD>
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

    
181
                            <FIELD name="role">participant</FIELD>
182

    
183
                        </ROW>
184

    
185
                    </xsl:for-each>
186

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

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

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

    
229
                </ROWS>
230
            </metadata>
231
        </record>
232
    </xsl:template>
233

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

    
262
		]]>
263
		</CODE>
264
		</SCRIPT>
265
		</CONFIGURATION>
266
<STATUS/>
267
<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
268
		</BODY>
269
		</RESOURCE_PROFILE>
(14-14/20)