Project

General

Profile

1
<RESOURCE_PROFILE>
2
	<HEADER>
3
		<RESOURCE_IDENTIFIER value="2853e0ea-47b9-4ea2-81c3-14ae74b5f7ff_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>WT 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"
17
                exclude-result-prefixes="xs" version="2.0">
18

    
19
	<xsl:param name="varDataSourceId"/>
20
	<xsl:variable name="namespacePrefix" select="string('wt__________')"/>
21
	<xsl:param name="quote">"</xsl:param>
22

    
23
	<xsl:variable name="funderID" select="concat($namespacePrefix, '::WT')"/>
24

    
25
	<xsl:variable name="stream" select="normalize-space(.//Grant/Stream)"/>
26
	<xsl:variable name="fundingID">
27
		<xsl:choose>
28
			<xsl:when test="string-length($stream) &gt; 0">
29
				<xsl:value-of select="concat($funderID, '::', $stream)"/>
30
			</xsl:when>
31
			<xsl:otherwise>
32
				<xsl:value-of select="$funderID"/>
33
			</xsl:otherwise>
34
		</xsl:choose>
35
	</xsl:variable>
36

    
37
	<xsl:variable name="projectID" select="concat($namespacePrefix, '::', .//Grant/Id)"/>
38

    
39
	<xsl:variable name="orgID" select="concat($namespacePrefix, '::', translate(.//Institution/Name, ' ,', '__'))"/>
40
	<!--
41
		personID is fine as long as WT gives us one person per project. If they fix their export, we might have 2 persons (or more).
42
		At this stage we are somehow fine to loose one of the persons (the second project with the same id overwrites the previous project
43
	 -->
44
	<xsl:variable name="personID" select="concat($namespacePrefix, '::', .//Person/Alias[@Source='Wellcome Trust'])"/>
45
	<xsl:variable name="startDate" select="translate(.//Grant/StartDate,'/\','--')"/>
46
	<xsl:variable name="endDate" select="translate(.//Grant/EndDate,'/\','--')"/>
47

    
48
	<xsl:variable name="dateFormat" select="string('yyyy-MM-dd')"/>
49

    
50
	<xsl:template name="getJson">
51
		<xsl:param name="varName"/>
52
		<xsl:param name="value"/>
53
		<xsl:value-of select="concat($quote, $varName, $quote, ':', $quote, $value, $quote)"/>
54
	</xsl:template>
55

    
56
	<xsl:template match="/">
57
		<record>
58

    
59
			<xsl:copy-of select=".//*[local-name()='header']"/>
60
			<metadata>
61
				<ROWS>
62
					<xsl:if test="string-length(normalize-space(.//Grant/Title)) &gt; 0 and string-length($projectID) &gt; 0">
63
						<ROW table="projects">
64
							<FIELD name="_dnet_resource_identifier_">
65
								<xsl:value-of select="$projectID"/>
66
							</FIELD>
67
							<FIELD name="id">
68
								<xsl:value-of select="$projectID"/>
69
							</FIELD>
70
							<FIELD name="code">
71
								<xsl:value-of select=".//Grant/Id"/>
72
							</FIELD>
73
							<FIELD name="startdate" type="date" format="{$dateFormat}">
74
								<xsl:value-of select="$startDate"/>
75
							</FIELD>
76
							<FIELD name="enddate" type="date" format="{$dateFormat}">
77
								<xsl:value-of select="$endDate"/>
78
							</FIELD>
79
							<FIELD name="title">
80
								<xsl:value-of select=".//Grant/Title"/>
81
							</FIELD>
82
							<FIELD name="contracttypeclass">UNKNOWN</FIELD>
83
							<FIELD name="contracttypescheme">wt:contractTypes</FIELD>
84

    
85
							<FIELD name="acronym"></FIELD>
86
							<FIELD name="keywords">
87
								<xsl:value-of select="normalize-space(.//Grant/Type)"/>
88
							</FIELD>
89
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
90
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
91
							<FIELD name="collectedfrom">
92
								<xsl:value-of select="$varDataSourceId"/>
93
							</FIELD>
94
							<FIELD name="optional1">
95
								<xsl:value-of select="concat(.//Grant/Amount, ' ', .//Grant/Amount/@Currency)"/>
96
							</FIELD>
97
							<xsl:if test="string-length(normalize-space(.//Grant/Alias[1]/text())) > 0">
98
								<xsl:variable name="projectAlias">
99
									<xsl:call-template name="getJson">
100
										<xsl:with-param name="varName">alias</xsl:with-param>
101
										<xsl:with-param name="value">
102
											<xsl:value-of select=".//Grant/Alias[1]"/>
103
										</xsl:with-param>
104
									</xsl:call-template>
105
								</xsl:variable>
106
								<xsl:variable name="jsonExtra">
107
									<xsl:value-of select="concat('{', $projectAlias, '}')"/>
108
								</xsl:variable>
109
								<FIELD name="jsonextrainfo">
110
									<xsl:value-of select="$jsonExtra"/>
111
								</FIELD>
112
							</xsl:if>
113
							<!-- oa_mandate_for_publications is true for projects started after 2005 -->
114
							<xsl:choose>
115
								<!-- Invalid date: we need at least YYYY -->
116
								<xsl:when test="string-length($startDate) &lt; 4">
117
									<FIELD name="oa_mandate_for_publications" type="boolean">false</FIELD>
118
								</xsl:when>
119
								<xsl:when test="xs:date($startDate) >= xs:date('2015-01-01')">
120
									<FIELD name="oa_mandate_for_publications" type="boolean">true</FIELD>
121
								</xsl:when>
122
								<xsl:otherwise><FIELD name="oa_mandate_for_publications" type="boolean">false</FIELD></xsl:otherwise>
123
							</xsl:choose>
124

    
125
							<xsl:variable name="personSurname" select="normalize-space(.//Person/FamilyName)"/>
126
							<xsl:variable name="personFirstName" select="normalize-space(.//Person/GivenName)"/>
127
							<xsl:variable name="personInitials" select="normalize-space(.//Person/Initials)"/>
128
							<xsl:variable name="personTitle" select="normalize-space(.//Person/Title)"/>
129

    
130
							<xsl:variable name="contactfullname">
131
								<xsl:choose>
132
									<xsl:when test="string-length($personFirstName) &gt; 0 and string-length($personSurname) &gt; 0">
133
										<xsl:value-of select="normalize-space(concat($personTitle, ' ', $personSurname, ', ', $personFirstName, ' ', $personInitials))"/>
134
									</xsl:when>
135
									<xsl:when test="string-length($personFirstName) &gt; 0">
136
										<xsl:value-of select="normalize-space(concat($personFirstName, ' ', $personInitials))"/>
137
									</xsl:when>
138
									<xsl:when test="string-length($personSurname) &gt; 0">
139
										<xsl:choose>
140
											<xsl:when test="string-length($personInitials) &gt; 0">
141
												<xsl:value-of select="normalize-space(concat($personTitle, ' ', $personSurname, ', ', $personInitials))"/>
142
											</xsl:when>
143
											<xsl:otherwise>
144
												<xsl:value-of select="normalize-space(concat($personTitle, ' ', $personSurname))"/>
145
											</xsl:otherwise>
146
										</xsl:choose>
147
									</xsl:when>
148
									<xsl:otherwise>
149
										<xsl:value-of select="''"/>
150
									</xsl:otherwise>
151
								</xsl:choose>
152
							</xsl:variable>
153
							<xsl:if test="string-length($contactfullname) &gt; 0">
154
								<FIELD name="contactfullname">
155
									<xsl:value-of select="$contactfullname"/>
156
								</FIELD>
157
							</xsl:if>
158
							<FIELD name="lastupdate" type="date"><xsl:value-of select="current-dateTime()"/></FIELD>
159
						</ROW>
160
						<ROW table="project_fundingpath">
161
							<FIELD name="_dnet_resource_identifier_">
162
								<xsl:value-of select="concat($fundingID,'@@', $projectID)"/>
163
							</FIELD>
164
							<FIELD name="funding">
165
								<xsl:value-of select="$fundingID"/>
166
							</FIELD>
167
							<FIELD name="project">
168
								<xsl:value-of select="$projectID"/>
169
							</FIELD>
170
							<FIELD name="startdate" type="date" format="{$dateFormat}">
171
								<xsl:value-of select="$startDate"/>
172
							</FIELD>
173
							<FIELD name="enddate" type="date" format="{$dateFormat}">
174
								<xsl:value-of select="$endDate"/>
175
							</FIELD>
176
						</ROW>
177
						<xsl:if test="not(concat($namespacePrefix, '::') = $orgID)">
178
							<ROW table="dsm_organizations">
179
								<FIELD name="_dnet_resource_identifier_">
180
									<xsl:value-of select="$orgID"/>
181
								</FIELD>
182
								<FIELD name="id">
183
									<xsl:value-of select="$orgID"/>
184
								</FIELD>
185
								<FIELD name="legalname">
186
									<xsl:value-of select=".//Institution/Name"/>
187
								</FIELD>
188
								<FIELD name="collectedfrom">
189
									<xsl:value-of select="$varDataSourceId"/>
190
								</FIELD>
191
								<FIELD name="provenanceaction">sysimport:crosswalk:entityregistry</FIELD>
192
								<FIELD name="trust" type="float">0.8</FIELD>
193
								<FIELD name="lastupdate" type="date"><xsl:value-of select="current-dateTime()"/></FIELD>
194
							</ROW>
195
							<ROW table="project_organization">
196
								<FIELD name="_dnet_resource_identifier_">
197
									<xsl:value-of select="concat($projectID, '@@', $orgID)"/>
198
								</FIELD>
199
								<FIELD name="project">
200
									<xsl:value-of select="$projectID"/>
201
								</FIELD>
202
								<FIELD name="resporganization">
203
									<xsl:value-of select="$orgID"/>
204
								</FIELD>
205
								<FIELD name="semanticclass">coordinator</FIELD>
206

    
207
							</ROW>
208
						</xsl:if>
209
					</xsl:if>
210
				</ROWS>
211
			</metadata>
212
		</record>
213
	</xsl:template>
214
</xsl:stylesheet>
215
		</CODE>
216
		</SCRIPT>
217
		</CONFIGURATION>
218
<STATUS/>
219
<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
220
		</BODY>
221
		</RESOURCE_PROFILE>
(22-22/22)