Project

General

Profile

1
<RESOURCE_PROFILE>
2
	<HEADER>
3
		<RESOURCE_IDENTIFIER value="_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"
18
                exclude-result-prefixes="xs" version="2.0">
19

    
20
	<xsl:param name="parentDatasourceId"/>
21
	<xsl:param name="namespacePrefix"/>
22

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

    
26
	<xsl:template match="/">
27

    
28

    
29
		<record>
30

    
31
			<xsl:copy-of select=".//*[local-name()='header']"/>
32

    
33
			<metadata>
34
				<ROWS>
35
					<xsl:variable name="projectCode"
36
					              select="//*[local-name()='identifier' and ./@*[local-name()='type' and .='RCUK']]"/>
37
					<xsl:variable name="projectId"
38
					              select="concat($namespacePrefix, '::', $projectCode)"/>
39

    
40
					<xsl:variable name="sDate" select=".//*[local-name()='fund']/*[local-name()='start']"/>
41
					<xsl:variable name="eDate" 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 select="substring-before($sDate, '+')"/>
46
							</xsl:when>
47
							<xsl:when test="contains($sDate, 'Z')">
48
								<xsl:value-of select="substring-before($sDate, 'Z')"/>
49
							</xsl:when>
50
							<xsl:otherwise>
51
								<xsl:value-of select="$sDate"/>
52
							</xsl:otherwise>
53
						</xsl:choose>
54
					</xsl:variable>
55
					<xsl:variable name="endDate">
56
						<xsl:choose>
57
							<xsl:when test="contains($eDate, '+')">
58
								<xsl:value-of select="substring-before($eDate, '+')"/>
59
							</xsl:when>
60
							<xsl:when test="contains($eDate, 'Z')">
61
								<xsl:value-of select="substring-before($eDate, 'Z')"/>
62
							</xsl:when>
63
							<xsl:otherwise>
64
								<xsl:value-of select="$eDate"/>
65
							</xsl:otherwise>
66
						</xsl:choose>
67
					</xsl:variable>
68

    
69
					<xsl:variable name="personCode"
70
					              select=".//*[local-name()='person']/@*[local-name()='id']"/>
71
					<xsl:variable name="personId"
72
					              select="concat($namespacePrefix,'::',$personCode)"/>
73
					<xsl:variable name="funding" select=".//*[local-name()='funder']/name"/>
74
					<xsl:variable name="fundingId">
75
							<xsl:if test="string-length($funding) > 0">
76
								<xsl:value-of select="concat($funderID ,'::' , .//*[local-name()='funder']/name)"/>
77
							</xsl:if>
78
							<xsl:otherwise><xsl:value-of select="$funderID"/></xsl:otherwise>
79
					</xsl:variable>
80

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

    
109
						<xsl:variable name="personSurname" select="normalize-space(.//*[local-name()='surname'])"/>
110
						<xsl:variable name="personFirstName" select="normalize-space(.//*[local-name()='firstName'])"/>
111
						<xsl:variable name="contactfullname">
112
							<xsl:choose>
113
								<xsl:when test="string-length($personFirstName) &gt; 0 and string-length($personSurname) &gt; 0">
114
									<xsl:value-of select="normalize-space(concat($personSurname, ', ', $personFirstName))"/>
115
								</xsl:when>
116
								<xsl:when test="string-length($personFirstName) &gt; 0">
117
									<xsl:value-of select="$personFirstName"/>
118
								</xsl:when>
119
								<xsl:when test="string-length($personSurname) &gt; 0">
120
									<xsl:value-of select="$personSurname"/>
121
								</xsl:when>
122
								<xsl:otherwise>
123
									<xsl:value-of select="''"/>
124
								</xsl:otherwise>
125
							</xsl:choose>
126
						</xsl:variable>
127
						<xsl:if test="string-length($contactfullname) &gt; 0">
128
							<FIELD name="contactfullname">
129
								<xsl:value-of select="$contactfullname"/>
130
							</FIELD>
131
						</xsl:if>
132
					</ROW>
133

    
134
					<ROW table="project_fundingpath">
135
						<FIELD name="_dnet_resource_identifier_">
136
							<xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
137
						</FIELD>
138
						<FIELD name="funding">
139
							<xsl:value-of select="$fundingId"/>
140
						</FIELD>
141
						<FIELD name="project">
142
							<xsl:value-of select="$projectId"/>
143
						</FIELD>
144
						<FIELD name="startdate" type="date" format="{$dateFormat}">
145
							<xsl:value-of select="$startDate"/>
146
						</FIELD>
147
						<FIELD name="enddate" type="date" format="{$dateFormat}">
148
							<xsl:value-of select="$endDate"/>
149
						</FIELD>
150
					</ROW>
151

    
152
					<xsl:for-each select=".//pp-org">
153
						<xsl:variable name="organizationId" select="concat($namespacePrefix, '::', normalize-space(./id))"/>
154
						<xsl:variable name="country" select="./country"/>
155
						<ROW table="organizations">
156
							<FIELD name="_dnet_resource_identifier_">
157
								<xsl:value-of select="$organizationId"/>
158
							</FIELD>
159
							<FIELD name="id">
160
								<xsl:value-of select="$organizationId"/>
161
							</FIELD>
162
							<FIELD name="legalname">
163
								<xsl:value-of select="./name"/>
164
							</FIELD>
165

    
166
							<xsl:if test="string-length($country) &gt; 0">
167
								<FIELD name="countryclass">
168
									<xsl:value-of select="$country"/>
169
								</FIELD>
170
								<FIELD name="countryscheme">dnet:countries</FIELD>
171
							</xsl:if>
172

    
173
							<FIELD name="collectedfrom">
174
								<xsl:value-of select="$parentDatasourceId"/>
175
							</FIELD>
176
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
177
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
178
						</ROW>
179
						<ROW table="project_organization">
180
							<FIELD name="_dnet_resource_identifier_">
181
								<xsl:value-of select='concat($projectId, "@@", $organizationId)'/>
182
							</FIELD>
183
							<FIELD name="project">
184
								<xsl:value-of select="$projectId"/>
185
							</FIELD>
186
							<FIELD name="resporganization">
187
								<xsl:value-of select="$organizationId"/>
188
							</FIELD>
189

    
190
							<FIELD name="semanticclass">participant</FIELD>
191
							<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
192
						</ROW>
193

    
194
					</xsl:for-each>
195

    
196
					<xsl:variable name="leadOrgId"
197
					              select="concat($namespacePrefix, '::', normalize-space(.//ld-org/id))"/>
198
					<ROW table="organizations">
199
						<FIELD name="_dnet_resource_identifier_">
200
							<xsl:value-of select="$leadOrgId"/>
201
						</FIELD>
202
						<FIELD name="id">
203
							<xsl:value-of select="$leadOrgId"/>
204
						</FIELD>
205
						<FIELD name="legalname">
206
							<xsl:value-of select=".//ld-org/name"/>
207
						</FIELD>
208
						<xsl:variable name="country" select=".//ld-org/country"/>
209
						<xsl:if test="string-length($country) &gt; 0">
210
							<FIELD name="countryclass">
211
								<xsl:value-of select="$country"/>
212
							</FIELD>
213
							<FIELD name="countryscheme">dnet:countries</FIELD>
214
						</xsl:if>
215

    
216
						<FIELD name="collectedfrom">
217
							<xsl:value-of select="$parentDatasourceId"/>
218
						</FIELD>
219
						<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
220
						<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
221
					</ROW>
222

    
223
					<ROW table="project_organization">
224
						<FIELD name="_dnet_resource_identifier_">
225
							<xsl:value-of select='concat($projectId, "@@", $leadOrgId)'/>
226
						</FIELD>
227
						<FIELD name="project">
228
							<xsl:value-of select="$projectId"/>
229
						</FIELD>
230
						<FIELD name="resporganization">
231
							<xsl:value-of select="$leadOrgId"/>
232
						</FIELD>
233
						<FIELD name="participantnumber" type="int">1</FIELD>
234
						<FIELD name="semanticclass">coordinator</FIELD>
235
						<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
236
					</ROW>
237

    
238
				</ROWS>
239
			</metadata>
240
		</record>
241
	</xsl:template>
242

    
243
</xsl:stylesheet>
244
		]]>
245
		</CODE>
246
		</SCRIPT>
247
		</CONFIGURATION>
248
<STATUS/>
249
<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
250
		</BODY>
251
		</RESOURCE_PROFILE>
(13-13/19)