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
							<FIELD name="contracttypeclass">UNKNOWN</FIELD>
84
							<FIELD name="contracttypescheme">wt:contractTypes</FIELD>
85

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

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

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

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