Project

General

Profile

« Previous | Next » 

Revision 59665

#6000: temporary transformation rules to fix organizations from re3data and opendoar

View differences:

modules/dnet-openaireplus-profiles/trunk/src/main/resources/eu/dnetlib/test/profiles/TransformationRuleDSResources/TransformationRuleDSResourceType/datasources/re3data2db_TMP.xml
1
<RESOURCE_PROFILE>
2
	<HEADER>
3
		<RESOURCE_IDENTIFIER value="2b85d042-815d-4058-9374-7c64d099d46c_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
4
		<RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
5
		<RESOURCE_KIND value="TransformationRuleDSResources"/>
6
		<RESOURCE_URI value=""/>
7
		<DATE_OF_CREATION value="2019-03-18T17:59:33+00:00"/>
8
	</HEADER>
9
	<BODY>
10
		<CONFIGURATION>
11
			<IMPORTED/>
12
			<SCRIPT>
13
				<TITLE>RE3DATA FIX ORGS</TITLE>
14
				<CODE>
15

  
16
					<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
17
									xmlns:dnet="eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions" version="2.0">
18

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

  
22
						<xsl:variable name="dsId"
23
									  select="concat($namespacePrefix, '::', normalize-space(.//*[local-name() = 're3data.orgIdentifier']))"/>
24
						<xsl:variable name="subjects">
25
							<xsl:for-each select="//*[local-name() = 'subject']">
26
								<xsl:if test="position() > 1"> @@ </xsl:if>
27
								<xsl:value-of select="substring-after(., ' ')"/>
28
							</xsl:for-each>
29
						</xsl:variable>
30

  
31
						<xsl:template match="/">
32
							<record>
33

  
34
								<xsl:copy-of select=".//*[local-name() = 'header']"/>
35
								<metadata>
36
									<ROWS>
37
										<xsl:for-each select="//*[local-name() = 'institution']">
38
											<xsl:variable name="orgId"
39
														  select="concat($namespacePrefix, '::', dnet:md5(concat(normalize-space(./*[local-name() = 'institutionName']), '_', normalize-space(./*[local-name() = 'institutionCountry']))))"/>
40
											<ROW table="dsm_organizations">
41
												<FIELD name="_dnet_resource_identifier_">
42
													<xsl:value-of select="$orgId"/>
43
												</FIELD>
44
												<FIELD name="id">
45
													<xsl:value-of select="$orgId"/>
46
												</FIELD>
47
												<FIELD name="legalname">
48
													<xsl:value-of select="./*[local-name() = 'institutionName']"/>
49
												</FIELD>
50
												<xsl:variable name="orgShortname">
51
													<xsl:value-of
52
															select="./*[local-name() = 'institutionAdditionalName'][1]"/>
53
												</xsl:variable>
54
												<xsl:if test="upper-case($orgShortname) = $orgShortname">
55
													<FIELD name="legalshortname">
56
														<xsl:value-of select="$orgShortname"/>
57
													</FIELD>
58
												</xsl:if>
59
												<FIELD name="websiteurl">
60
													<xsl:choose>
61
														<xsl:when
62
																test="starts-with(normalize-space(./*[local-name() = 'institutionURL']), 'http')">
63
															<xsl:value-of select="./*[local-name() = 'institutionURL']"
64
															/>
65
														</xsl:when>
66
														<xsl:when
67
																test="string-length(normalize-space(./*[local-name() = 'institutionURL'])) > 0">
68
															<xsl:value-of
69
																	select="concat('http://', normalize-space(./*[local-name() = 'institutionURL']))"
70
															/>
71
														</xsl:when>
72
													</xsl:choose>
73
												</FIELD>
74
												<FIELD name="country">
75
													<xsl:value-of select="./*[local-name() = 'institutionCountry']"/>
76
												</FIELD>
77
												<xsl:if test="./*[local-name() = 'institutionType'] = 'non-profit'">
78
													<FIELD name="ec_nonprofit" type="boolean">true</FIELD>
79
												</xsl:if>
80
												<FIELD name="collectedfrom">
81
													<xsl:value-of select="$varDataSourceId"/>
82
												</FIELD>
83
												<FIELD name="provenanceaction"
84
												>sysimport:crosswalk:entityregistry</FIELD>
85
											</ROW>
86

  
87
											<ROW table="dsm_datasource_organization">
88
												<FIELD name="_dnet_resource_identifier_">
89
													<xsl:value-of select="concat($dsId, '@@', $orgId)"/>
90
												</FIELD>
91
												<FIELD name="datasource">
92
													<xsl:value-of select="$dsId"/>
93
												</FIELD>
94
												<FIELD name="organization">
95
													<xsl:value-of select="$orgId"/>
96
												</FIELD>
97
											</ROW>
98
										</xsl:for-each>
99

  
100
									</ROWS>
101
								</metadata>
102
							</record>
103
						</xsl:template>
104
					</xsl:stylesheet>
105

  
106
				</CODE>
107
			</SCRIPT>
108
		</CONFIGURATION>
109
		<STATUS/>
110
		<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
111
	</BODY>
112
</RESOURCE_PROFILE>
modules/dnet-openaireplus-profiles/trunk/src/main/resources/eu/dnetlib/test/profiles/TransformationRuleDSResources/TransformationRuleDSResourceType/datasources/opendoar2dbrest_TMP.xml
1
<RESOURCE_PROFILE>
2
    <HEADER>
3
        <RESOURCE_IDENTIFIER value="5e845f47-7731-40a1-9f25-3f4419f8e403_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
4
        <RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
5
        <RESOURCE_KIND value="TransformationRuleDSResources"/>
6
        <RESOURCE_URI value=""/>
7
        <DATE_OF_CREATION value="2019-11-11T10:35:54+00:00"/>
8
    </HEADER>
9
    <BODY>
10
        <CONFIGURATION>
11
            <IMPORTED/>
12
            <SCRIPT>
13
                <TITLE>OPENDOAR FIX ORGS</TITLE>
14
                <CODE>
15
                    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
16
                                    xmlns:dnet="eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions" version="2.0">
17
                        <xsl:param name="varDataSourceId"/>
18
                        <xsl:variable name="namespacePrefix" select="string('opendoar____')"/>
19

  
20
                        <xsl:template match="/">
21
                            <record>
22
                                <xsl:copy-of select=".//*[local-name() = 'header']"/>
23
                                <metadata>
24
                                    <xsl:variable name="rid" select="normalize-space(//items/system_metadata/id)"/>
25
                                    <xsl:variable name="datasourceId" select="concat($namespacePrefix, '::', $rid)"/>
26
                                    <ROWS>
27
                                        <xsl:for-each select="//organisation">
28
                                            <xsl:variable name="oUrl" select="normalize-space(./url)"/>
29
                                            <xsl:variable name="preferredNameLanguage"
30
                                                          select="./name/preferred_phrases[./value='name'][1]/language[1]"/>
31
                                            <xsl:variable name="oName">
32
                                                <xsl:choose>
33
                                                    <xsl:when test="string-length($preferredNameLanguage[1]/text()) > 0 and ./name[./language = $preferredNameLanguage]/name">
34
                                                        <xsl:value-of
35
                                                                select="./name[./language = $preferredNameLanguage]/name/text()"/>
36
                                                    </xsl:when>
37
                                                    <xsl:otherwise>
38
                                                        <xsl:value-of select="./name[1]/name/text()"/>
39
                                                    </xsl:otherwise>
40
                                                </xsl:choose>
41
                                            </xsl:variable>
42
                                            <xsl:variable name="oAcronym">
43
                                                <xsl:choose>
44
                                                    <xsl:when test="string-length($preferredNameLanguage[1]/text()) > 0 and ./name[./language = $preferredNameLanguage]/acronym">
45
                                                        <xsl:value-of
46
                                                                select="./name[./language = $preferredNameLanguage]/acronym"/>
47
                                                    </xsl:when>
48
                                                    <xsl:otherwise>
49
                                                        <xsl:value-of select="./name[1]/acronym"/>
50
                                                    </xsl:otherwise>
51
                                                </xsl:choose>
52
                                            </xsl:variable>
53
                                            <xsl:variable name="oCountry"
54
                                                          select="upper-case(normalize-space(./country))"/>
55
                                            <xsl:variable name="organizationId"
56
                                                          select="translate(concat($namespacePrefix, '::', $oName, '_', $oCountry), ' ', '_')"/>
57
                                            <xsl:if test="string-length($oName) > 0">
58
                                                <ROW table="dsm_organizations">
59
                                                    <FIELD name="_dnet_resource_identifier_">
60
                                                        <xsl:value-of select="$organizationId"/>
61
                                                    </FIELD>
62
                                                    <FIELD name="id">
63
                                                        <xsl:value-of select="$organizationId"/>
64
                                                    </FIELD>
65
                                                    <FIELD name="legalname">
66
                                                        <xsl:value-of select="$oName"/>
67
                                                    </FIELD>
68
                                                    <FIELD name="legalshortname">
69
                                                        <xsl:value-of select="normalize-space($oAcronym)"/>
70
                                                    </FIELD>
71
                                                    <FIELD name="websiteurl">
72
                                                        <xsl:choose>
73
                                                            <xsl:when test="starts-with(normalize-space($oUrl), 'http')">
74
                                                                <xsl:value-of select="normalize-space($oUrl)"/>
75
                                                            </xsl:when>
76
                                                            <xsl:when test="string-length(normalize-space($oUrl)) > 0">
77
                                                                <xsl:value-of
78
                                                                        select="concat('http://', normalize-space($oUrl))"/>
79
                                                            </xsl:when>
80
                                                        </xsl:choose>
81
                                                    </FIELD>
82

  
83
                                                    <FIELD name="country">
84
                                                        <xsl:choose>
85
                                                            <xsl:when test="$oCountry = 'UK'">GB</xsl:when>
86
                                                            <xsl:otherwise>
87
                                                                <xsl:value-of select="$oCountry"/>
88
                                                            </xsl:otherwise>
89
                                                        </xsl:choose>
90
                                                    </FIELD>
91

  
92
                                                    <FIELD name="collectedfrom">
93
                                                        <xsl:value-of select="$varDataSourceId"/>
94
                                                    </FIELD>
95
                                                    <FIELD name="provenanceaction"
96
                                                    >sysimport:crosswalk:entityregistry</FIELD>
97
                                                </ROW>
98

  
99
                                                <ROW table="dsm_datasource_organization">
100
                                                    <FIELD name="_dnet_resource_identifier_">
101
                                                        <xsl:value-of select="concat($datasourceId, '@@', $organizationId)"
102
                                                        />
103
                                                    </FIELD>
104
                                                    <FIELD name="datasource">
105
                                                        <xsl:value-of select="$datasourceId"/>
106
                                                    </FIELD>
107
                                                    <FIELD name="organization">
108
                                                        <xsl:value-of select="$organizationId"/>
109
                                                    </FIELD>
110
                                                </ROW>
111
                                            </xsl:if>
112
                                        </xsl:for-each>
113
                                    </ROWS>
114
                                </metadata>
115
                            </record>
116
                        </xsl:template>
117

  
118
                    </xsl:stylesheet>
119

  
120

  
121
                </CODE>
122
            </SCRIPT>
123
        </CONFIGURATION>
124
        <STATUS/>
125
        <SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
126
    </BODY>
127
</RESOURCE_PROFILE>

Also available in: Unified diff