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

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

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

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