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
					<![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="varDataSourceId"/>
21
	<xsl:variable name="namespacePrefix" select="string('wt__________')"/>
22
	<xsl:param name="quote">"</xsl:param>
23

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

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

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

    
40
	<xsl:variable name="orgID" select="concat($namespacePrefix, '::', translate(.//Institution/Name, ' ,', '__'))"/>
41
	<!--
42
		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).
43
		At this stage we are somehow fine to loose one of the persons (the second project with the same id overwrites the previous project
44
	 -->
45
	<xsl:variable name="personID" select="concat($namespacePrefix, '::', .//Person/Alias[@Source='Wellcome Trust'])"/>
46
	<xsl:variable name="startDate" select="translate(.//Grant/StartDate,'/\','--')"/>
47
	<xsl:variable name="endDate" select="translate(.//Grant/EndDate,'/\','--')"/>
48

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

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

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

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

    
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
							 <xsl:if test=".//Grant/Abstract">
95
                                <FIELD name="summary">
96
                                    <xsl:value-of select=".//Grant/Abstract"/>
97
                                </FIELD>
98
                            </xsl:if>
99
                            <xsl:if test=".//Grant/Amount">
100
                                <FIELD name="fundedamount" type="float">
101
                                    <xsl:value-of select=".//Grant/Amount"/>
102
                                </FIELD>
103
                                <FIELD name="currency">
104
                                    <xsl:value-of select=".//Grant/Amount/@Currency"/>
105
                                </FIELD>
106
                            </xsl:if>
107
							<xsl:if test="string-length(normalize-space(.//Grant/Alias[1]/text())) > 0">
108
								<xsl:variable name="projectAlias">
109
									<xsl:call-template name="getJson">
110
										<xsl:with-param name="varName">alias</xsl:with-param>
111
										<xsl:with-param name="value">
112
											<xsl:value-of select=".//Grant/Alias[1]"/>
113
										</xsl:with-param>
114
									</xsl:call-template>
115
								</xsl:variable>
116
								<xsl:variable name="jsonExtra">
117
									<xsl:value-of select="concat('{', $projectAlias, '}')"/>
118
								</xsl:variable>
119
								<FIELD name="jsonextrainfo">
120
									<xsl:value-of select="$jsonExtra"/>
121
								</FIELD>
122
							</xsl:if>
123
							<!-- oa_mandate_for_publications is true for projects started after 2005 -->
124
							<xsl:choose>
125
								<!-- Invalid date: we need at least YYYY -->
126
								<xsl:when test="string-length($startDate) &lt; 4">
127
									<FIELD name="oa_mandate_for_publications" type="boolean">false</FIELD>
128
								</xsl:when>
129
								<xsl:when test="xs:date($startDate) >= xs:date('2015-01-01')">
130
									<FIELD name="oa_mandate_for_publications" type="boolean">true</FIELD>
131
								</xsl:when>
132
								<xsl:otherwise><FIELD name="oa_mandate_for_publications" type="boolean">false</FIELD></xsl:otherwise>
133
							</xsl:choose>
134

    
135
							<xsl:variable name="personSurname" select="normalize-space(.//Person/FamilyName)"/>
136
							<xsl:variable name="personFirstName" select="normalize-space(.//Person/GivenName)"/>
137
							<xsl:variable name="personInitials" select="normalize-space(.//Person/Initials)"/>
138
							<xsl:variable name="personTitle" select="normalize-space(.//Person/Title)"/>
139

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

    
217
							</ROW>
218
						</xsl:if>
219
					</xsl:if>
220
				</ROWS>
221
			</metadata>
222
		</record>
223
	</xsl:template>
224
</xsl:stylesheet>
225
]]>
226
				</CODE>
227
			</SCRIPT>
228
		</CONFIGURATION>
229
		<STATUS/>
230
		<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
231
	</BODY>
232
</RESOURCE_PROFILE>
(26-26/26)